10
10
use Magento \CloudDocker \Test \Functional \Codeception \Docker ;
11
11
12
12
/**
13
- * @group php83
13
+ * Abstract PatchApplierCest
14
+ *
15
+ * @abstract
14
16
*/
15
- class PatchApplierCest extends AbstractCest
17
+ abstract class PatchApplierCest extends AbstractCest
16
18
{
17
19
/**
18
- * @param \CliTester $I
20
+ * Prepares the test environment before each test.
21
+ *
22
+ * @param \CliTester $I The CLI tester instance.
23
+ * @throws \Robo\Exception\TaskException
19
24
*/
20
25
public function _before (\CliTester $ I ): void
21
26
{
22
27
parent ::_before ($ I );
23
-
24
- $ this ->prepareTemplate ($ I , '2.4.7 ' );
25
- $ I ->copyFileToWorkDir ('files/debug_logging/.magento.env.yaml ' , '.magento.env.yaml ' );
26
28
}
27
29
28
30
/**
31
+ * Tests applying an existing patch to a target file.
32
+ *
29
33
* @param \CliTester $I
34
+ * @param \Codeception\Example $data The example data for the test.
35
+ * Expected structure:
36
+ * [
37
+ * 'templateVersion' => string,
38
+ * 'magentoVersion' => string|null (optional)
39
+ * ]
30
40
* @throws \Robo\Exception\TaskException
41
+ * @dataProvider patchesDataProvider
31
42
*/
32
- public function testApplyingPatch (\CliTester $ I ): void
43
+ public function testApplyingPatch (\CliTester $ I, \ Codeception \ Example $ data ): void
33
44
{
45
+ $ this ->prepareTemplate ($ I , $ data ['templateVersion ' ], $ data ['magentoVersion ' ] ?? null );
46
+
34
47
$ I ->generateDockerCompose ('--mode=production ' );
48
+
49
+ $ I ->copyFileToWorkDir ('files/debug_logging/.magento.env.yaml ' , '.magento.env.yaml ' );
35
50
$ I ->copyFileToWorkDir ('files/patches/target_file.md ' , 'target_file.md ' );
36
51
$ I ->copyFileToWorkDir ('files/patches/patch.patch ' , 'm2-hotfixes/patch.patch ' );
37
52
@@ -47,12 +62,25 @@ public function testApplyingPatch(\CliTester $I): void
47
62
}
48
63
49
64
/**
65
+ * Tests that an existing patch is not applied again.
66
+ *
50
67
* @param \CliTester $I
68
+ * @param \Codeception\Example $data The example data for the test.
69
+ * Expected structure:
70
+ * [
71
+ * 'templateVersion' => string,
72
+ * 'magentoVersion' => string|null (optional)
73
+ * ]
51
74
* @throws \Robo\Exception\TaskException
75
+ * @dataProvider patchesDataProvider
52
76
*/
53
- public function testApplyingExistingPatch (\CliTester $ I ): void
77
+ public function testApplyingExistingPatch (\CliTester $ I, \ Codeception \ Example $ data ): void
54
78
{
79
+ $ this ->prepareTemplate ($ I , $ data ['templateVersion ' ], $ data ['magentoVersion ' ] ?? null );
80
+
55
81
$ I ->generateDockerCompose ('--mode=production ' );
82
+
83
+ $ I ->copyFileToWorkDir ('files/debug_logging/.magento.env.yaml ' , '.magento.env.yaml ' );
56
84
$ I ->copyFileToWorkDir ('files/patches/target_file_applied_patch.md ' , 'target_file.md ' );
57
85
$ I ->copyFileToWorkDir ('files/patches/patch.patch ' , 'm2-hotfixes/patch.patch ' );
58
86
@@ -68,4 +96,10 @@ public function testApplyingExistingPatch(\CliTester $I): void
68
96
$ I ->grabFileContent ('/init/var/log/cloud.log ' , Docker::BUILD_CONTAINER )
69
97
);
70
98
}
99
+
100
+ /**
101
+ * Returns the data provider for patches.
102
+ * @return array
103
+ */
104
+ abstract protected function patchesDataProvider (): array ;
71
105
}
0 commit comments