Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FullModuleListTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\Module\FullModuleList;
9 
10 class FullModuleListTest extends \PHPUnit\Framework\TestCase
11 {
15  private $moduleList;
16 
17  protected function setUp()
18  {
19  $loaderMock = $this->createMock(\Magento\Framework\Module\ModuleList\Loader::class);
20  $modules = [
21  'Vendor_A' => ['data' => 'a'],
22  'Vendor_B' => ['data' => 'b'],
23  'Vendor_C' => ['data' => 'c'],
24  ];
25  $loaderMock->expects($this->once())->method('load')->will($this->returnValue($modules));
26  $this->moduleList = new FullModuleList($loaderMock);
27  }
28 
29  public function testGetAll()
30  {
31  $expect = [
32  'Vendor_A' => ['data' => 'a'],
33  'Vendor_B' => ['data' => 'b'],
34  'Vendor_C' => ['data' => 'c'],
35  ];
36  $this->assertEquals($expect, $this->moduleList->getAll());
37  // call once more to make sure it's cached
38  $this->moduleList->getAll();
39  }
40 
41  public function testGetOne()
42  {
43  $expect = ['data' => 'b'];
44  $this->assertEquals($expect, $this->moduleList->getOne('Vendor_B'));
45  }
46 
47  public function testGetNames()
48  {
49  $expect = ['Vendor_A', 'Vendor_B', 'Vendor_C'];
50  $this->assertEquals($expect, $this->moduleList->getNames());
51  }
52 
53  public function testHasTrue()
54  {
55  $this->assertTrue($this->moduleList->has('Vendor_A'));
56  }
57 
58  public function testHasFalse()
59  {
60  $this->assertFalse($this->moduleList->has('No_Such_Module'));
61  }
62 }