@@ -121,4 +121,56 @@ public function testCanSuccessfullyDownloadATool()
121121 $ processor = new Processor ($ this ->io , $ this ->helper , $ this ->configuration );
122122 $ processor ->process ($ tool );
123123 }
124+
125+ public function testCanSuccessfullyDownloadAToolViaFallbackUrl ()
126+ {
127+ vfsStream::setup ('bin ' );
128+
129+ $ downloader = $ this
130+ ->getMockBuilder (Downloader::class)
131+ ->getMock ();
132+
133+ $ downloader
134+ ->expects ($ this ->exactly (3 ))
135+ ->method ('isAccessible ' )
136+ ->will ($ this ->onConsecutiveCalls (false , true , false ));
137+
138+ $ filesystem = $ this
139+ ->getMockBuilder (Filesystem::class)
140+ ->getMock ();
141+
142+ $ filesystem
143+ ->method ('isFileAlreadyExist ' )
144+ ->willReturn (false );
145+
146+ $ this ->helper
147+ ->method ('getFilesystem ' )
148+ ->willReturn ($ filesystem );
149+
150+ $ this ->helper
151+ ->expects ($ this ->exactly (4 ))
152+ ->method ('getDownloader ' )
153+ ->willReturn ($ downloader );
154+
155+ $ this ->helper
156+ ->method ('isFileAlreadyExist ' )
157+ ->willReturn (false );
158+
159+ $ this ->io
160+ ->expects ($ this ->exactly (2 ))
161+ ->method ('write ' );
162+
163+ $ tool = $ this
164+ ->getMockBuilder (Tool::class)
165+ ->disableOriginalConstructor ()
166+ ->getMock ();
167+
168+ $ tool
169+ ->expects ($ this ->exactly (2 ))
170+ ->method ('getFallbackUrl ' )
171+ ->willReturn ('//test.html ' );
172+
173+ $ processor = new Processor ($ this ->io , $ this ->helper , $ this ->configuration );
174+ $ processor ->process ($ tool );
175+ }
124176}
0 commit comments