@@ -900,19 +900,18 @@ public function testCoverageDepthFirstTaggingOnRecursiveAliasDefinitions()
900
900
* @param string $name
901
901
* @param array[] string $test
902
902
*/
903
- public function testConsistencyOverInternalStates ($ smTemplate , $ name , $ test )
903
+ public function testConsistencyOverInternalStates ($ smTemplate , $ name , $ test, $ sharedByDefault )
904
904
{
905
905
$ sm = clone $ smTemplate ;
906
906
$ object ['get ' ] = [];
907
907
$ object ['build ' ] = [];
908
908
909
-
910
909
// call get()/build() and store the retrieved
911
910
// objects in $object['get'] or $object['build']
912
911
// respectively
913
912
foreach ($ test as $ method ) {
914
913
$ obj = $ sm ->$ method ($ name );
915
- $ object [$ method ][] = $ obj ;
914
+ $ object [$ sharedByDefault ? $ method : ' build ' ][] = $ obj ;
916
915
$ this ->assertNotNull ($ obj );
917
916
$ this ->assertTrue ($ sm ->has ($ name ));
918
917
}
@@ -944,7 +943,7 @@ public function testConsistencyOverInternalStates($smTemplate, $name, $test)
944
943
*/
945
944
public function provideConsistencyOverInternalStatesTests ()
946
945
{
947
- $ config = [
946
+ $ config1 = [
948
947
'factories ' => [
949
948
// to allow build('service')
950
949
'service ' => function ($ container , $ requestedName , array $ options = null ) {
@@ -953,30 +952,36 @@ public function provideConsistencyOverInternalStatesTests()
953
952
'factory ' => SampleFactory::class,
954
953
'delegator ' => SampleFactory::class,
955
954
],
956
- 'delegators ' => [
957
- 'delegator ' => [
958
- PassthroughDelegatorFactory::class
959
- ],
960
- ],
955
+ 'delegators ' => [
956
+ 'delegator ' => [
957
+ PassthroughDelegatorFactory::class
958
+ ],
959
+ ],
961
960
'invokables ' => [
962
961
'invokable ' => InvokableObject::class,
963
962
],
964
963
'services ' => [
965
964
'service ' => new stdClass (),
966
965
],
967
- 'aliases ' => [
966
+ 'aliases ' => [
968
967
'serviceAlias ' => 'service ' ,
969
968
'invokableAlias ' => 'invokable ' ,
970
969
'factoryAlias ' => 'factory ' ,
971
970
'abstractFactoryAlias ' => 'foo ' ,
972
971
'delegatorAlias ' => 'delegator ' ,
973
- ],
972
+ ],
974
973
'abstract_factories ' => [
975
974
AbstractFactoryFoo::class
976
975
]
977
976
];
977
+ $ config2 = $ config1 ;
978
+ $ config2 ['shared_by_default ' ] = false ;
978
979
979
- $ smTemplate = $ this ->createContainer ($ config );
980
+ $ configs = [ $ config1 , $ config2 ];
981
+
982
+ foreach ($ configs as $ config ) {
983
+ $ smTemplates [] = $ this ->createContainer ($ config );
984
+ }
980
985
981
986
// produce all 3-tuples of 'build' and 'get'
982
987
$ methods = ['get ' , 'build ' ];
@@ -996,13 +1001,16 @@ public function provideConsistencyOverInternalStatesTests()
996
1001
$ config ['services ' ],
997
1002
$ config ['aliases ' ],
998
1003
$ config ['delegators ' ]
999
- ));
1004
+ ));
1000
1005
$ names [] = 'foo ' ;
1001
1006
1002
- foreach ($ names as $ name ) {
1003
- foreach ($ callSequences as $ callSequence ) {
1004
- $ sm = clone $ smTemplate ;
1005
- $ tests [] = [$ smTemplate , $ name , $ callSequence ];
1007
+ foreach ($ configs as $ config ) {
1008
+ $ smTemplate = $ this ->createContainer ($ config );
1009
+ foreach ($ names as $ name ) {
1010
+ foreach ($ callSequences as $ callSequence ) {
1011
+ $ sm = clone $ smTemplate ;
1012
+ $ tests [] = [$ smTemplate , $ name , $ callSequence , $ config ['shared_by_default ' ] ?? true ];
1013
+ }
1006
1014
}
1007
1015
}
1008
1016
return $ tests ;
0 commit comments