StockLevelFormatterTest.php in Commerce Stock 8
File
modules/field/tests/src/Functional/StockLevelFormatterTest.php
View source
<?php
namespace Drupal\Tests\commerce_stock_field\Functional;
use Drupal\commerce_stock\StockTransactionsInterface;
class StockLevelFormatterTest extends StockLevelFieldTestBase {
public function setup() {
$this->fieldName = "Stock Level Test";
parent::setup();
}
public function testDefaultFormatter() {
$this
->drupalGet('product/' . $this->product
->id());
$this
->saveHtmlOutput();
$this
->assertSession()
->pageTextContains('stock_level_test');
$this
->assertSession()
->elementContains('css', '.product--variation-field--variation_stock_level_test__1', '10');
}
public function testDefaultFormatterDontCacheStockLevel() {
$this
->drupalGet('product/' . $this->product
->id());
$this
->saveHtmlOutput();
$this
->assertSession()
->pageTextContains('stock_level_test');
$this
->assertSession()
->elementContains('css', '.product--variation-field--variation_stock_level_test__1', '10');
$this->stockServiceManager
->createTransaction($this->variation, $this->locations[1]
->getId(), '', 10, 10.1, 'USD', StockTransactionsInterface::STOCK_IN, []);
$this
->drupalGet('product/' . $this->product
->id());
$this
->saveHtmlOutput();
$this
->assertSession()
->elementContains('css', '.product--variation-field--variation_stock_level_test__1', '20');
}
}