|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\CloudComponents\Test\Functional\Acceptance; |
| 9 | + |
| 10 | +/** |
| 11 | + * @group php83 |
| 12 | + */ |
| 13 | +class Acceptance83Cest extends AcceptanceCest |
| 14 | +{ |
| 15 | + /** |
| 16 | + * @param \CliTester $I |
| 17 | + */ |
| 18 | + public function _before(\CliTester $I): void |
| 19 | + { |
| 20 | + $I->cleanupWorkDir(); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * @param \CliTester $I |
| 25 | + * @param string $magentoVersion |
| 26 | + */ |
| 27 | + protected function prepareTemplate(\CliTester $I, string $magentoVersion): void |
| 28 | + { |
| 29 | + $I->cloneTemplateToWorkDir($magentoVersion); |
| 30 | + $I->createAuthJson(); |
| 31 | + $I->createArtifactsDir(); |
| 32 | + $I->createArtifactCurrentTestedCode('components', '1.0.99'); |
| 33 | + $I->addArtifactsRepoToComposer(); |
| 34 | + $I->addDependencyToComposer('magento/magento-cloud-components', '1.0.99'); |
| 35 | + |
| 36 | + $I->addEceToolsGitRepoToComposer(); |
| 37 | + $I->addEceDockerGitRepoToComposer(); |
| 38 | + $I->addCloudPatchesGitRepoToComposer(); |
| 39 | + $I->addQualityPatchesGitRepoToComposer(); |
| 40 | + |
| 41 | + $dependencies = [ |
| 42 | + 'magento/ece-tools', |
| 43 | + 'magento/magento-cloud-docker', |
| 44 | + 'magento/magento-cloud-patches', |
| 45 | + 'magento/quality-patches' |
| 46 | + ]; |
| 47 | + |
| 48 | + foreach ($dependencies as $dependency) { |
| 49 | + $I->assertTrue( |
| 50 | + $I->addDependencyToComposer($dependency, $I->getDependencyVersion($dependency)), |
| 51 | + 'Can not add dependency ' . $dependency |
| 52 | + ); |
| 53 | + } |
| 54 | + |
| 55 | + $I->composerUpdate(); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @param \CliTester $I |
| 60 | + * @param \Codeception\Example $data |
| 61 | + * @throws \Robo\Exception\TaskException |
| 62 | + * @dataProvider patchesDataProvider |
| 63 | + */ |
| 64 | + public function testPatches(\CliTester $I, \Codeception\Example $data): void |
| 65 | + { |
| 66 | + $this->prepareTemplate($I, $data['magentoVersion']); |
| 67 | + $this->removeESIfExists($I, $data['magentoVersion']); |
| 68 | + $I->generateDockerCompose('--mode=production'); |
| 69 | + $I->runDockerComposeCommand('run build cloud-build'); |
| 70 | + $I->startEnvironment(); |
| 71 | + $I->runDockerComposeCommand('run deploy cloud-deploy'); |
| 72 | + $I->runDockerComposeCommand('run deploy cloud-post-deploy'); |
| 73 | + $I->amOnPage('/'); |
| 74 | + $I->see('Home page'); |
| 75 | + $I->see('CMS homepage content goes here.'); |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * @param \CliTester $I |
| 80 | + * @param string $magentoVersion |
| 81 | + */ |
| 82 | + protected function removeESIfExists(\CliTester $I, string $magentoVersion): void |
| 83 | + { |
| 84 | + if ($magentoVersion !== 'master' && version_compare($magentoVersion, '2.4.0', '<')) { |
| 85 | + $services = $I->readServicesYaml(); |
| 86 | + |
| 87 | + if (isset($services['elasticsearch'])) { |
| 88 | + unset($services['elasticsearch']); |
| 89 | + $I->writeServicesYaml($services); |
| 90 | + |
| 91 | + $app = $I->readAppMagentoYaml(); |
| 92 | + unset($app['relationships']['elasticsearch']); |
| 93 | + $I->writeAppMagentoYaml($app); |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * @return array |
| 100 | + */ |
| 101 | + protected function patchesDataProvider(): array |
| 102 | + { |
| 103 | + return [ |
| 104 | + ['magentoVersion' => '2.4.7'], |
| 105 | + ]; |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * @param \CliTester $I |
| 110 | + */ |
| 111 | + public function _after(\CliTester $I): void |
| 112 | + { |
| 113 | + $I->stopEnvironment(); |
| 114 | + $I->removeWorkDir(); |
| 115 | + } |
| 116 | +} |
0 commit comments