@@ -88,6 +88,31 @@ public function testDownloadsTrapPharSuccessfullyWithForceOption(): void
8888 }
8989 }
9090
91+ public function testDownloadsTomlTestGzBinary (): void
92+ {
93+ // Arrange
94+ $ dload = $ this ->buildDLoad ($ this ->createTomlTestXmlConfig ());
95+ $ downloadConfig = new DownloadConfig ();
96+ $ downloadConfig ->software = 'toml-test ' ;
97+ $ downloadConfig ->version = '2.1.0 ' ;
98+ $ downloadConfig ->type = Type::Binary;
99+ $ downloadConfig ->extractPath = (string ) $ this ->destinationDir ;
100+
101+ // Act
102+ $ dload ->addTask ($ downloadConfig );
103+ $ dload ->run ();
104+
105+ // Assert - Check that toml-test binary was downloaded and extracted from .gz
106+ $ os = OperatingSystem::fromGlobals ();
107+ $ expectedPath = (string ) $ this ->destinationDir ->join ('toml-test ' . $ os ->getBinaryExtension ());
108+ self ::assertFileExists ($ expectedPath , 'toml-test binary should be downloaded and extracted from .gz archive ' );
109+ self ::assertGreaterThan (1024 , \filesize ($ expectedPath ), 'Downloaded binary should have substantial size ' );
110+
111+ if (\PHP_OS_FAMILY !== 'Windows ' ) {
112+ self ::assertTrue (\is_executable ($ expectedPath ), 'Binary file should be executable ' );
113+ }
114+ }
115+
91116 public function testDownloadsTrapBinary (): void
92117 {
93118 // Arrange
@@ -120,29 +145,51 @@ protected function setUp(): void
120145 $ this ->tempDir = $ this ->testRuntimeDir ->join ('temp ' );
121146 $ this ->destinationDir = $ this ->testRuntimeDir ;
122147
123- // Initialize DLoad through Bootstrap
148+ $ this ->dload = $ this ->buildDLoad ($ this ->createTrapXmlConfig ());
149+ }
150+
151+ protected function tearDown (): void
152+ {
153+ // Clean up test directories
154+ if ($ this ->testRuntimeDir ->isDir ()) {
155+ $ this ->removeDirectory ($ this ->testRuntimeDir );
156+ }
157+ }
158+
159+ /**
160+ * @return non-empty-string
161+ */
162+ private function buildDLoad (string $ xmlConfig ): DLoad
163+ {
124164 $ container = Bootstrap::init ()
125- ->withConfig (
126- $ this ->createTrapXmlConfig (),
127- [],
128- [],
129- \getenv (),
130- )
165+ ->withConfig ($ xmlConfig , [], [], \getenv ())
131166 ->finish ();
132167 $ container ->set ($ input = new ArgvInput (), InputInterface::class);
133168 $ container ->set ($ output = new BufferedOutput (), OutputInterface::class);
134169 $ container ->set (new SymfonyStyle ($ input , $ output ), StyleInterface::class);
135170 $ container ->set (new Logger ($ output ));
136171
137- $ this -> dload = $ container ->get (DLoad::class);
172+ return $ container ->get (DLoad::class);
138173 }
139174
140- protected function tearDown (): void
175+ /**
176+ * @return non-empty-string
177+ */
178+ private function createTomlTestXmlConfig (): string
141179 {
142- // Clean up test directories
143- if ($ this ->testRuntimeDir ->isDir ()) {
144- $ this ->removeDirectory ($ this ->testRuntimeDir );
145- }
180+ return <<<XML
181+ <?xml version="1.0"?>
182+ <dload temp-dir=" {$ this ->tempDir }" >
183+ <registry overwrite="false">
184+ <software name="TOML Test" alias="toml-test">
185+ <repository type="github" uri="toml-lang/toml-test"
186+ asset-pattern="/^toml-test-.*/"
187+ />
188+ <binary name="toml-test" pattern="/^toml-test-.*/" version-command="version" />
189+ </software>
190+ </registry>
191+ </dload>
192+ XML ;
146193 }
147194
148195 /**
0 commit comments