File tree Expand file tree Collapse file tree 3 files changed +12
-15
lines changed
Test/Unit/Config/Application Expand file tree Collapse file tree 3 files changed +12
-15
lines changed Original file line number Diff line number Diff line change 7
7
8
8
namespace Magento \MagentoCloud \Config \Application ;
9
9
10
- use Magento \MagentoCloud \Command \PostDeploy ;
11
10
use Magento \MagentoCloud \Config \Environment ;
12
11
13
12
/**
14
13
* Checks hooks enabling in .magento.app.yaml
15
14
*/
16
15
class HookChecker
17
16
{
18
- const HOOK_POST_DEPLOY = 'post_deploy ' ;
17
+ private const HOOK_POST_DEPLOY = 'post_deploy ' ;
19
18
20
19
/**
21
20
* @var Environment
@@ -39,14 +38,8 @@ public function isPostDeployHookEnabled(): bool
39
38
{
40
39
$ appConfig = $ this ->environment ->getApplication ();
41
40
42
- if (isset ($ appConfig ['hooks ' ][self ::HOOK_POST_DEPLOY ])) {
43
- $ postDeployHooks = $ appConfig ['hooks ' ][self ::HOOK_POST_DEPLOY ];
41
+ $ postDeployHooks = $ appConfig ['hooks ' ][self ::HOOK_POST_DEPLOY ] ?? '' ;
44
42
45
- if (preg_match (sprintf ('/ece-tools\s+%s/ ' , PostDeploy::NAME ), $ postDeployHooks )) {
46
- return true ;
47
- }
48
- }
49
-
50
- return false ;
43
+ return false !== strpos ($ postDeployHooks , '/ece-tools ' );
51
44
}
52
45
}
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public function validate(): Validator\ResultInterface
49
49
'In order to minimize downtime, add the following to ".magento.app.yaml": ' . PHP_EOL .
50
50
'hooks: ' . PHP_EOL .
51
51
' post_deploy: | ' . PHP_EOL .
52
- ' php ./vendor/bin/ece-tools post-deploy '
52
+ ' php ./vendor/bin/ece-tools run scenario/ post-deploy.xml '
53
53
);
54
54
}
55
55
Original file line number Diff line number Diff line change @@ -27,7 +27,10 @@ class HookCheckerTest extends TestCase
27
27
*/
28
28
private $ checker ;
29
29
30
- protected function setUp ()
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ protected function setUp (): void
31
34
{
32
35
$ this ->environmentMock = $ this ->createMock (Environment::class);
33
36
@@ -37,9 +40,10 @@ protected function setUp()
37
40
/**
38
41
* @param array $hooks
39
42
* @param bool $expectedResult
43
+ *
40
44
* @dataProvider isPostDeployEnabledDataProvider
41
45
*/
42
- public function testIsPostDeployHookEnabled (array $ hooks , bool $ expectedResult )
46
+ public function testIsPostDeployHookEnabled (array $ hooks , bool $ expectedResult ): void
43
47
{
44
48
$ this ->environmentMock ->expects ($ this ->once ())
45
49
->method ('getApplication ' )
@@ -59,8 +63,8 @@ public function isPostDeployEnabledDataProvider(): array
59
63
true ,
60
64
],
61
65
[
62
- ['post_deploy ' => 'php test\nphp test2\n ' ],
63
- false ,
66
+ ['post_deploy ' => 'php ./vendor/bin/ece-tools run ' ],
67
+ true ,
64
68
],
65
69
[
66
70
['deploy ' => 'php test\nphp test2\n ' ],
You can’t perform that action at this time.
0 commit comments