diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d56c7c8..6555746 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,6 +24,7 @@ test:acceptance: stage: test services: - mysql:5.7 + - mailhog/mailhog:v1.0.0 - selenium/standalone-chrome variables: MYSQL_ROOT_PASSWORD: "dev" diff --git a/app/typo3conf/AdditionalConfiguration.php b/app/typo3conf/AdditionalConfiguration.php index 5bad1bd..017d71b 100644 --- a/app/typo3conf/AdditionalConfiguration.php +++ b/app/typo3conf/AdditionalConfiguration.php @@ -12,6 +12,10 @@ if ((string) $appContext === 'Testing/Acceptance') { 'SYS' => [ 'trustedHostsPattern' => 'localhost:8080', ], + 'MAIL' => [ + 'transport' => 'smtp', + 'transport_smtp_server' => '127.0.0.1:1025', + ], 'DB' => [ 'Connections' => [ 'Default' => [ @@ -29,6 +33,10 @@ if ((string) $appContext === 'Testing/Acceptance' && getenv('CI') === 'true') { 'SYS' => [ 'trustedHostsPattern' => getenv('TESTING_DOMAIN'), ], + 'MAIL' => [ + 'transport' => 'smtp', + 'transport_smtp_server' => 'mailhog__mailhog:1025', + ], 'DB' => [ 'Connections' => [ 'Default' => [ diff --git a/codeception.yml b/codeception.yml index 3f2a988..9a42be1 100644 --- a/codeception.yml +++ b/codeception.yml @@ -11,6 +11,10 @@ suites: dump: tests/_data/typo3.sql populate: true cleanup: true + - MailHog: + url: http://127.0.0.1 + port: 8025 + deleteEmailsAfterScenario: true - \Helper\Acceptance step_decorators: - Codeception\Step\ConditionalAssertion diff --git a/composer.json b/composer.json index ae2a0a0..f5a6b38 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "require-dev": { "typo3/cms-lowlevel": "*", "codeception/codeception": "^3.1.0", - "typo3/testing-framework": "^4.11" + "typo3/testing-framework": "^4.11", + "ericmartel/codeception-email-mailhog": "^1.0" }, "config": { "platform": { diff --git a/composer.lock b/composer.lock index a79975b..1994d5d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5770c0e541ee89e208e3aa77b5eeabb7", + "content-hash": "b11be7cdad4ce0e81c2f13a90d3a32e5", "packages": [ { "name": "algo26-matthias/idna-convert", @@ -4203,6 +4203,76 @@ "description": "Flexible Stub wrapper for PHPUnit's Mock Builder", "time": "2019-08-10T16:20:53+00:00" }, + { + "name": "ericmartel/codeception-email", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/ericmartel/codeception-email.git", + "reference": "a53370c349467af06a245110014667c3a432e6b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ericmartel/codeception-email/zipball/a53370c349467af06a245110014667c3a432e6b8", + "reference": "a53370c349467af06a245110014667c3a432e6b8", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Codeception\\Email\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric Martel", + "email": "emartel@gmail.com" + } + ], + "description": "Provides test helpers for Codeception when testing email functionality", + "time": "2017-09-05T17:02:06+00:00" + }, + { + "name": "ericmartel/codeception-email-mailhog", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/ericmartel/codeception-email-mailhog.git", + "reference": "5aa917bf97c5a228ef5cba90741cf3b7ff373ea7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ericmartel/codeception-email-mailhog/zipball/5aa917bf97c5a228ef5cba90741cf3b7ff373ea7", + "reference": "5aa917bf97c5a228ef5cba90741cf3b7ff373ea7", + "shasum": "" + }, + "require": { + "ericmartel/codeception-email": "^1.0", + "guzzlehttp/guzzle": "^6.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Codeception\\Module\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric Martel", + "email": "emartel@gmail.com" + } + ], + "description": "Provides test helpers for Codeception when testing email functionality with MailHog", + "time": "2017-11-25T04:16:18+00:00" + }, { "name": "facebook/webdriver", "version": "1.7.1", diff --git a/tests/AddressCest.php b/tests/AddressCest.php index c22e9ad..f9e7a3c 100644 --- a/tests/AddressCest.php +++ b/tests/AddressCest.php @@ -8,6 +8,9 @@ class AddressCest $I->see('Codappix GmbH'); } + /** + * @depends listsExistingRecords + */ public function canEditRecord(AcceptanceTester $I) { $I->amOnPage('/plugin'); @@ -22,6 +25,32 @@ class AddressCest $I->see('TYPO3 Camp Rhein Ruhr'); } + /** + * @depends canEditRecord + */ + public function sendsMailOnUpdate(AcceptanceTester $I) + { + $I->amOnPage('/plugin'); + $I->see('Edit'); + $I->click('Edit'); + + $I->see('Editing: Codappix GmbH'); + $I->fillField(['id' => 'companyName'], 'TYPO3 Camp Rhein Ruhr'); + $I->click('Update'); + + $I->fetchEmails(); + $I->haveUnreadEmails(); + $I->openNextUnreadEmail(); + $I->dontHaveUnreadEmails(); + + $I->seeInOpenedEmailSubject('Address TYPO3 Camp Rhein Ruhr was updated'); + $I->seeInOpenedEmailBody('The address TYPO3 Camp Rhein Ruhr was successfully updated.'); + $I->seeInOpenedEmailRecipients('coding@daniel-siepmann.de'); + } + + /** + * @depends listsExistingRecords + */ public function zipValidatesAgainst5Digits(AcceptanceTester $I) { $I->amOnPage('/plugin'); diff --git a/tests/_envs/gitlab-ci.yml b/tests/_envs/gitlab-ci.yml index 3d4219c..e031c75 100644 --- a/tests/_envs/gitlab-ci.yml +++ b/tests/_envs/gitlab-ci.yml @@ -7,3 +7,6 @@ modules: dsn: 'mysql:host=mysql;dbname=dev' user: 'dev' password: 'dev' + MailHog: + url: http://mailhog__mailhog + port: 8025 diff --git a/tests/_envs/local.yml b/tests/_envs/local.yml index d5dbc2a..867e75e 100644 --- a/tests/_envs/local.yml +++ b/tests/_envs/local.yml @@ -6,3 +6,6 @@ modules: dsn: 'mysql:host=localhost;dbname=own_workshopgitlabacceptance_testing' user: 'dev' password: 'dev' + MailHog: + url: http://127.0.0.1 + port: 8025