1010use Magento \CloudDocker \Test \Functional \Codeception \Docker ;
1111
1212/**
13- * @group php84
13+ * Abstract PatchApplierCest
14+ *
15+ * @abstract
1416 */
15- class PatchApplierCest extends AbstractCest
17+ abstract class PatchApplierCest extends AbstractCest
1618{
1719 /**
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
1924 */
2025 public function _before (\CliTester $ I ): void
2126 {
2227 parent ::_before ($ I );
23-
24- $ this ->prepareTemplate ($ I , '2.4.8 ' );
25- $ I ->copyFileToWorkDir ('files/debug_logging/.magento.env.yaml ' , '.magento.env.yaml ' );
2628 }
2729
2830 /**
31+ * Tests applying an existing patch to a target file.
32+ *
2933 * @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+ * ]
3040 * @throws \Robo\Exception\TaskException
41+ * @dataProvider patchesDataProvider
3142 */
32- public function testApplyingPatch (\CliTester $ I ): void
43+ public function testApplyingPatch (\CliTester $ I, \ Codeception \ Example $ data ): void
3344 {
45+ $ this ->prepareTemplate ($ I , $ data ['templateVersion ' ], $ data ['magentoVersion ' ] ?? null );
46+
3447 $ I ->generateDockerCompose ('--mode=production ' );
48+
49+ $ I ->copyFileToWorkDir ('files/debug_logging/.magento.env.yaml ' , '.magento.env.yaml ' );
3550 $ I ->copyFileToWorkDir ('files/patches/target_file.md ' , 'target_file.md ' );
3651 $ I ->copyFileToWorkDir ('files/patches/patch.patch ' , 'm2-hotfixes/patch.patch ' );
3752
@@ -47,12 +62,25 @@ public function testApplyingPatch(\CliTester $I): void
4762 }
4863
4964 /**
65+ * Tests that an existing patch is not applied again.
66+ *
5067 * @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+ * ]
5174 * @throws \Robo\Exception\TaskException
75+ * @dataProvider patchesDataProvider
5276 */
53- public function testApplyingExistingPatch (\CliTester $ I ): void
77+ public function testApplyingExistingPatch (\CliTester $ I, \ Codeception \ Example $ data ): void
5478 {
79+ $ this ->prepareTemplate ($ I , $ data ['templateVersion ' ], $ data ['magentoVersion ' ] ?? null );
80+
5581 $ I ->generateDockerCompose ('--mode=production ' );
82+
83+ $ I ->copyFileToWorkDir ('files/debug_logging/.magento.env.yaml ' , '.magento.env.yaml ' );
5684 $ I ->copyFileToWorkDir ('files/patches/target_file_applied_patch.md ' , 'target_file.md ' );
5785 $ I ->copyFileToWorkDir ('files/patches/patch.patch ' , 'm2-hotfixes/patch.patch ' );
5886
@@ -68,4 +96,10 @@ public function testApplyingExistingPatch(\CliTester $I): void
6896 $ I ->grabFileContent ('/init/var/log/cloud.log ' , Docker::BUILD_CONTAINER )
6997 );
7098 }
99+
100+ /**
101+ * Returns the data provider for patches.
102+ * @return array
103+ */
104+ abstract protected function patchesDataProvider (): array ;
71105}
0 commit comments