BulkConfigurationAssignTest.php 2.8 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\InventoryLowQuantityNotification\Test\Integration\Model\ResourceModel;
  8. use Magento\InventoryLowQuantityNotification\Model\ResourceModel\BulkConfigurationAssign;
  9. use Magento\InventoryLowQuantityNotificationApi\Api\GetSourceItemConfigurationInterface;
  10. use Magento\TestFramework\Helper\Bootstrap;
  11. use PHPUnit\Framework\TestCase;
  12. class BulkConfigurationAssignTest extends TestCase
  13. {
  14. /**
  15. * @var BulkConfigurationAssign
  16. */
  17. private $bulkConfigurationAssign;
  18. /**
  19. * @var GetSourceItemConfigurationInterface
  20. */
  21. private $getSourceItemConfiguration;
  22. public function setUp()
  23. {
  24. parent::setUp();
  25. $this->bulkConfigurationAssign = Bootstrap::getObjectManager()->get(BulkConfigurationAssign::class);
  26. $this->getSourceItemConfiguration =
  27. Bootstrap::getObjectManager()->create(GetSourceItemConfigurationInterface::class);
  28. }
  29. /**
  30. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php
  31. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php
  32. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php
  33. * @magentoDataFixture ../../../../app/code/Magento/InventoryLowQuantityNotificationApi/Test/_files/source_item_configuration.php
  34. * @magentoDbIsolation enabled
  35. * @throws \Magento\Framework\Exception\LocalizedException
  36. */
  37. public function testAssign()
  38. {
  39. $this->bulkConfigurationAssign->execute(['SKU-1'], ['us-1']);
  40. $sourceConfig = $this->getSourceItemConfiguration->execute('us-1', 'SKU-1');
  41. self::assertNull(
  42. $sourceConfig->getNotifyStockQty(),
  43. 'Low stock notification configuration was not defaulted during assign'
  44. );
  45. }
  46. /**
  47. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php
  48. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php
  49. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php
  50. * @magentoDataFixture ../../../../app/code/Magento/InventoryLowQuantityNotificationApi/Test/_files/source_item_configuration.php
  51. * @magentoDbIsolation enabled
  52. * @throws \Magento\Framework\Exception\LocalizedException
  53. */
  54. public function testAssignOnExisting()
  55. {
  56. $this->bulkConfigurationAssign->execute(['SKU-1'], ['eu-1']);
  57. $sourceConfig = $this->getSourceItemConfiguration->execute('eu-1', 'SKU-1');
  58. self::assertEquals(
  59. 5.6,
  60. $sourceConfig->getNotifyStockQty(),
  61. 'Low stock notification configuration was changed assigning on existing source'
  62. );
  63. }
  64. }