You are here

public function StockLevelFormatterTest::testDefaultFormatterDontCacheStockLevel in Commerce Stock 8

Whether the stock level dosn't get cached.

Throws

\Behat\Mink\Exception\ElementHtmlException

\Behat\Mink\Exception\ResponseTextException

File

modules/field/tests/src/Functional/StockLevelFormatterTest.php, line 42

Class

StockLevelFormatterTest
Provides tests for stock level field default formatter.

Namespace

Drupal\Tests\commerce_stock_field\Functional

Code

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');
}