ManageConfigConditionTest.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\InventorySales\Test\Integration\GetStockItemData;
  8. use Magento\InventorySalesApi\Model\GetStockItemDataInterface;
  9. use Magento\TestFramework\Helper\Bootstrap;
  10. use PHPUnit\Framework\TestCase;
  11. class ManageConfigConditionTest extends TestCase
  12. {
  13. /**
  14. * @var GetStockItemDataInterface
  15. */
  16. private $getStockItemData;
  17. /**
  18. * @inheritdoc
  19. */
  20. protected function setUp()
  21. {
  22. parent::setUp();
  23. $this->getStockItemData = Bootstrap::getObjectManager()->get(GetStockItemDataInterface::class);
  24. }
  25. /**
  26. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php
  27. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php
  28. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php
  29. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php
  30. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
  31. * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
  32. * @magentoConfigFixture default_store cataloginventory/item_options/manage_stock 0
  33. *
  34. * @param string $sku
  35. * @param int $stockId
  36. * @param $expectedData
  37. * @return void
  38. *
  39. * @dataProvider executeWithManageStockFalseDataProvider
  40. *
  41. * @magentoDbIsolation disabled
  42. */
  43. public function testExecuteWithManageStockFalse(string $sku, int $stockId, $expectedData)
  44. {
  45. $stockItemData = $this->getStockItemData->execute($sku, $stockId);
  46. self::assertEquals($expectedData, $stockItemData);
  47. }
  48. /**
  49. * @return array
  50. */
  51. public function executeWithManageStockFalseDataProvider(): array
  52. {
  53. return [
  54. ['SKU-1', 10, [GetStockItemDataInterface::QUANTITY => 8.5, GetStockItemDataInterface::IS_SALABLE => 1]],
  55. ['SKU-1', 20, null],
  56. ['SKU-1', 30, [GetStockItemDataInterface::QUANTITY => 8.5, GetStockItemDataInterface::IS_SALABLE => 1]],
  57. ['SKU-2', 10, null],
  58. ['SKU-2', 20, [GetStockItemDataInterface::QUANTITY => 5, GetStockItemDataInterface::IS_SALABLE => 1]],
  59. ['SKU-2', 30, [GetStockItemDataInterface::QUANTITY => 5, GetStockItemDataInterface::IS_SALABLE => 1]],
  60. ['SKU-3', 10, [GetStockItemDataInterface::QUANTITY => 0, GetStockItemDataInterface::IS_SALABLE => 1]],
  61. ['SKU-3', 20, null],
  62. ['SKU-3', 30, [GetStockItemDataInterface::QUANTITY => 0, GetStockItemDataInterface::IS_SALABLE => 1]],
  63. ];
  64. }
  65. }