@@ -21,12 +21,12 @@ public function testDependenciesModules(): void
21
21
include __DIR__ . '/../_files/application.config.with.dependencies.php '
22
22
);
23
23
$ sm = $ this ->getApplicationServiceLocator ();
24
- $ this ->assertEquals ( true , $ sm ->has ('FooObject ' ));
25
- $ this ->assertEquals ( true , $ sm ->has ('BarObject ' ));
24
+ $ this ->assertTrue ( $ sm ->has ('FooObject ' ));
25
+ $ this ->assertTrue ( $ sm ->has ('BarObject ' ));
26
26
27
27
$ this ->assertModulesLoaded (['Foo ' , 'Bar ' ]);
28
28
$ this ->expectedException (ExpectationFailedException::class);
29
- $ this ->assertModulesLoaded (['Foo ' , 'Bar ' , 'Unknow ' ]);
29
+ $ this ->assertModulesLoaded (['Foo ' , 'Bar ' , 'Unknown ' ]);
30
30
}
31
31
32
32
public function testBadDependenciesModules (): void
@@ -35,11 +35,29 @@ public function testBadDependenciesModules(): void
35
35
include __DIR__ . '/../_files/application.config.with.dependencies.disabled.php '
36
36
);
37
37
$ sm = $ this ->getApplicationServiceLocator ();
38
- $ this ->assertEquals ( false , $ sm ->has ('FooObject ' ));
39
- $ this ->assertEquals ( true , $ sm ->has ('BarObject ' ));
38
+ $ this ->assertFalse ( $ sm ->has ('FooObject ' ));
39
+ $ this ->assertTrue ( $ sm ->has ('BarObject ' ));
40
40
41
41
$ this ->assertNotModulesLoaded (['Foo ' ]);
42
42
$ this ->expectedException (ExpectationFailedException::class);
43
43
$ this ->assertNotModulesLoaded (['Foo ' , 'Bar ' ]);
44
44
}
45
+
46
+ /**
47
+ * Test that 'assertModulesLoaded()' can detect modules that are loaded in a module's init() method
48
+ */
49
+ public function testLoadedModulesUsingModuleInit (): void
50
+ {
51
+ $ this ->setApplicationConfig (
52
+ include __DIR__ . '/../_files/application.config.with.modules.init.php '
53
+ );
54
+ $ sm = $ this ->getApplicationServiceLocator ();
55
+
56
+ // Check that modules loaded and created the below services
57
+ $ this ->assertTrue ($ sm ->has ('FooObject ' ));
58
+ $ this ->assertTrue ($ sm ->has ('QuxObject ' ));
59
+
60
+ // Assert for the module loaded via Module init() method
61
+ $ this ->assertModulesLoaded (['Foo ' ]);
62
+ }
45
63
}
0 commit comments