@@ -75,4 +75,58 @@ public function testFetchTagsFilteredWithMany()
75
75
$ this ->assertCount (1 , $ tags );
76
76
$ this ->assertCount (1 , $ tags ['custom_tag_name ' ]);
77
77
}
78
+
79
+ public function testFetchTagsDefinitionHasNoTags ()
80
+ {
81
+ $ container = new ContainerBuilder ();
82
+ $ container ->register ('dummy_service ' , 'Egulias\Tests\ServiceDummy ' );
83
+
84
+ $ fetcher = new TagFetcher ($ container );
85
+
86
+ $ filters = new FilterList ();
87
+ $ filters ->append (new Name ('custom_tag_name ' ));
88
+ $ tags = $ fetcher ->fetch ($ filters );
89
+
90
+ $ this ->assertCount (0 , $ tags );
91
+ }
92
+
93
+ public function testFetchTagsFromPublicDefinitionsOnly ()
94
+ {
95
+ $ container = new ContainerBuilder ();
96
+ $ definition1 = $ container ->register ('dummy_service ' , 'Egulias\Tests\ServiceDummy ' );
97
+ $ definition1
98
+ ->addTag ('custom_tag_name ' , array ('method ' => 'name ' , 'number ' => 8 , 'another ' => 'attribute ' ))
99
+ ->setPublic (true );
100
+ $ definition2 = $ container ->register ('another_dummy_service ' , 'Egulias\Tests\Service2Dummy ' );
101
+ $ definition2
102
+ ->addTag ('custom_tag_name ' , array ('method ' => 'name ' , 'number ' => 10 , 'another ' => 'attribute ' ))
103
+ ->setPublic (false );
104
+
105
+ $ fetcher = new TagFetcher ($ container );
106
+
107
+ $ filters = new FilterList ();
108
+ $ filters ->append (new Name ('custom_tag_name ' ));
109
+ $ tags = $ fetcher ->fetch ($ filters );
110
+
111
+ $ this ->assertCount (1 , $ tags );
112
+ $ this ->assertCount (1 , $ tags ['custom_tag_name ' ]);
113
+ }
114
+
115
+ public function testFetchTagsDefinitionIsAlias ()
116
+ {
117
+ $ container = new ContainerBuilder ();
118
+ $ definition1 = $ container ->register ('dummy_service ' , 'Egulias\Tests\ServiceDummy ' );
119
+ $ definition1
120
+ ->addTag ('custom_tag_name ' , array ('method ' => 'name ' , 'number ' => 8 , 'another ' => 'attribute ' ))
121
+ ->setPublic (true );
122
+ $ container ->setAlias ('alias_service ' , 'dummy_service ' );
123
+ $ fetcher = new TagFetcher ($ container );
124
+
125
+ $ filters = new FilterList ();
126
+ $ filters ->append (new Name ('custom_tag_name ' ));
127
+ $ tags = $ fetcher ->fetch ($ filters );
128
+
129
+ $ this ->assertCount (1 , $ tags );
130
+ $ this ->assertCount (1 , $ tags ['custom_tag_name ' ]);
131
+ }
78
132
}
0 commit comments