Skip to content

Commit 9487d0a

Browse files
committed
Add php 8.3 functional tests
1 parent 22c4e7c commit 9487d0a

10 files changed

+384
-10
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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\CloudDocker\Test\Functional\Acceptance;
9+
10+
use Robo\Exception\TaskException;
11+
12+
/**
13+
* @group php82
14+
*/
15+
class Acceptance82Cest extends AcceptanceCest
16+
{
17+
/**
18+
* Template version for testing
19+
*/
20+
protected const TEMPLATE_VERSION = '2.4.6';
21+
22+
/**
23+
* @param \CliTester $I
24+
* @throws TaskException
25+
*/
26+
public function testProductionMode(\CliTester $I): void
27+
{
28+
$I->assertTrue($I->generateDockerCompose('--mode=production'), 'Command build:compose failed');
29+
$I->replaceImagesWithCustom();
30+
$I->startEnvironment();
31+
$I->runDockerComposeCommand('run build cloud-build');
32+
$I->runDockerComposeCommand('run deploy cloud-deploy');
33+
$I->runDockerComposeCommand('run deploy cloud-post-deploy');
34+
$I->amOnPage('/');
35+
$I->see('Home page');
36+
$I->see('CMS homepage content goes here.');
37+
}
38+
39+
/**
40+
* @param \CliTester $I
41+
* @throws TaskException
42+
* @throws \Codeception\Exception\ModuleConfigException
43+
* @throws \Codeception\Exception\ModuleException
44+
*/
45+
public function testCustomHost(\CliTester $I): void
46+
{
47+
$I->updateBaseUrl('http://magento2.test/');
48+
$I->assertTrue(
49+
$I->generateDockerCompose('--mode=production --host=magento2.test'),
50+
'Command build:compose failed'
51+
);
52+
$I->replaceImagesWithCustom();
53+
$I->startEnvironment();
54+
$I->assertTrue($I->runDockerComposeCommand('run build cloud-build'), 'Build phase failed');
55+
$I->assertTrue($I->runDockerComposeCommand('run deploy cloud-deploy'), 'Deploy phase failed');
56+
$I->assertTrue($I->runDockerComposeCommand('run deploy cloud-post-deploy'), 'Post deploy phase failed');
57+
$I->amOnPage('/');
58+
$I->see('Home page');
59+
$I->see('CMS homepage content goes here.');
60+
}
61+
}

src/Test/Functional/Acceptance/AcceptanceCest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
use Robo\Exception\TaskException;
1111

1212
/**
13-
* @group php82
13+
* @group php83
1414
*/
1515
class AcceptanceCest extends AbstractCest
1616
{
1717
/**
1818
* Template version for testing
1919
*/
20-
protected const TEMPLATE_VERSION = '2.4.6';
20+
protected const TEMPLATE_VERSION = '2.4.7-beta-test';
2121

2222
/**
2323
* @param \CliTester $I
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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\CloudDocker\Test\Functional\Acceptance;
9+
10+
use CliTester;
11+
12+
/**
13+
* @group php82
14+
*/
15+
class Developer82Cest extends DeveloperCest
16+
{
17+
/**
18+
* Template version for testing
19+
*/
20+
protected const TEMPLATE_VERSION = '2.4.6';
21+
22+
/**
23+
* Tests that php settings contains configuration from php.dev.ini
24+
*
25+
* @param CliTester $I
26+
* @throws \Robo\Exception\TaskException
27+
*/
28+
public function testDevPhpIni(CliTester $I)
29+
{
30+
$I->generateDockerCompose('--mode=developer');
31+
$I->replaceImagesWithCustom();
32+
$I->startEnvironment();
33+
34+
$I->runDockerComposeCommand('run deploy php -i | grep opcache.validate_timestamps');
35+
$I->seeInOutput('=> On');
36+
37+
$I->runDockerComposeCommand('run fpm php -i | grep opcache.validate_timestamps');
38+
$I->seeInOutput('=> On');
39+
}
40+
}

src/Test/Functional/Acceptance/DeveloperCest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
use CliTester;
1111

1212
/**
13-
* @group php82
13+
* @group php83
1414
*/
1515
class DeveloperCest extends AbstractCest
1616
{
1717
/**
1818
* Template version for testing
1919
*/
20-
protected const TEMPLATE_VERSION = '2.4.6';
20+
protected const TEMPLATE_VERSION = '2.4.7-beta-test';
2121

2222
/**
2323
* Tests that php settings contains configuration from php.dev.ini
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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\CloudDocker\Test\Functional\Acceptance;
9+
10+
use CliTester;
11+
use Codeception\Example;
12+
use Robo\Exception\TaskException;
13+
14+
/**
15+
* @group php82
16+
*/
17+
class Elasticsearch82Cest extends ElasticsearchCest
18+
{
19+
/**
20+
* Template version for testing
21+
*/
22+
protected const TEMPLATE_VERSION = '2.4.6';
23+
24+
/**
25+
* @param CliTester $I
26+
* @param Example $data
27+
* @dataProvider dataProvider
28+
* @return void
29+
* @throws TaskException
30+
*/
31+
public function testElasticsearch(CliTester $I, Example $data)
32+
{
33+
$I->generateDockerCompose($this->buildCommand($data));
34+
$I->replaceImagesWithCustom();
35+
$I->startEnvironment();
36+
if (!empty($data['plugins'])) {
37+
$I->runDockerComposeCommand('logs elasticsearch');
38+
foreach ($data['plugins'] as $plugin) {
39+
$I->seeInOutput($plugin);
40+
}
41+
}
42+
$I->runDockerComposeCommand('exec -T elasticsearch ps aux | grep elasticsearch');
43+
$I->seeInOutput('-Xms' . $data['xms']);
44+
$I->seeInOutput('-Xmx' . $data['xmx']);
45+
46+
if (!empty($data['param'])) {
47+
$I->runDockerComposeCommand('exec -T elasticsearch curl http://localhost:9200/_nodes/settings');
48+
$I->seeInOutput($data['param']['needle']);
49+
}
50+
}
51+
52+
/**
53+
* Builds build:compose command from given test data
54+
*
55+
* @param Example $data
56+
* @return string
57+
*/
58+
private function buildCommand(Example $data): string
59+
{
60+
$command = sprintf(
61+
'--mode=production --es=%s --es-env-var="ES_JAVA_OPTS=-Xms%s -Xmx%s" --no-os',
62+
$data['version'],
63+
$data['xms'],
64+
$data['xmx']
65+
);
66+
67+
if (!empty($data['param'])) {
68+
$command .= " --es-env-var={$data['param']['key']}={$data['param']['value']}";
69+
}
70+
if (!empty($data['plugins'])) {
71+
$command .= sprintf(' --es-env-var="ES_PLUGINS=%s"', implode(' ', $data['plugins']));
72+
}
73+
74+
return $command;
75+
}
76+
77+
/**
78+
* @return array
79+
*/
80+
protected function dataProvider(): array
81+
{
82+
return [
83+
[
84+
'version' => '7.10',
85+
'xms' => '520m',
86+
'xmx' => '520m',
87+
'plugins' => ['analysis-nori'],
88+
'param' => [
89+
'key' => 'node.store.allow_mmap',
90+
'value' => 'false',
91+
'needle' => '"store":{"allow_mmap":"false"}',
92+
]
93+
],
94+
];
95+
}
96+
}

src/Test/Functional/Acceptance/ElasticsearchCest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
use Robo\Exception\TaskException;
1313

1414
/**
15-
* @group php82
15+
* @group php83
1616
*/
1717
class ElasticsearchCest extends AbstractCest
1818
{
1919
/**
2020
* Template version for testing
2121
*/
22-
protected const TEMPLATE_VERSION = '2.4.6';
22+
protected const TEMPLATE_VERSION = '2.4.7-beta-test';
2323

2424
/**
2525
* @param CliTester $I
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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\CloudDocker\Test\Functional\Acceptance;
9+
10+
/**
11+
* @group php82
12+
*/
13+
class MailHog82Cest extends MailHogCest
14+
{
15+
/**
16+
* Template version for testing
17+
*/
18+
protected const TEMPLATE_VERSION = '2.4.6';
19+
20+
/**
21+
* @param \CliTester $I
22+
* @throws \Exception
23+
*/
24+
public function testDefaultPorts(\CliTester $I): void
25+
{
26+
$I->updateBaseUrl('http://magento2.docker:8025/');
27+
$I->assertTrue(
28+
$I->generateDockerCompose(),
29+
'Command build:compose failed'
30+
);
31+
$this->runAndAssert($I);
32+
}
33+
34+
/**
35+
* @param \CliTester $I
36+
* @throws \Exception
37+
*/
38+
public function testCustomPorts(\CliTester $I): void
39+
{
40+
$I->updateBaseUrl('http://magento2.docker:8026/');
41+
$I->assertTrue(
42+
$I->generateDockerCompose('--mailhog-http-port=8026 --mailhog-smtp-port=1026'),
43+
'Command build:compose failed'
44+
);
45+
$this->runAndAssert($I);
46+
}
47+
48+
/**
49+
* @param \CliTester $I
50+
* @throws \Exception
51+
*/
52+
private function runAndAssert(\CliTester $I): void
53+
{
54+
$I->replaceImagesWithCustom();
55+
$I->startEnvironment();
56+
$I->amOnPage('/');
57+
$I->see('MailHog');
58+
59+
$I->sendAjaxGetRequest('/api/v2/messages', ['limit' => 10]);
60+
$I->seeResponseIsJson();
61+
$I->assertSame([0], $I->grabDataFromResponseByJsonPath('$.total'));
62+
63+
$I->assertTrue(
64+
$I->runDockerComposeCommand('run deploy bash -c "php -r \"mail(\'[email protected]\',\'test\',\'test\');\""')
65+
);
66+
$I->sendAjaxGetRequest('/api/v2/messages', ['limit' => 10]);
67+
$I->seeResponseIsJson();
68+
$I->assertSame([1], $I->grabDataFromResponseByJsonPath('$.total'));
69+
}
70+
}

src/Test/Functional/Acceptance/MailHogCest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
namespace Magento\CloudDocker\Test\Functional\Acceptance;
99

1010
/**
11-
* @group php82
11+
* @group php83
1212
*/
1313
class MailHogCest extends AbstractCest
1414
{
1515
/**
1616
* Template version for testing
1717
*/
18-
protected const TEMPLATE_VERSION = '2.4.6';
18+
protected const TEMPLATE_VERSION = '2.4.7-beta-test';
1919

2020
/**
2121
* @param \CliTester $I

0 commit comments

Comments
 (0)