@@ -252,18 +252,87 @@ public function testRecognizesLooseValues(): void
252252 $ this ->assertFalse ($ config ->QFALSE );
253253 }
254254
255- public function testRegistrars (): void
255+ public function testRegistrarsWithDisabledRegistrarHasData (): void
256256 {
257+ $ modules = new Modules ();
258+
259+ $ modules ->registrarHasData = false ;
260+ BaseConfig::setModules ($ modules );
261+
257262 $ config = new RegistrarConfig ();
258263 $ config ::$ registrars = [TestRegistrar::class];
264+
259265 $ this ->setPrivateProperty ($ config , 'didDiscovery ' , true );
260266 $ method = $ this ->getPrivateMethodInvoker ($ config , 'registerProperties ' );
261267 $ method ();
262268
269+ $ cars = [
270+ 'Sedans ' => [
271+ 'Toyota ' => [
272+ 'year ' => 2018 ,
273+ 'color ' => 'silver ' ,
274+ ],
275+ ],
276+ 'Trucks ' => [
277+ 'Volvo ' => [
278+ 'year ' => 2019 ,
279+ 'color ' => 'dark blue ' ,
280+ ],
281+ ],
282+ 'Sedans Lux ' => [
283+ 'Toyota ' => [
284+ 'year ' => 2025 ,
285+ 'color ' => 'silver ' ,
286+ ],
287+ ],
288+ ];
289+
263290 // no change to unmodified property
264291 $ this ->assertSame ('bar ' , $ config ->foo );
265292 // add to an existing array property
266293 $ this ->assertSame (['baz ' , 'first ' , 'second ' ], $ config ->bar );
294+ // replace some of the keys with another value
295+ $ this ->assertSame ($ cars , $ config ->cars );
296+ }
297+
298+ public function testRegistrarsWithEnabledRegistrarHasData (): void
299+ {
300+ $ modules = new Modules ();
301+
302+ $ modules ->registrarHasData = true ;
303+ BaseConfig::setModules ($ modules );
304+
305+ $ config = new RegistrarConfig ();
306+ $ config ::$ registrars = [TestRegistrar::class];
307+
308+ $ this ->setPrivateProperty ($ config , 'didDiscovery ' , true );
309+ $ method = $ this ->getPrivateMethodInvoker ($ config , 'registerProperties ' );
310+ $ method ();
311+
312+ $ cars = [
313+ 'Sedans ' => [
314+ 'Toyota ' => [
315+ 'year ' => 2018 ,
316+ 'color ' => 'silver ' ,
317+ ],
318+ ],
319+ 'Trucks ' => [
320+ 'Volvo ' => [
321+ 'year ' => 2019 ,
322+ 'color ' => 'dark blue ' ,
323+ ],
324+ ],
325+ 'Sedans Lux ' => [
326+ 'Toyota ' => [
327+ 'year ' => 2025 ,
328+ 'color ' => 'silver ' ,
329+ ],
330+ ],
331+ ];
332+
333+ $ this ->assertSame ('bar ' , $ config ->foo );
334+ $ this ->assertSame (['first ' , 'second ' ], $ config ->bar );
335+ $ this ->assertSame ($ cars , $ config ->cars );
267336 }
268337
269338 public function testBadRegistrar (): void
0 commit comments