BulkConfigurationUnassignTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\BulkConfigurationUnassign;
  9. use Magento\InventoryLowQuantityNotificationApi\Api\GetSourceItemConfigurationInterface;
  10. use Magento\TestFramework\Helper\Bootstrap;
  11. use PHPUnit\Framework\TestCase;
  12. class BulkConfigurationUnassignTest extends TestCase
  13. {
  14. /**
  15. * @var BulkConfigurationUnassign
  16. */
  17. private $bulkConfigurationUnassign;
  18. /**
  19. * @var GetSourceItemConfigurationInterface
  20. */
  21. private $getSourceItemConfiguration;
  22. public function setUp()
  23. {
  24. parent::setUp();
  25. $this->bulkConfigurationUnassign = Bootstrap::getObjectManager()->get(BulkConfigurationUnassign::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 testUnassign()
  38. {
  39. $this->bulkConfigurationUnassign->execute(['SKU-1'], ['eu-1']);
  40. $sourceConfig = $this->getSourceItemConfiguration->execute('eu-1', 'SKU-1');
  41. self::assertEquals(
  42. 1.0, // Default value when configuration is not defined
  43. $sourceConfig->getNotifyStockQty(),
  44. 'Low stock notification not removed after unassign'
  45. );
  46. }
  47. }