22
33namespace Tooly \Tests \Script \Decision ;
44
5- use Tooly \Factory \ToolFactory ;
65use Tooly \Model \Tool ;
76use Tooly \Script \Decision \FileAlreadyExistDecision ;
7+ use Tooly \Script \Helper \Downloader ;
88
99/**
1010 * @package Tooly\Tests\Script\Decision
1111 */
1212class FileAlreadyExistDecisionTest extends DecisionTestCase
1313{
14- public function testIfFileNotAlreadyExistReturnsTrue ()
14+ public function testIfFileIsAccessibleAndFileNotAlreadyExistReturnsTrue ()
1515 {
16+ $ downloader = $ this
17+ ->getMockBuilder (Downloader::class)
18+ ->disableOriginalConstructor ()
19+ ->getMock ();
20+
21+ $ downloader
22+ ->expects ($ this ->once ())
23+ ->method ('isAccessible ' )
24+ ->willReturn (true );
25+
26+ $ this ->helper
27+ ->expects ($ this ->once ())
28+ ->method ('getDownloader ' )
29+ ->willReturn ($ downloader );
30+
31+ $ this ->helper
32+ ->expects ($ this ->once ())
33+ ->method ('isFileAlreadyExist ' )
34+ ->willReturn (false );
35+
36+ $ tool = $ this
37+ ->getMockBuilder (Tool::class)
38+ ->disableOriginalConstructor ()
39+ ->getMock ();
40+
41+ $ decision = new FileAlreadyExistDecision ($ this ->configuration , $ this ->helper );
42+ $ this ->assertTrue ($ decision ->canProceed ($ tool ));
43+ }
44+
45+ public function testIfFileNotAccessibleAndFileNotAlreadyExistReturnsTrue ()
46+ {
47+ $ downloader = $ this
48+ ->getMockBuilder (Downloader::class)
49+ ->disableOriginalConstructor ()
50+ ->getMock ();
51+
52+ $ downloader
53+ ->expects ($ this ->once ())
54+ ->method ('isAccessible ' )
55+ ->willReturn (false );
56+
57+ $ this ->helper
58+ ->expects ($ this ->once ())
59+ ->method ('getDownloader ' )
60+ ->willReturn ($ downloader );
61+
1662 $ this ->helper
1763 ->expects ($ this ->once ())
1864 ->method ('isFileAlreadyExist ' )
@@ -27,8 +73,54 @@ public function testIfFileNotAlreadyExistReturnsTrue()
2773 $ this ->assertTrue ($ decision ->canProceed ($ tool ));
2874 }
2975
30- public function testIfFileAlreadyExistReturnsFalse ()
76+ public function testIfFileIsAccessibleAndFileAlreadyExistReturnsFalse ()
3177 {
78+ $ downloader = $ this
79+ ->getMockBuilder (Downloader::class)
80+ ->disableOriginalConstructor ()
81+ ->getMock ();
82+
83+ $ downloader
84+ ->expects ($ this ->once ())
85+ ->method ('isAccessible ' )
86+ ->willReturn (true );
87+
88+ $ this ->helper
89+ ->expects ($ this ->once ())
90+ ->method ('getDownloader ' )
91+ ->willReturn ($ downloader );
92+
93+ $ this ->helper
94+ ->expects ($ this ->once ())
95+ ->method ('isFileAlreadyExist ' )
96+ ->willReturn (true );
97+
98+ $ tool = $ this
99+ ->getMockBuilder (Tool::class)
100+ ->disableOriginalConstructor ()
101+ ->getMock ();
102+
103+ $ decision = new FileAlreadyExistDecision ($ this ->configuration , $ this ->helper );
104+ $ this ->assertFalse ($ decision ->canProceed ($ tool ));
105+ }
106+
107+ public function testIfFileNotAccessibleAndFileAlreadyExistReturnsFalse ()
108+ {
109+ $ downloader = $ this
110+ ->getMockBuilder (Downloader::class)
111+ ->disableOriginalConstructor ()
112+ ->getMock ();
113+
114+ $ downloader
115+ ->expects ($ this ->once ())
116+ ->method ('isAccessible ' )
117+ ->willReturn (false );
118+
119+ $ this ->helper
120+ ->expects ($ this ->once ())
121+ ->method ('getDownloader ' )
122+ ->willReturn ($ downloader );
123+
32124 $ this ->helper
33125 ->expects ($ this ->once ())
34126 ->method ('isFileAlreadyExist ' )
0 commit comments