ModuleServiceTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\Backend\Test\Unit\Service\V1;
  8. use Magento\Backend\Service\V1\ModuleService;
  9. use Magento\Framework\Module\ModuleListInterface;
  10. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  11. /**
  12. * Module List Service Test
  13. *
  14. * Covers \Magento\Sales\Model\ValidatorResultMerger
  15. */
  16. class ModuleServiceTest extends \PHPUnit\Framework\TestCase
  17. {
  18. /**
  19. * Testable Object
  20. *
  21. * @var ModuleService
  22. */
  23. private $moduleService;
  24. /**
  25. * @var ModuleListInterface|\PHPUnit_Framework_MockObject_MockObject
  26. */
  27. private $moduleListMock;
  28. /**
  29. * Object Manager
  30. *
  31. * @var ObjectManager
  32. */
  33. private $objectManager;
  34. /**
  35. * Set Up
  36. *
  37. * @return void
  38. */
  39. protected function setUp()
  40. {
  41. $this->moduleListMock = $this->createMock(ModuleListInterface::class);
  42. $this->objectManager = new ObjectManager($this);
  43. $this->moduleService = $this->objectManager->getObject(
  44. ModuleService::class,
  45. [
  46. 'moduleList' => $this->moduleListMock,
  47. ]
  48. );
  49. }
  50. /**
  51. * Test getModules method
  52. *
  53. * @return void
  54. */
  55. public function testGetModules()
  56. {
  57. $moduleNames = ['Magento_Backend', 'Magento_Catalog', 'Magento_Customer'];
  58. $this->moduleListMock->expects($this->once())->method('getNames')->willReturn($moduleNames);
  59. $expected = $moduleNames;
  60. $actual = $this->moduleService->getModules();
  61. $this->assertEquals($expected, $actual);
  62. }
  63. }