Skip to content

Commit 89e6675

Browse files
committed
Add PHP 8.3 functional tests
1 parent 5c5aab7 commit 89e6675

34 files changed

+2267
-30
lines changed
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
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\MagentoCloud\Test\Functional\Acceptance;
9+
10+
/**
11+
* This test runs on the latest version of PHP
12+
* @group php82
13+
*/
14+
class AdminCredentialCest extends AbstractCest
15+
{
16+
/**
17+
* @var string
18+
*/
19+
protected $magentoCloudTemplate = '2.4.6';
20+
21+
/**
22+
* @param \CliTester $I
23+
*/
24+
public function _before(\CliTester $I): void
25+
{
26+
parent::_before($I);
27+
28+
$I->copyFileToWorkDir('files/debug_logging/.magento.env.yaml', '.magento.env.yaml');
29+
}
30+
31+
/**
32+
* @param \CliTester $I
33+
* @param \Codeception\Example $data
34+
* @throws \Robo\Exception\TaskException
35+
* @dataProvider installWithoutAdminEmailDataProvider
36+
*/
37+
public function testInstallWithoutAdminEmail(\CliTester $I, \Codeception\Example $data): void
38+
{
39+
$I->generateDockerCompose(
40+
sprintf(
41+
'--mode=production --env-vars="%s"',
42+
$this->convertEnvFromArrayToJson($data['variables'])
43+
)
44+
);
45+
$I->runDockerComposeCommand('run build cloud-build');
46+
$I->startEnvironment();
47+
$I->runDockerComposeCommand('run build cloud-build');
48+
$I->runDockerComposeCommand('run deploy cloud-deploy');
49+
$I->amOnPage('/');
50+
$I->see('Home page');
51+
$I->see('CMS homepage content goes here.');
52+
53+
$log = $I->grabFileContent('/var/log/cloud.log');
54+
$I->assertStringContainsString($data['installMessage'], $log);
55+
$I->assertStringNotContainsString('--admin-user', $log);
56+
$I->assertStringNotContainsString('--admin-firstname', $log);
57+
$I->assertStringNotContainsString('--admin-lastname', $log);
58+
$I->assertStringNotContainsString('--admin-email', $log);
59+
$I->assertStringNotContainsString('--admin-password', $log);
60+
61+
// Upgrade
62+
$I->runDockerComposeCommand('run deploy cloud-deploy');
63+
64+
$I->assertStringContainsString($data['upgradeMessage'], $I->grabFileContent('/var/log/cloud.log'));
65+
}
66+
67+
/**
68+
* @return array
69+
*/
70+
protected function installWithoutAdminEmailDataProvider(): array
71+
{
72+
return [
73+
[
74+
'variables' => ['MAGENTO_CLOUD_VARIABLES' => []],
75+
'installMessage' => '',
76+
'upgradeMessage' => '',
77+
],
78+
[
79+
'variables' => ['MAGENTO_CLOUD_VARIABLES' => ['ADMIN_USERNAME' => 'MyLogin']],
80+
'installMessage' => 'The following admin data was ignored and an admin was not created because'
81+
. ' admin email is not set: admin login',
82+
'upgradeMessage' => 'The following admin data is required to create an admin user during initial'
83+
. ' installation only and is ignored during upgrade process: admin login',
84+
],
85+
];
86+
}
87+
88+
/**
89+
* @param \CliTester $I
90+
* @param \Codeception\Example $data
91+
* @throws \Robo\Exception\TaskException
92+
* @dataProvider installWithDifferentVariablesDataProvider
93+
*/
94+
public function testInstallWithDifferentVariables(\CliTester $I, \Codeception\Example $data)
95+
{
96+
$I->generateDockerCompose(
97+
sprintf(
98+
'--mode=production --env-vars="%s"',
99+
$this->convertEnvFromArrayToJson($data['variables'])
100+
)
101+
);
102+
$I->runDockerComposeCommand('run build cloud-build');
103+
$I->startEnvironment();
104+
$I->runDockerComposeCommand('run deploy cloud-deploy');
105+
$I->amOnPage('/');
106+
$I->see('Home page');
107+
$I->see('CMS homepage content goes here.');
108+
109+
$credentialsEmail = $I->grabFileContent('/var/credentials_email.txt');
110+
$I->assertStringContainsString($data['expectedAdminEmail'], $credentialsEmail);
111+
$I->assertStringContainsString($data['expectedAdminUsername'], $credentialsEmail);
112+
$I->assertStringContainsString($data['expectedAdminUrl'], $credentialsEmail);
113+
114+
$log = $I->grabFileContent('/var/log/cloud.log');
115+
$I->assertStringContainsString('--admin-user', $log);
116+
$I->assertStringContainsString('--admin-firstname', $log);
117+
$I->assertStringContainsString('--admin-lastname', $log);
118+
$I->assertStringContainsString('--admin-email', $log);
119+
$I->assertStringContainsString('--admin-password', $log);
120+
$I->assertStringNotContainsString(
121+
'The following admin data was ignored and an admin was not created because admin email is not set',
122+
$log
123+
);
124+
125+
// Upgrade
126+
$I->runDockerComposeCommand('run deploy cloud-deploy');
127+
128+
$I->assertStringNotContainsString(
129+
'The following admin data is required to create an admin user during initial installation only'
130+
. ' and is ignored during upgrade process: admin login',
131+
$I->grabFileContent('/var/log/cloud.log')
132+
);
133+
}
134+
135+
/**
136+
* @return array
137+
*/
138+
protected function installWithDifferentVariablesDataProvider()
139+
{
140+
return [
141+
[
142+
'variables' => [
143+
'MAGENTO_CLOUD_VARIABLES' => ['ADMIN_EMAIL' => 'admin@example.com'],
144+
],
145+
'expectedAdminEmail' => 'admin@example.com',
146+
'expectedAdminUsername' => 'admin',
147+
'expectedAdminUrl' => 'admin',
148+
],
149+
[
150+
'variables' => [
151+
'MAGENTO_CLOUD_VARIABLES' => [
152+
'ADMIN_EMAIL' => 'admin2@example.com',
153+
'ADMIN_URL' => 'root',
154+
'ADMIN_USERNAME' => 'myusername',
155+
],
156+
],
157+
'expectedAdminEmail' => 'admin2@example.com',
158+
'expectedAdminUsername' => 'root',
159+
'expectedAdminUrl' => 'myusername',
160+
]
161+
];
162+
}
163+
}

src/Test/Functional/Acceptance/AdminCredentialCest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AdminCredentialCest extends AbstractCest
1616
/**
1717
* @var string
1818
*/
19-
protected $magentoCloudTemplate = '2.4.6';
19+
protected $magentoCloudTemplate = '2.4.7-beta-test';
2020

2121
/**
2222
* @param \CliTester $I
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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\MagentoCloud\Test\Functional\Acceptance;
9+
10+
use CliTester;
11+
use Codeception\Example;
12+
use Exception;
13+
use Robo\Exception\TaskException;
14+
15+
/**
16+
* Checks database backup functionality
17+
* @group php82
18+
*/
19+
class BackupDbCest extends AbstractCest
20+
{
21+
/**
22+
* @var array
23+
*/
24+
private $expectedLogs = [
25+
'INFO: Starting backup.',
26+
'NOTICE: Enabling Maintenance mode',
27+
'INFO: Trying to kill running cron jobs and consumers processes',
28+
'INFO: Running Magento cron and consumers processes were not found.',
29+
'INFO: Waiting for lock on db dump.',
30+
'NOTICE: Maintenance mode is disabled.',
31+
'INFO: Backup completed.'
32+
];
33+
34+
/**
35+
* @var array
36+
*/
37+
private $envMagento = ['stage' => ['global' => ['SCD_ON_DEMAND' => true]]];
38+
39+
/**
40+
* {@inheritDoc}
41+
* @param CliTester $I
42+
*/
43+
public function _before(CliTester $I): void
44+
{
45+
// Do nothing
46+
}
47+
48+
/**
49+
* @param CliTester $I
50+
* @param Example $data
51+
* @throws Exception
52+
* @dataProvider dataProviderMagentoCloudVersions
53+
*/
54+
public function testBackUpDb(CliTester $I, Example $data): void
55+
{
56+
57+
$this->prepareWorkplace($I, $data['version']);
58+
59+
// Part of test without 'SplitDB' architecture
60+
$this->partRunDbDumpWithoutSplitDbArch($I);
61+
62+
$I->stopEnvironment(true);
63+
}
64+
65+
/**
66+
* @return array
67+
*/
68+
protected function dataProviderMagentoCloudVersions(): array
69+
{
70+
return [
71+
['version' => '2.4.6'],
72+
];
73+
}
74+
75+
/**
76+
* Part of test without 'SplitDB' architecture
77+
*
78+
* @param CliTester $I
79+
* @throws TaskException
80+
*/
81+
private function partRunDbDumpWithoutSplitDbArch(CliTester $I)
82+
{
83+
$I->writeEnvMagentoYaml($this->envMagento);
84+
$I->generateDockerCompose('--mode=production');
85+
86+
// Running database dump command with invalid database label
87+
$I->runDockerComposeCommand('run build cloud-build');
88+
89+
// Restore app/etc after build phase
90+
$I->runDockerComposeCommand('run build bash -c "cp -r /app/init/app/etc /app/app"');
91+
92+
$I->runDockerComposeCommand('run deploy ece-command db-dump incorrectName');
93+
$I->seeInOutput(
94+
'CRITICAL: Incorrect the database names: [ incorrectName ].'
95+
. ' Available database names: [ main quote sales ]'
96+
);
97+
98+
// Running database dump command with unavailable database label
99+
$I->runDockerComposeCommand('run deploy cloud-deploy');
100+
101+
$I->runDockerComposeCommand('run deploy ece-command db-dump -n quote');
102+
$I->seeInOutput(
103+
'CRITICAL: Environment does not have connection `checkout` associated with database `quote`'
104+
);
105+
106+
$I->runDockerComposeCommand('run deploy ece-command db-dump -n sales');
107+
$I->seeInOutput(
108+
'CRITICAL: Environment does not have connection `sales` associated with database `sales`'
109+
);
110+
111+
$I->runDockerComposeCommand('run deploy ece-command db-dump -n quote sales');
112+
$I->seeInOutput(
113+
'CRITICAL: Environment does not have connection `checkout` associated with database `quote`'
114+
);
115+
116+
// Running database dump command without database label (by default)
117+
$I->runDockerComposeCommand('run deploy ece-command db-dump -n');
118+
$I->seeInOutput(array_merge(
119+
$this->expectedLogs,
120+
[
121+
'INFO: Start creation DB dump for main database...',
122+
'INFO: Finished DB dump for main database, it can be found here: /app/var/dump-main',
123+
]
124+
));
125+
$I->doNotSeeInOutput(['quote', 'sales']);
126+
}
127+
}

src/Test/Functional/Acceptance/BackupDbCest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
/**
1616
* Checks database backup functionality
17-
* @group php82
17+
* @group php83
1818
*/
1919
class BackupDbCest extends AbstractCest
2020
{
@@ -68,7 +68,7 @@ public function testBackUpDb(CliTester $I, Example $data): void
6868
protected function dataProviderMagentoCloudVersions(): array
6969
{
7070
return [
71-
['version' => '2.4.6'],
71+
['version' => '2.4.7-beta-test'],
7272
];
7373
}
7474

0 commit comments

Comments
 (0)