|
| 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 php74 |
| 12 | + */ |
| 13 | +class MailHogCest extends AbstractCest |
| 14 | +{ |
| 15 | + /** |
| 16 | + * @param \CliTester $I |
| 17 | + * @throws \Exception |
| 18 | + */ |
| 19 | + public function testDefaultPorts(\CliTester $I): void |
| 20 | + { |
| 21 | + $I->updateBaseUrl('http://magento2.docker:8025/'); |
| 22 | + $I->assertTrue( |
| 23 | + $I->runEceDockerCommand('build:compose'), |
| 24 | + 'Command build:compose failed' |
| 25 | + ); |
| 26 | + $this->runAndAssert($I); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * @param \CliTester $I |
| 31 | + * @throws \Exception |
| 32 | + */ |
| 33 | + public function testCustomPorts(\CliTester $I): void |
| 34 | + { |
| 35 | + $I->updateBaseUrl('http://magento2.docker:8026/'); |
| 36 | + $I->assertTrue( |
| 37 | + $I->runEceDockerCommand('build:compose --mailhog-http-port=8026 --mailhog-smtp-port=1026'), |
| 38 | + 'Command build:compose failed' |
| 39 | + ); |
| 40 | + $this->runAndAssert($I); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * @param \CliTester $I |
| 45 | + * @throws \Exception |
| 46 | + */ |
| 47 | + private function runAndAssert(\CliTester $I): void |
| 48 | + { |
| 49 | + $I->replaceImagesWithGenerated(); |
| 50 | + $I->startEnvironment(); |
| 51 | + $I->amOnPage('/'); |
| 52 | + $I->see('MailHog'); |
| 53 | + |
| 54 | + $I->sendAjaxGetRequest('/api/v2/messages', ['limit' => 10]); |
| 55 | + $I->seeResponseIsJson(); |
| 56 | + $I->assertSame([0], $I->grabDataFromResponseByJsonPath('$.total')); |
| 57 | + |
| 58 | + $I->assertTrue( |
| 59 | + $I-> runDockerComposeCommand( 'run deploy bash -c "php -r \"mail(\'[email protected]\',\'test\',\'test\');\""') |
| 60 | + ); |
| 61 | + $I->sendAjaxGetRequest('/api/v2/messages', ['limit' => 10]); |
| 62 | + $I->seeResponseIsJson(); |
| 63 | + $I->assertSame([1], $I->grabDataFromResponseByJsonPath('$.total')); |
| 64 | + } |
| 65 | +} |
0 commit comments