@@ -1532,6 +1532,54 @@ public function testCreateTag(): void
15321532 }
15331533 }
15341534
1535+ public function testListTags (): void
1536+ {
1537+ $ repositoryName = 'test-list-tags- ' . \uniqid ();
1538+ $ this ->vcsAdapter ->createRepository (static ::$ owner , $ repositoryName , false );
1539+
1540+ try {
1541+ $ this ->vcsAdapter ->createFile (static ::$ owner , $ repositoryName , 'README.md ' , '# Test ' );
1542+ $ commitHash = $ this ->vcsAdapter ->getLatestCommit (static ::$ owner , $ repositoryName , static ::$ defaultBranch )['commitHash ' ];
1543+
1544+ $ this ->vcsAdapter ->createTag (static ::$ owner , $ repositoryName , 'v1.0.0 ' , $ commitHash );
1545+ $ this ->vcsAdapter ->createTag (static ::$ owner , $ repositoryName , 'v1.1.0 ' , $ commitHash );
1546+ $ this ->vcsAdapter ->createTag (static ::$ owner , $ repositoryName , 'v2.0.0 ' , $ commitHash );
1547+
1548+ $ tags = [];
1549+ for ($ attempt = 0 ; $ attempt < 10 ; $ attempt ++) {
1550+ $ tags = $ this ->vcsAdapter ->listTags (static ::$ owner , $ repositoryName );
1551+ if (count ($ tags ) >= 3 ) {
1552+ break ;
1553+ }
1554+ usleep (500000 );
1555+ }
1556+
1557+ $ this ->assertEqualsCanonicalizing (['v1.0.0 ' , 'v1.1.0 ' , 'v2.0.0 ' ], $ tags );
1558+
1559+ // Glob filtering
1560+ $ this ->assertEqualsCanonicalizing (['v1.0.0 ' , 'v1.1.0 ' ], $ this ->vcsAdapter ->listTags (static ::$ owner , $ repositoryName , 'v1.* ' ));
1561+ $ this ->assertSame (['v2.0.0 ' ], $ this ->vcsAdapter ->listTags (static ::$ owner , $ repositoryName , 'v2.0.0 ' ));
1562+ $ this ->assertEmpty ($ this ->vcsAdapter ->listTags (static ::$ owner , $ repositoryName , 'nope-* ' ));
1563+ } finally {
1564+ $ this ->vcsAdapter ->deleteRepository (static ::$ owner , $ repositoryName );
1565+ }
1566+ }
1567+
1568+ public function testListTagsEmptyAndMissingRepo (): void
1569+ {
1570+ $ repositoryName = 'test-list-tags-empty- ' . \uniqid ();
1571+ $ this ->vcsAdapter ->createRepository (static ::$ owner , $ repositoryName , false );
1572+
1573+ try {
1574+ $ this ->vcsAdapter ->createFile (static ::$ owner , $ repositoryName , 'README.md ' , '# Test ' );
1575+ $ this ->assertSame ([], $ this ->vcsAdapter ->listTags (static ::$ owner , $ repositoryName ));
1576+ } finally {
1577+ $ this ->vcsAdapter ->deleteRepository (static ::$ owner , $ repositoryName );
1578+ }
1579+
1580+ $ this ->assertSame ([], $ this ->vcsAdapter ->listTags (static ::$ owner , 'non-existing-repo- ' . \uniqid ()));
1581+ }
1582+
15351583 public function testListRepositoryLanguages (): void
15361584 {
15371585 $ repositoryName = 'test-list-repository-languages- ' . \uniqid ();
0 commit comments