@@ -19,13 +19,13 @@ final class InvalidTemplateArgumentTest extends DefinitionExceptionTestCase
1919 public function testInvalidArgumentGiven (): void
2020 {
2121 $ this ->expectException (InvalidTemplateArgumentException::class);
22- $ this ->expectExceptionMessage ('Passed template argument #1 of type int<T> must be of type string, but T given ' );
22+ $ this ->expectExceptionMessage ('Passed template argument #2 of type int<T, U > must be of type string, but U given ' );
2323
24- $ type = self ::parse ('int<T> ' );
24+ $ type = self ::parse ('int<T, U > ' );
2525
2626 assert ($ type instanceof NamedTypeNode);
2727
28- $ argument = $ type ->arguments ?->first ();
28+ $ argument = $ type ->arguments ?->last ();
2929 assert ($ argument instanceof TemplateArgumentNode);
3030
3131 throw InvalidTemplateArgumentException::becauseTemplateArgumentMustBe (
@@ -34,4 +34,23 @@ public function testInvalidArgumentGiven(): void
3434 type: $ type ,
3535 );
3636 }
37+
38+ #[TestDox('[undefined behaviour] all works if pass an non-node \'s argument ' )]
39+ public function testOfNonOwnArgument (): void
40+ {
41+ $ this ->expectException (InvalidTemplateArgumentException::class);
42+ $ this ->expectExceptionMessage ('Passed template argument #0 of type another-type must be of type string, but T given ' );
43+
44+ $ type = self ::parse ('int<T> ' );
45+ assert ($ type instanceof NamedTypeNode);
46+
47+ $ argument = $ type ->arguments ?->first();
48+ assert ($ argument instanceof TemplateArgumentNode);
49+
50+ throw InvalidTemplateArgumentException::becauseTemplateArgumentMustBe (
51+ argument: $ argument ,
52+ expected: new NamedTypeNode ('string ' ),
53+ type: self ::parse ('another-type ' ),
54+ );
55+ }
3756}
0 commit comments