File tree Expand file tree Collapse file tree 4 files changed +35
-13
lines changed Expand file tree Collapse file tree 4 files changed +35
-13
lines changed Original file line number Diff line number Diff line change 66
77use App \Models \Site ;
88use App \RemoteSite \Connection ;
9+ use App \RemoteSite \Responses \HealthCheck ;
910use App \RemoteSite \Responses \PrepareUpdate ;
1011use Illuminate \Contracts \Queue \ShouldQueue ;
1112use Illuminate \Foundation \Queue \Queueable ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \TUF ;
4+
5+ use App \DTO \BaseDTO ;
6+
7+ class ReleaseData extends BaseDTO
8+ {
9+ public function __construct (
10+ public readonly string $ version ,
11+ public readonly string $ stability
12+ ) {
13+ }
14+ }
Original file line number Diff line number Diff line change @@ -41,18 +41,20 @@ function () {
4141 throw new MetadataException ("Empty target custom attribute " );
4242 }
4343
44- return [$ target ['custom ' ]['version ' ] => $ target ['custom ' ]];
44+ $ release = ReleaseData::from ($ target ['custom ' ]);
45+
46+ return [$ release ->version => $ release ];
4547 });
4648 }
4749 );
4850 }
4951
5052 public function getLatestVersionForBranch (int $ branch ): string
5153 {
52- return $ this ->getReleases ()->filter (function ($ release ) {
53- return $ release[ " stability " ] === "Stable " ;
54- })->sort (function ($ releaseA , $ releaseB ) {
55- return version_compare ($ releaseA[ " version " ] , $ releaseB[ " version " ] , '< ' );
54+ return $ this ->getReleases ()->filter (function (ReleaseData $ release ) {
55+ return $ release-> stability === "Stable " ;
56+ })->sort (function (ReleaseData $ releaseA , ReleaseData $ releaseB ) {
57+ return version_compare ($ releaseA-> version , $ releaseB-> version , '< ' );
5658 })->pluck ('version ' )->first ();
5759 }
5860}
Original file line number Diff line number Diff line change 33namespace Tests \Unit \TUF ;
44
55use App \TUF \EloquentModelStorage ;
6+ use App \TUF \ReleaseData ;
67use App \TUF \TufFetcher ;
78use Illuminate \Support \Facades \App ;
89use Tests \TestCase ;
@@ -24,13 +25,15 @@ public function testGetReleasesConvertsLegitResponse()
2425 "Joomla_5.1.2-Stable-Upgrade_Package.zip " => [
2526 "custom " => [
2627 "description " => "Joomla! 5.1.2 Release " ,
27- "version " => "5.1.2 "
28+ "version " => "5.1.2 " ,
29+ "stability " => "stable " ,
2830 ]
2931 ],
3032 "Joomla_5.2.1-Stable-Upgrade_Package.zip " => [
3133 "custom " => [
3234 "description " => "Joomla! 5.2.1 Release " ,
33- "version " => "5.2.1 "
35+ "version " => "5.2.1 " ,
36+ "stability " => "stable " ,
3437 ]
3538 ]
3639 ]));
@@ -39,14 +42,16 @@ public function testGetReleasesConvertsLegitResponse()
3942 $ result = $ object ->getReleases ();
4043
4144 $ this ->assertEquals ([
42- "5.1.2 " => [
45+ "5.1.2 " => ReleaseData:: from ( [
4346 "description " => "Joomla! 5.1.2 Release " ,
44- "version " => "5.1.2 "
45- ],
46- "5.2.1 " => [
47+ "version " => "5.1.2 " ,
48+ "stability " => "stable " ,
49+ ]),
50+ "5.2.1 " => ReleaseData::from ([
4751 "description " => "Joomla! 5.2.1 Release " ,
48- "version " => "5.2.1 "
49- ],
52+ "version " => "5.2.1 " ,
53+ "stability " => "stable " ,
54+ ]),
5055 ], $ result ->toArray ());
5156 }
5257
You can’t perform that action at this time.
0 commit comments