IsSingleSourceModeTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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\InventoryCatalog\Test\Integration;
  8. use Magento\InventoryApi\Api\SourceRepositoryInterface;
  9. use Magento\InventoryCatalogApi\Model\IsSingleSourceModeInterface;
  10. use Magento\TestFramework\Helper\Bootstrap;
  11. use PHPUnit\Framework\TestCase;
  12. class IsSingleSourceModeTest extends TestCase
  13. {
  14. /**
  15. * @var IsSingleSourceModeInterface
  16. */
  17. private $isSingleSourceMode;
  18. /**
  19. * @var SourceRepositoryInterface
  20. */
  21. private $sourceRepository;
  22. /**
  23. * @inheritdoc
  24. */
  25. protected function setUp()
  26. {
  27. $this->isSingleSourceMode = Bootstrap::getObjectManager()->get(IsSingleSourceModeInterface::class);
  28. $this->sourceRepository = Bootstrap::getObjectManager()->get(SourceRepositoryInterface::class);
  29. }
  30. public function testExecuteOnCleanInstall()
  31. {
  32. self::assertTrue($this->isSingleSourceMode->execute());
  33. }
  34. /**
  35. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source.php
  36. */
  37. public function testExecuteWithTwoSourcesOneDisabled()
  38. {
  39. $sourceToDisable = $this->sourceRepository->get('source-code-1');
  40. $sourceToDisable->setEnabled(false);
  41. $this->sourceRepository->save($sourceToDisable);
  42. self::assertTrue($this->isSingleSourceMode->execute());
  43. }
  44. /**
  45. * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php
  46. */
  47. public function testExecuteWithEnabledSources()
  48. {
  49. self::assertFalse($this->isSingleSourceMode->execute());
  50. }
  51. }