7
7
8
8
namespace Magento \MagentoCloud \Test \Unit \Step \Deploy ;
9
9
10
+ use Magento \MagentoCloud \Filesystem \Driver \File ;
11
+ use Magento \MagentoCloud \Filesystem \FileList ;
10
12
use Magento \MagentoCloud \Filesystem \Flag \Manager ;
11
13
use Magento \MagentoCloud \Step \Deploy \RemoveDeployFailedFlag ;
12
14
use Magento \MagentoCloud \Step \StepException ;
@@ -26,17 +28,31 @@ class RemoveDeployFailedFlagTest extends TestCase
26
28
/**
27
29
* @var Manager|MockObject
28
30
*/
29
- private $ flagManager ;
31
+ private $ flagManagerMock ;
32
+
33
+ /**
34
+ * @var File|MockObject
35
+ */
36
+ private $ fileMock ;
37
+
38
+ /**
39
+ * @var FileList|MockObject
40
+ */
41
+ private $ fileListMock ;
30
42
31
43
/**
32
44
* @inheritDoc
33
45
*/
34
46
protected function setUp (): void
35
47
{
36
- $ this ->flagManager = $ this ->createMock (Manager::class);
48
+ $ this ->flagManagerMock = $ this ->createMock (Manager::class);
49
+ $ this ->fileMock = $ this ->createMock (File::class);
50
+ $ this ->fileListMock = $ this ->createMock (FileList::class);
37
51
38
52
$ this ->step = new RemoveDeployFailedFlag (
39
- $ this ->flagManager
53
+ $ this ->flagManagerMock ,
54
+ $ this ->fileMock ,
55
+ $ this ->fileListMock
40
56
);
41
57
}
42
58
@@ -45,13 +61,30 @@ protected function setUp(): void
45
61
*/
46
62
public function testExecute (): void
47
63
{
48
- $ this ->flagManager ->expects ($ this ->at (0 ))
64
+ $ filePath = 'file/path/name.txt ' ;
65
+ $ this ->flagManagerMock ->expects ($ this ->exactly (3 ))
49
66
->method ('delete ' )
50
- ->with (Manager::FLAG_DEPLOY_HOOK_IS_FAILED );
51
- $ this ->flagManager ->expects ($ this ->at (1 ))
52
- ->method ('delete ' )
53
- ->with (Manager::FLAG_IGNORE_SPLIT_DB );
67
+ ->withConsecutive (
68
+ [Manager::FLAG_DEPLOY_HOOK_IS_FAILED ],
69
+ [Manager::FLAG_IGNORE_SPLIT_DB ],
70
+ [Manager::FLAG_ENV_FILE_ABSENCE ]
71
+ );
72
+ $ this ->fileListMock ->expects ($ this ->once ())
73
+ ->method ('getCloudErrorLog ' )
74
+ ->willReturn ($ filePath );
75
+ $ this ->fileMock ->expects ($ this ->once ())
76
+ ->method ('deleteFile ' )
77
+ ->with ($ filePath );
78
+
79
+ $ this ->step ->execute ();
80
+ }
54
81
82
+ public function testExceptionType ()
83
+ {
84
+ $ this ->expectException (StepException::class);
85
+ $ this ->flagManagerMock ->expects ($ this ->once ())
86
+ ->method ('delete ' )
87
+ ->willThrowException (new \Exception ('txt ' ));
55
88
$ this ->step ->execute ();
56
89
}
57
90
}
0 commit comments