Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ComponentRegistrarFixtureTest.php
Go to the documentation of this file.
1 <?php
8 
11 
12 class ComponentRegistrarFixtureTest extends \PHPUnit\Framework\TestCase
13 {
17  private $componentRegistrar;
18 
19  const LIBRARY_NAME = 'magento/library';
20  const MODULE_NAME = 'Magento_ModuleOne';
21  const THEME_NAME = 'frontend/Magento/theme';
22  const LANGUAGE_NAME = 'magento_language';
23 
24  protected function setUp()
25  {
26  $this->componentRegistrar = new ComponentRegistrar();
27  }
28 
32  public function testStartEndTest()
33  {
34  $this->assertFixturesNotRegistered();
35  $object = new ComponentRegistrarFixture(__DIR__ . '/_files');
36  $object->startTest($this);
37  $this->assertFixturesRegistered();
38  $object->endTest($this);
39  $this->assertFixturesNotRegistered();
40  }
41 
42  private function assertFixturesNotRegistered()
43  {
44  $this->assertEmpty($this->componentRegistrar->getPath(ComponentRegistrar::LIBRARY, self::LIBRARY_NAME));
45  $this->assertEmpty($this->componentRegistrar->getPath(ComponentRegistrar::MODULE, self::MODULE_NAME));
46  $this->assertEmpty($this->componentRegistrar->getPath(ComponentRegistrar::THEME, self::THEME_NAME));
47  $this->assertEmpty($this->componentRegistrar->getPath(ComponentRegistrar::LANGUAGE, self::LANGUAGE_NAME));
48  }
49 
50  private function assertFixturesRegistered()
51  {
52  $this->assertSame(
53  __DIR__ . '/_files/components/b',
54  $this->componentRegistrar->getPath(ComponentRegistrar::LIBRARY, self::LIBRARY_NAME)
55  );
56  $this->assertSame(
57  __DIR__ . '/_files/components',
58  $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, self::MODULE_NAME)
59  );
60  $this->assertSame(
61  __DIR__ . '/_files/components/a/aa/aaa',
62  $this->componentRegistrar->getPath(ComponentRegistrar::THEME, self::THEME_NAME)
63  );
64  $this->assertSame(
65  __DIR__ . '/_files/components/a/aa',
66  $this->componentRegistrar->getPath(ComponentRegistrar::LANGUAGE, self::LANGUAGE_NAME)
67  );
68  }
69 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60