@@ -79,6 +79,81 @@ public function testGetReleasesThrowsExceptionOnMissingCustom()
7979 $ object ->getReleases ();
8080 }
8181
82+ public function testGetLatestVersionForBranchReturnsNullForMissingBranch ()
83+ {
84+ App::bind (StorageInterface::class, fn () => $ this ->getStorageMock ([
85+ "Joomla_5.2.1-Stable-Upgrade_Package.zip " => [
86+ "custom " => [
87+ "description " => "Joomla! 5.2.1 Release " ,
88+ "version " => "5.2.1 " ,
89+ "stability " => "stable " ,
90+ ]
91+ ]
92+ ]));
93+
94+ $ object = new TufFetcher ();
95+ $ result = $ object ->getLatestVersionForBranch (6 );
96+
97+ $ this ->assertNull ($ result );
98+ }
99+
100+ public function testGetLatestVersionForBranchChecksBranch ()
101+ {
102+ App::bind (StorageInterface::class, fn () => $ this ->getStorageMock ([
103+ "Joomla_5.2.1-Stable-Upgrade_Package.zip " => [
104+ "custom " => [
105+ "description " => "Joomla! 5.2.1 Release " ,
106+ "version " => "5.2.1 " ,
107+ "stability " => "stable " ,
108+ ]
109+ ],
110+ "Joomla_4.2.1-Stable-Upgrade_Package.zip " => [
111+ "custom " => [
112+ "description " => "Joomla! 4.2.1 Release " ,
113+ "version " => "4.1.2 " ,
114+ "stability " => "stable " ,
115+ ]
116+ ]
117+ ]));
118+
119+ $ object = new TufFetcher ();
120+ $ result = $ object ->getLatestVersionForBranch (4 );
121+
122+ $ this ->assertEquals ("4.1.2 " , $ result );
123+ }
124+
125+ public function testGetLatestVersionForBranchChecksOrdering ()
126+ {
127+ App::bind (StorageInterface::class, fn () => $ this ->getStorageMock ([
128+ "Joomla_5.2.3-Stable-Upgrade_Package.zip " => [
129+ "custom " => [
130+ "description " => "Joomla! 5.2.3 Release " ,
131+ "version " => "5.2.3 " ,
132+ "stability " => "stable " ,
133+ ]
134+ ],
135+ "Joomla_5.2.1-Stable-Upgrade_Package.zip " => [
136+ "custom " => [
137+ "description " => "Joomla! 5.2.1 Release " ,
138+ "version " => "5.2.1 " ,
139+ "stability " => "stable " ,
140+ ]
141+ ],
142+ "Joomla_5.2.2-Stable-Upgrade_Package.zip " => [
143+ "custom " => [
144+ "description " => "Joomla! 5.2.2 Release " ,
145+ "version " => "5.2.2 " ,
146+ "stability " => "stable " ,
147+ ]
148+ ]
149+ ]));
150+
151+ $ object = new TufFetcher ();
152+ $ result = $ object ->getLatestVersionForBranch (5 );
153+
154+ $ this ->assertEquals ("5.2.3 " , $ result );
155+ }
156+
82157 protected function getStorageMock (array $ targets )
83158 {
84159 $ targetsMock = $ this ->getMockBuilder (TargetsMetadata::class)
0 commit comments