66use Prokl \ServiceProvider \Bundles \BundlesLoader ;
77use Prokl \ServiceProvider \Tests \Fixtures \DummyService ;
88use Prokl \ServiceProvider \Tests \Fixtures \TestingBundle ;
9+ use Prokl \ServiceProvider \Tests \Fixtures \TestingBundleDev ;
910use Prokl \TestingTools \Base \BaseTestCase ;
1011use Prokl \TestingTools \Tools \PHPUnitUtils ;
1112use ReflectionException ;
1617 * @package Prokl\ServiceProvider\Tests\Cases
1718 *
1819 * @since 01.06.2021
20+ * @since 03.07.2021 Актуализация.
1921 */
2022class BundlesLoaderTest extends BaseTestCase
2123{
@@ -41,6 +43,7 @@ protected function setUp(): void
4143 $ this ->dummyContainer = new ContainerBuilder ();
4244 $ this ->obTestObject = new BundlesLoader (
4345 $ this ->dummyContainer ,
46+ 'dev ' ,
4447 '/../Fixtures/bundles.php '
4548 );
4649 }
@@ -59,6 +62,8 @@ public function testLoad() : void
5962 $ this ->assertCount (1 , $ result );
6063 $ this ->assertSame ('TestingBundle ' , array_key_first ($ result ));
6164 $ this ->assertInstanceOf (TestingBundle::class, $ result ['TestingBundle ' ]);
65+ // Не загрузился ли бандл для другого окружения.
66+ $ this ->assertArrayNotHasKey (TestingBundleDev::class, $ result );
6267 }
6368
6469 /**
@@ -70,6 +75,7 @@ public function testLoadDefaultPath() : void
7075 {
7176 $ this ->obTestObject = new BundlesLoader (
7277 $ this ->dummyContainer ,
78+ 'dev ' ,
7379 '/../Fixtures/fake.php ' // Несуществующий конфиг
7480 );
7581
@@ -80,6 +86,28 @@ public function testLoadDefaultPath() : void
8086 $ this ->assertEmpty ($ result );
8187 }
8288
89+ /**
90+ * load(). Другое окружение.
91+ *
92+ * @return void
93+ */
94+ public function testLoadAnotherEnv () : void
95+ {
96+ $ this ->obTestObject = new BundlesLoader (
97+ $ this ->dummyContainer ,
98+ 'test ' ,
99+ '/../Fixtures/bundles.php '
100+ );
101+
102+ $ this ->obTestObject ->load ();
103+
104+ $ result = $ this ->obTestObject ->bundles ();
105+
106+ $ this ->assertArrayHasKey ('TestingBundle ' , $ result );
107+ $ this ->assertArrayHasKey ('TestingBundleDev ' , $ result );
108+ $ this ->assertInstanceOf (TestingBundleDev::class, $ result ['TestingBundleDev ' ]);
109+ }
110+
83111 /**
84112 * load(). Бандл без метода RegisterExtension.
85113 *
@@ -89,11 +117,14 @@ public function testLoadWithoutRegisterExtension() : void
89117 {
90118 $ this ->obTestObject = new BundlesLoader (
91119 $ this ->dummyContainer ,
120+ 'dev ' ,
92121 '/../Fixtures/invalid_bundles.php '
93122 );
94123
95124 $ this ->expectException (InvalidArgumentException::class);
96- $ this ->expectExceptionMessage ('Bundle TestingInvalidBundle dont have implemented getContainerExtension method. ' );
125+ $ this ->expectExceptionMessage (
126+ 'Bundle Prokl\ServiceProvider\Tests\Fixtures\TestingInvalidBundle dont have implemented getContainerExtension method. '
127+ );
97128
98129 $ this ->obTestObject ->load ();
99130 }
@@ -107,6 +138,7 @@ public function testLoadInvalidClass() : void
107138 {
108139 $ this ->obTestObject = new BundlesLoader (
109140 $ this ->dummyContainer ,
141+ 'dev ' ,
110142 '/../Fixtures/fake_bundles.php '
111143 );
112144
0 commit comments