@@ -76,4 +76,68 @@ public function testMultipleAttributesNoneMatch(): void
7676
7777 self ::assertFalse ($ filter ->accept ($ meta ));
7878 }
79+
80+ /**
81+ * Covers L41: when the attribute name has NO backslash, shortName is null
82+ * and only exact matching is done (no short-name fallback).
83+ */
84+ public function testAcceptsClassWithShortNameAttributeNoNamespace (): void
85+ {
86+ // Attribute stored/searched as plain name (no backslash)
87+ $ attr = self ::createAttributeMetadata (name: 'Route ' );
88+ $ meta = self ::createClassMetadata (attributes: ['Route ' => $ attr ]);
89+
90+ // Filter with plain name — shortName branch is null (L41 covered)
91+ $ filter = new AttributeFilter ('Route ' );
92+
93+ self ::assertTrue ($ filter ->accept ($ meta ));
94+ }
95+
96+ public function testRejectsWhenShortNameNoNamespaceDoesNotMatch (): void
97+ {
98+ $ attr = self ::createAttributeMetadata (name: 'Route ' );
99+ $ meta = self ::createClassMetadata (attributes: ['Route ' => $ attr ]);
100+
101+ // Searching for 'Command' plain name — no match
102+ $ filter = new AttributeFilter ('Command ' );
103+
104+ self ::assertFalse ($ filter ->accept ($ meta ));
105+ }
106+
107+ public function testAcceptsViaShortNameFallbackOnMethod (): void
108+ {
109+ // Filter with FQCN, attribute stored with short name on method
110+ $ attr = new AttributeMetadata (name: 'Route ' , target: AttributeTarget::Method);
111+ $ method = new MethodMetadata (name: 'index ' , attributes: ['Route ' => $ attr ]);
112+ $ meta = self ::createClassMetadata (methods: ['index ' => $ method ]);
113+
114+ // FQCN filter — shortName = 'Route' — matches method attribute stored as 'Route'
115+ $ filter = new AttributeFilter ('App \\Route ' );
116+
117+ self ::assertTrue ($ filter ->accept ($ meta ));
118+ }
119+
120+ public function testAcceptsViaShortNameFallbackOnProperty (): void
121+ {
122+ // Filter with FQCN, attribute stored with short name on property
123+ $ attr = new AttributeMetadata (name: 'Column ' , target: AttributeTarget::Property);
124+ $ prop = new PropertyMetadata (name: 'id ' , attributes: ['Column ' => $ attr ]);
125+ $ meta = self ::createClassMetadata (properties: ['id ' => $ prop ]);
126+
127+ // FQCN filter — shortName = 'Column' — matches property attribute stored as 'Column'
128+ $ filter = new AttributeFilter ('Doctrine \\Column ' );
129+
130+ self ::assertTrue ($ filter ->accept ($ meta ));
131+ }
132+
133+ public function testRejectsWhenNoAttributeClassesGiven (): void
134+ {
135+ $ attr = self ::createAttributeMetadata (name: 'Route ' );
136+ $ meta = self ::createClassMetadata (attributes: ['Route ' => $ attr ]);
137+
138+ // Empty filter — foreach never executes → returns false
139+ $ filter = new AttributeFilter ();
140+
141+ self ::assertFalse ($ filter ->accept ($ meta ));
142+ }
79143}
0 commit comments