From ae5e5e5be04df5953ff7e7af466ecf2508f2ab98 Mon Sep 17 00:00:00 2001 From: Rudzinski Date: Tue, 21 Dec 2021 11:11:23 +0100 Subject: [PATCH] Code cleaning (#49) * Prepare dependency;Install bitbag/coding-standard * Delete always true assertions and redundant parameters, add variables to PHPDocs, fix invalid method names * Fix src dir with bitbag/codin-standard tool * Fix tests dir with bitbag/codin-standard tool * New workflow * Add PHP 7.3 and env * Delete .env.local * Fix doctrine conflict * Add doctrine conflict * Add env to build.yml * Remove unnecessary line from build.yml * Fix build.yaml invalid format * MailChimpContext fixed * Fix too wide specification in .gitignore file --- .github/coding_standard.yaml | 87 ++++++++++++++ .github/workflows/build.yml | 112 ++++++++++-------- .gitignore | 3 + composer.json | 13 +- ...changing_newsletter_email_as_admin.feature | 2 +- ...subscribing_newsletter_as_customer.feature | 4 +- .../subscribing_newsletter_as_guest.feature | 4 +- ...ibing_newsletter_with_invalid_data.feature | 4 +- src/Controller/NewsletterController.php | 2 +- .../BitBagSyliusMailChimpExtension.php | 2 +- src/Handler/NewsletterSubscriptionHandler.php | 15 ++- .../Constraints/UniqueNewsletterEmail.php | 2 +- tests/Application/.env.test | 9 -- tests/Application/config/bootstrap.php | 6 +- .../Context/Ui/Shop/MailChimpContext.php | 36 ++---- .../Context/Ui/Shop/NewsletterContext.php | 19 +-- .../Fake/AlwaysSuccessMailChimpClient.php | 6 +- tests/Behat/Page/Shop/NewsletterPage.php | 10 +- .../Page/Shop/NewsletterPageInterface.php | 8 +- tests/Behat/Page/Shop/ProfileUpdatePage.php | 4 +- .../Page/Shop/ProfileUpdatePageInterface.php | 4 +- 21 files changed, 224 insertions(+), 128 deletions(-) create mode 100644 .github/coding_standard.yaml delete mode 100644 tests/Application/.env.test diff --git a/.github/coding_standard.yaml b/.github/coding_standard.yaml new file mode 100644 index 0000000..1b9e84f --- /dev/null +++ b/.github/coding_standard.yaml @@ -0,0 +1,87 @@ +name: Coding standard + +on: + push: + branches-ignore: + - 'dependabot/**' + pull_request: ~ + release: + types: [created] + schedule: + - + cron: "0 1 * * 6" # Run at 1am every Saturday + workflow_dispatch: ~ + +jobs: + tests: + runs-on: ubuntu-latest + + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" + + strategy: + fail-fast: false + matrix: + php: [7.4, 7.3, 8.0] + symfony: [^4.4, ^5.2] + sylius: [~1.8.0, ~1.9.0, ~1.10.0] + node: [10.x] + mysql: [5.7] + + exclude: + - + php: 7.3 + mysql: 8.0 + - + sylius: ~1.8.0 + symfony: ^5.2 + - + sylius: ~1.8.0 + php: 8.0 + - + sylius: ~1.9.0 + php: 8.0 + - + sylius: ~1.10.0 + php: 7.3 + + env: + APP_ENV: test + DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" + + steps: + - + uses: actions/checkout@v2 + - + name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - + name: Cache Composer + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php }}-composer- + - + name: Restrict Symfony version + if: matrix.symfony != '' + run: | + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" + - + name: Restrict Sylius version + if: matrix.sylius != '' + run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction + + - + name: Install PHP dependencies + run: composer install --no-interaction + + - + name: Run PHPStan + run: vendor/bin/phpstan analyse -c phpstan.neon -l 7 src/ + + - name: Run ECS + run: vendor/bin/ecs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3808467..bdb379b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,18 +14,36 @@ on: jobs: tests: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest - name: "PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" strategy: fail-fast: false matrix: - php: [7.4] - symfony: [^5.2] + php: [7.4, 7.3, 8.0] + symfony: [^4.4, ^5.2] + sylius: [~1.8.0, ~1.9.0, ~1.10.0] node: [10.x] mysql: [5.7] + exclude: + - + php: 7.3 + mysql: 8.0 + - + sylius: ~1.8.0 + symfony: ^5.2 + - + sylius: ~1.8.0 + php: 8.0 + - + sylius: ~1.9.0 + php: 8.0 + - + sylius: ~1.10.0 + php: 7.3 + env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" @@ -59,34 +77,11 @@ jobs: with: mysql version: "${{ matrix.mysql }}" mysql root password: "root" - - - - name: Configure sysctl limits - run: | - sudo swapoff -a - sudo sysctl -w vm.swappiness=1 - sudo sysctl -w fs.file-max=262144 - sudo sysctl -w vm.max_map_count=262144 - - - - name: Runs Elasticsearch - uses: elastic/elastic-github-actions/elasticsearch@master - with: - stack-version: 6.8.15 - name: Output PHP version for Symfony CLI run: php -v | head -n 1 | awk '{ print $2 }' > .php-version - - - name: Install wkhtmltopdf - run: | - sudo apt-get update - sudo apt-get install xvfb libfontconfig wkhtmltopdf --fix-missing - echo 'xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf "$@"' > "/usr/local/bin/wkhtmltopdf.sh" - sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh - echo export WKHTMLTOPDF_PATH="/usr/local/wkhtmltopdf.sh" - - name: Install certificates run: symfony server:ca:install @@ -97,12 +92,7 @@ jobs: - name: Run webserver - run: symfony server:start --port=8080 --dir=public --daemon - - - - name: Restrict Symfony version - if: matrix.symfony != '' - run: composer config extra.symfony.require "${{ matrix.symfony }}" + run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon) - name: Get Composer cache directory @@ -117,8 +107,19 @@ jobs: key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} restore-keys: | ${{ runner.os }}-php-${{ matrix.php }}-composer- + - + name: Restrict Symfony version + if: matrix.symfony != '' + run: | + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" + - + name: Restrict Sylius version + if: matrix.sylius != '' + run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction - - name: Install PHP dependencies + - + name: Install PHP dependencies run: composer install --no-interaction - @@ -134,7 +135,6 @@ jobs: key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }} restore-keys: | ${{ runner.os }}-node-${{ matrix.node }}-yarn- - - name: Install JS dependencies run: (cd tests/Application && yarn install) @@ -143,38 +143,50 @@ jobs: name: Prepare test application database run: | (cd tests/Application && bin/console doctrine:database:create -vvv) - (cd tests/Application && bin/console doctrine:migrations:migrate -n -vvv) - + (cd tests/Application && bin/console doctrine:schema:create -vvv) - name: Prepare test application assets run: | (cd tests/Application && bin/console assets:install public -vvv) (cd tests/Application && yarn build) - - name: Prepare test application cache run: (cd tests/Application && bin/console cache:warmup -vvv) - - name: Load fixtures + name: Load fixtures in test application run: (cd tests/Application && bin/console sylius:fixtures:load -n) - - + - name: Validate composer.json - run: composer validate --ansi --strict --no-check-publish - - - - name: Run security check - run: symfony security:check - - - - name: Run PHPStan - run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/ + run: composer validate --ansi --strict - - + - name: Validate database schema run: (cd tests/Application && bin/console doctrine:schema:validate) + - + name: Run PHPStan + run: vendor/bin/phpstan analyse -c phpstan.neon -l 7 src/ + - name: Run PHPSpec run: vendor/bin/phpspec run --ansi -f progress --no-interaction + + + - + name: Run Behat + env: + MAIL_CHIMP_API_KEY: ${{ secrets.MAILCHIMP_API_TOKEN }} + MAIL_CHIMP_LIST_ID: ${{ secrets.MAIL_CHIMP_LIST_ID }} + MAIL_CHIMP_WEBHOOK_SECRET: ${{ secrets.MAIL_CHIMP_WEBHOOK_SECRET }} + run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun + + - + name: Upload Behat logs + uses: actions/upload-artifact@v2 + if: failure() + with: + name: Behat logs + path: etc/build/ + if-no-files-found: ignore diff --git a/.gitignore b/.gitignore index 829a5d4..008a7e9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ !/etc/build/.gitkeep /tests/Application/yarn.lock +/.env.*.local +/.env.local +/.env.local.php diff --git a/composer.json b/composer.json index 96c0a3b..7c70488 100644 --- a/composer.json +++ b/composer.json @@ -5,10 +5,13 @@ "description": "MailChimp plugin for Sylius.", "license": "MIT", "require": { - "php": "^7.4 || ^8.0", + "php": "^7.3 || ^7.4 || ^8.0", "sylius/sylius": "^1.10", "drewm/mailchimp-api": "^v2.5.4", - "ext-json": "*" + "ext-json": "*", + "vimeo/psalm": "^4.12", + "composer/xdebug-handler": "^2.0", + "bitbag/coding-standard": "^1.0" }, "require-dev": { "behat/behat": "^3.6.1", @@ -36,10 +39,12 @@ "symfony/debug-bundle": "^4.4 || ^5.2", "symfony/dotenv": "^4.4 || ^5.2", "symfony/intl": "^4.4 || ^5.2", - "symfony/web-profiler-bundle": "^4.4 || ^5.2", - "vimeo/psalm": "4.6.4" + "symfony/web-profiler-bundle": "^4.4 || ^5.2" }, "prefer-stable": true, + "conflict": { + "doctrine/orm": "^2.10.0" + }, "autoload": { "psr-4": { "BitBag\\SyliusMailChimpPlugin\\": "src/", diff --git a/features/changing_newsletter_email_as_admin.feature b/features/changing_newsletter_email_as_admin.feature index b4905dc..924f1aa 100644 --- a/features/changing_newsletter_email_as_admin.feature +++ b/features/changing_newsletter_email_as_admin.feature @@ -6,7 +6,7 @@ Feature: Changing customer newsletter email Background: Given I am logged in as an administrator - And there is a created list in MailChimp with specified ID + @ui Scenario: Subscribing to newsletter as guest diff --git a/features/subscribing_newsletter_as_customer.feature b/features/subscribing_newsletter_as_customer.feature index e9c72a0..8f9c7c1 100644 --- a/features/subscribing_newsletter_as_customer.feature +++ b/features/subscribing_newsletter_as_customer.feature @@ -6,7 +6,7 @@ Feature: Updating not subscribed customer Background: Given the store operates on a single channel And there is no customer with "tata@escobar.co" email - And there is a created list in MailChimp with specified ID + Scenario: Subscribing to newsletter as customer Given I want to subscribe to the newsletter @@ -15,4 +15,4 @@ Feature: Updating not subscribed customer Then the "tata@escobar.co" customer should be created And the customer should be subscribed to the newsletter And I should be notified that I am subscribed to the newsletter - And the email "tata@escobar.co" should be exported to MailChimp's default list \ No newline at end of file + And the email "tata@escobar.co" should be exported to MailChimp's default list diff --git a/features/subscribing_newsletter_as_guest.feature b/features/subscribing_newsletter_as_guest.feature index 42491f9..6c1b9ae 100644 --- a/features/subscribing_newsletter_as_guest.feature +++ b/features/subscribing_newsletter_as_guest.feature @@ -7,7 +7,7 @@ Feature: Creating new newsletter customer Background: Given the store operates on a single channel And there is no customer with "tata@escobar.co" email - And there is a created list in MailChimp with specified ID + Scenario: Subscribing to newsletter as guest Given I want to subscribe to the newsletter @@ -16,4 +16,4 @@ Feature: Creating new newsletter customer Then the "tata@escobar.co" customer should be created And the customer should be subscribed to the newsletter And I should be notified that I am subscribed to the newsletter - And the email "tata@escobar.co" should be exported to MailChimp's default list \ No newline at end of file + And the email "tata@escobar.co" should be exported to MailChimp's default list diff --git a/features/subscribing_newsletter_with_invalid_data.feature b/features/subscribing_newsletter_with_invalid_data.feature index 64a08c2..cf2082c 100644 --- a/features/subscribing_newsletter_with_invalid_data.feature +++ b/features/subscribing_newsletter_with_invalid_data.feature @@ -6,7 +6,7 @@ Feature: Validating newsletter form Background: Given the store operates on a single channel - And there is a created list in MailChimp with specified ID + Scenario: Subscribing to newsletter with invalid email When I want to subscribe to the newsletter @@ -26,4 +26,4 @@ Feature: Validating newsletter form When I want to subscribe to the newsletter And I fill newsletter with "los@pepes.co" email And I subscribe to it - Then I should be notified that the submitted email is already subscribed to the newsletter \ No newline at end of file + Then I should be notified that the submitted email is already subscribed to the newsletter diff --git a/src/Controller/NewsletterController.php b/src/Controller/NewsletterController.php index 84ac622..e314e48 100644 --- a/src/Controller/NewsletterController.php +++ b/src/Controller/NewsletterController.php @@ -50,7 +50,7 @@ public function subscribeAction(Request $request): JsonResponse $email = $request->request->get('email'); $token = $request->request->get('_token'); - if(!is_string($email) || !is_string($token)){ + if (!is_string($email) || !is_string($token)) { return new JsonResponse([ 'success' => false, 'errors' => json_encode($this->translator->trans('bitbag_sylius_mailchimp_plugin.ui.invalid_variable_type')), diff --git a/src/DependencyInjection/BitBagSyliusMailChimpExtension.php b/src/DependencyInjection/BitBagSyliusMailChimpExtension.php index f6ebeea..1788a10 100644 --- a/src/DependencyInjection/BitBagSyliusMailChimpExtension.php +++ b/src/DependencyInjection/BitBagSyliusMailChimpExtension.php @@ -18,7 +18,7 @@ final class BitBagSyliusMailChimpExtension extends Extension { /** - * {@inheritdoc} + * @inheritdoc */ public function load(array $config, ContainerBuilder $container): void { diff --git a/src/Handler/NewsletterSubscriptionHandler.php b/src/Handler/NewsletterSubscriptionHandler.php index 4458377..c1e880e 100644 --- a/src/Handler/NewsletterSubscriptionHandler.php +++ b/src/Handler/NewsletterSubscriptionHandler.php @@ -125,8 +125,10 @@ private function exportNewEmail(string $email): void if (false === $response) { throw new BadRequestHttpException( - sprintf('Mailchimp returned false instead of response array, last error : %s', - $this->mailChimp->getLastError()) + sprintf( + 'Mailchimp returned false instead of response array, last error : %s', + $this->mailChimp->getLastError() + ) ); } @@ -137,7 +139,8 @@ private function exportNewEmail(string $email): void $concatenatedList = implode(',', $validListIds); throw new BadRequestHttpException( - sprintf('Mailchimp returned %1$i code, is the MAIL_CHIMP_LIST_ID [ %2$s ] one of available ones: [ %3$s ] ?', + sprintf( + 'Mailchimp returned %1$i code, is the MAIL_CHIMP_LIST_ID [ %2$s ] one of available ones: [ %3$s ] ?', Response::HTTP_NOT_FOUND, $this->listId, $concatenatedList @@ -168,8 +171,10 @@ protected function addMailchimpData(string $email): void if (false === $response) { throw new BadRequestHttpException( - sprintf('Mailchimp returned false instead of response array, last error : %s', - $this->mailChimp->getLastError()) + sprintf( + 'Mailchimp returned false instead of response array, last error : %s', + $this->mailChimp->getLastError() + ) ); } diff --git a/src/Validator/Constraints/UniqueNewsletterEmail.php b/src/Validator/Constraints/UniqueNewsletterEmail.php index 9b6a213..77618c2 100644 --- a/src/Validator/Constraints/UniqueNewsletterEmail.php +++ b/src/Validator/Constraints/UniqueNewsletterEmail.php @@ -19,6 +19,6 @@ final class UniqueNewsletterEmail extends Constraint public function validatedBy(): string { - return get_class($this) . 'Validator'; + return static::class . 'Validator'; } } diff --git a/tests/Application/.env.test b/tests/Application/.env.test deleted file mode 100644 index e946850..0000000 --- a/tests/Application/.env.test +++ /dev/null @@ -1,9 +0,0 @@ -APP_SECRET='ch4mb3r0f5ecr3ts' - -KERNEL_CLASS='Tests\BitBag\SyliusExamplePlugin\Application\Kernel' - -DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.db - -MAIL_CHIMP_API_KEY='YourAPIKey' -MAIL_CHIMP_LIST_ID='YourMailingListID' -MAIL_CHIMP_WEBHOOK_SECRET='' diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index d7ac51d..b49cacb 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -15,9 +15,9 @@ throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); } else { // load all the .env files - (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); + (new Dotenv())->loadEnv(dirname(__DIR__) . '/.env'); } -$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; +$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?? 'dev'; $_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; -$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; +$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/tests/Behat/Context/Ui/Shop/MailChimpContext.php b/tests/Behat/Context/Ui/Shop/MailChimpContext.php index 47e22f6..a4ac1a6 100644 --- a/tests/Behat/Context/Ui/Shop/MailChimpContext.php +++ b/tests/Behat/Context/Ui/Shop/MailChimpContext.php @@ -1,39 +1,32 @@ listId = $listId; } - /** - * @Given there is a created list in MailChimp with specified ID - */ - public function thereIsAMailChimpListWithSpecifiedId() - { - Assert::notNull($this->listId); - } - /** * @Given this email is also subscribed to the default MailChimp list */ @@ -63,7 +48,6 @@ public function thisEmailIsAlsoExportedToMailChimpDefaultList() } /** - * * @Then the email :email should not be in MailChimp's list */ public function theEmailShouldNotBeInMailChimpList($email) @@ -92,7 +76,6 @@ public function theEmailShouldBeExportedToMailChimp($email) $email, $this->listId )); - $this->subscribedEmail = $email; } /** @@ -100,7 +83,7 @@ public function theEmailShouldBeExportedToMailChimp($email) */ public function thereIsAnExistingEmailInMailChimpDefaultList($email) { - $response = $this->mailChimp->post("lists/" . $this->listId . "/members", [ + $response = $this->mailChimp->post('lists/' . $this->listId . '/members', [ 'email_address' => $email, 'status' => 'subscribed', ]); @@ -109,7 +92,7 @@ public function thereIsAnExistingEmailInMailChimpDefaultList($email) } /** - * @AfterScenario + * @AfterScenario :email */ public function removeNewsletterEmail() { @@ -119,6 +102,7 @@ public function removeNewsletterEmail() /** * @param string $email + * * @return string */ private function getSubscriberHash($email) diff --git a/tests/Behat/Context/Ui/Shop/NewsletterContext.php b/tests/Behat/Context/Ui/Shop/NewsletterContext.php index d62ead6..0150ce0 100644 --- a/tests/Behat/Context/Ui/Shop/NewsletterContext.php +++ b/tests/Behat/Context/Ui/Shop/NewsletterContext.php @@ -1,5 +1,7 @@ newsletterPage = $newsletterPage; $this->customerRepository = $customerRepository; $this->customerFactory = $customerFactory; @@ -88,7 +89,7 @@ public function iSubscribeToIt() */ public function iShouldBeNotifiedThatIAmSubscribedToTheNewsletter() { - Assert::contains($this->newsletterPage->getContents(), "You are now subscribed to the newsletter"); + Assert::contains($this->newsletterPage->getContent(), 'You are now subscribed to the newsletter'); } /** @@ -127,7 +128,7 @@ public function thereIsNoCustomerWithEmail($email) */ public function iShouldBeNotifiedAboutInvalidEmailAddress() { - Assert::contains($this->newsletterPage->getContents(), 'The submitted email address is not valid'); + Assert::contains($this->newsletterPage->getContent(), 'The submitted email address is not valid'); } /** @@ -143,7 +144,7 @@ public function theFormTokenIsSetTo($token) */ public function iShouldBeNotifiedThatTheSubmittedCsrfTokenIsInvalid() { - Assert::contains($this->newsletterPage->getContents(), 'Submited CSRF token is invalid'); + Assert::contains($this->newsletterPage->getContent(), 'Submited CSRF token is invalid'); } /** @@ -151,7 +152,7 @@ public function iShouldBeNotifiedThatTheSubmittedCsrfTokenIsInvalid() */ public function iShouldBeNotifiedThatTheSubmittedEmailIsAlreadySubscribedToTheNewsletter() { - Assert::contains($this->newsletterPage->getContents(), "Given email address is already subscribed to the newsletter"); + Assert::contains($this->newsletterPage->getContent(), 'Given email address is already subscribed to the newsletter'); } /** @@ -183,7 +184,6 @@ public function theCustomerIsSubscribedToTheNewsletter($email) { /** @var CustomerInterface $customer */ $customer = $this->customerRepository->findOneBy(['email' => $email]); - Assert::isInstanceOf($customer, CustomerInterface::class); $customer->setSubscribedToNewsletter(true); $this->customerManager->flush(); $this->sharedStorage->set('newsletter_email', $customer->getEmail()); @@ -191,7 +191,8 @@ public function theCustomerIsSubscribedToTheNewsletter($email) /** * @param string $email - * @return null|object|CustomerInterface + * + * @return object|CustomerInterface|null */ private function getCustomerByEmail($email) { diff --git a/tests/Behat/Fake/AlwaysSuccessMailChimpClient.php b/tests/Behat/Fake/AlwaysSuccessMailChimpClient.php index 6616fa9..ccb8bbb 100644 --- a/tests/Behat/Fake/AlwaysSuccessMailChimpClient.php +++ b/tests/Behat/Fake/AlwaysSuccessMailChimpClient.php @@ -1,19 +1,19 @@ 'subscribed']; } - public function get($method, $args = array(), $timeout = self::TIMEOUT) + public function get($method, $args = [], $timeout = self::TIMEOUT) { return ['status' => 'subscribed']; } diff --git a/tests/Behat/Page/Shop/NewsletterPage.php b/tests/Behat/Page/Shop/NewsletterPage.php index 5c2f1b0..ad54a31 100644 --- a/tests/Behat/Page/Shop/NewsletterPage.php +++ b/tests/Behat/Page/Shop/NewsletterPage.php @@ -1,5 +1,7 @@ getDocument()->find('css','#newsletter-token')->setValue($token); + $this->getDocument()->find('css', '#newsletter-token')->setValue($token); } public function subscribe() { $this->getDocument()->pressButton('Subscribe'); } -} \ No newline at end of file +} diff --git a/tests/Behat/Page/Shop/NewsletterPageInterface.php b/tests/Behat/Page/Shop/NewsletterPageInterface.php index 584fbe1..f265ca5 100644 --- a/tests/Behat/Page/Shop/NewsletterPageInterface.php +++ b/tests/Behat/Page/Shop/NewsletterPageInterface.php @@ -1,5 +1,7 @@ getDocument()->uncheckField('Subscribe to the newsletter'); } -} \ No newline at end of file +} diff --git a/tests/Behat/Page/Shop/ProfileUpdatePageInterface.php b/tests/Behat/Page/Shop/ProfileUpdatePageInterface.php index 7e82b95..372296e 100644 --- a/tests/Behat/Page/Shop/ProfileUpdatePageInterface.php +++ b/tests/Behat/Page/Shop/ProfileUpdatePageInterface.php @@ -1,5 +1,7 @@