You are here

public function StockLevelTest::testBaseFieldisAddedtoPurchasableEntity in Commerce Stock 8

Test always in stock field is added to purchasable entities.

Test that a commerce_stock_always_in_stock base field is added to purchasable entities.

File

modules/field/tests/src/Kernel/StockLevelTest.php, line 151

Class

StockLevelTest
Ensure the stock level field works.

Namespace

Drupal\Tests\commerce_stock_field\Kernel

Code

public function testBaseFieldisAddedtoPurchasableEntity() {
  $variation = ProductVariation::create([
    'type' => 'default',
  ]);
  $variation
    ->save();

  // This would throw an Exception, if the field isn't there.
  $field = $variation
    ->get('commerce_stock_always_in_stock');

  // Check the default value is set to FALSE.
  self::assertFalse($field
    ->getValue()[0]['value']);
}