public function LocalStockServiceTest::testLocalStockService in Commerce Stock 8
Test the local stock service.
@covers ::create @covers ::getStockChecker @covers ::getStockUpdater @covers ::getConfiguration @covers ::getName @covers ::getId
File
- modules/
local_storage/ tests/ src/ Kernel/ LocalStockServiceTest.php, line 47
Class
- LocalStockServiceTest
- Tests the local stock service.
Namespace
Drupal\Tests\commerce_stock_local\KernelCode
public function testLocalStockService() {
// Check if we get back, what we passed to the stock service.
$prophecy = $this
->prophesize(StockCheckInterface::class);
$stockChecker = $prophecy
->reveal();
$stockUpdater = $this
->prophesize(StockUpdateInterface::class)
->reveal();
$prophecy = $this
->prophesize(StockServiceConfigInterface::class);
$prophecy
->getAvailabilityLocations(Argument::any())
->willReturn([
1 => 'main',
]);
$stockServiceConfig = $prophecy
->reveal();
$localStockService = new LocalStockService($stockChecker, $stockUpdater, $stockServiceConfig);
self::assertEquals($stockChecker, $localStockService
->getStockChecker());
self::assertEquals($stockUpdater, $localStockService
->getStockUpdater());
self::assertEquals($stockServiceConfig, $localStockService
->getConfiguration());
self::assertEquals('local_stock', $localStockService
->getId());
self::assertEquals('Local stock', $localStockService
->getName());
// Test that instantiation through container works.
$localStockService = LocalStockService::create($this->container);
self::assertInstanceOf(LocalStockService::class, $localStockService);
$stockChecker = $localStockService
->getStockChecker();
self::assertInstanceOf(StockCheckInterface::class, $stockChecker);
$stockUpdater = $localStockService
->getStockUpdater();
self::assertInstanceOf(StockUpdateInterface::class, $stockUpdater);
$stockConfig = $localStockService
->getConfiguration();
self::assertInstanceOf(StockServiceConfigInterface::class, $stockConfig);
}