From 2f78ed3f9efcbd579bd33abe1746bfd4e482bb66 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 18 Apr 2017 10:29:10 +0200 Subject: [PATCH] merge project into demoshop. --- .travis.yml | 10 +- codeception.yml | 10 +- composer.json | 11 +- setup_test | 8 + .../Zed/Console/ConsoleDependencyProvider.php | 3 + .../Pyz/Zed/Transfer/TransferConfig.php | 11 +- tests/Acceptance.suite.yml | 8 + .../Customer/Yves/CustomerNewsletterCest.php | 9 + .../Discount/Zed/DiscountCreateCest.php | 64 --- .../Discount/Zed/DiscountListCest.php | 38 -- .../Zed/PageObject/DiscountCreatePage.php | 45 -- .../Discount/Zed/Tester/DiscountTester.php | 61 --- tests/Console.suite.yml | 6 + tests/Console/GenerateBundleCest.php | 27 ++ tests/Console/GenerateDataBuildersCest.php | 22 + tests/Console/_bootstrap.php | 1 + .../Shared/config_default-development.php | 99 ++++ .../Shared/config_default-development_DE.php | 85 ++++ .../config/Shared/config_default.php | 439 ++++++++++++++++++ .../config/Shared/config_local.dist.php | 4 + .../config/Shared/config_propel.php | 69 +++ .../config/Shared/console_env_local.php | 3 + .../config/Shared/default_store.php | 3 + .../cli_sandbox/config/Shared/stores.php | 41 ++ tests/_data/console_runner.php | 12 + tests/_support/ConsoleTester.php | 23 + tests/_support/Helper/Console.php | 55 +++ tests/_support/Module/Customer.php | 41 +- tests/_support/Module/Functional.php | 8 - 29 files changed, 967 insertions(+), 249 deletions(-) rename tests/Acceptance/Discount/Zed/PageObject/DiscountListPage.php => src/Pyz/Zed/Transfer/TransferConfig.php (51%) delete mode 100644 tests/Acceptance/Discount/Zed/DiscountCreateCest.php delete mode 100644 tests/Acceptance/Discount/Zed/DiscountListCest.php delete mode 100644 tests/Acceptance/Discount/Zed/PageObject/DiscountCreatePage.php delete mode 100644 tests/Acceptance/Discount/Zed/Tester/DiscountTester.php create mode 100644 tests/Console.suite.yml create mode 100644 tests/Console/GenerateBundleCest.php create mode 100644 tests/Console/GenerateDataBuildersCest.php create mode 100644 tests/Console/_bootstrap.php create mode 100644 tests/_data/cli_sandbox/config/Shared/config_default-development.php create mode 100644 tests/_data/cli_sandbox/config/Shared/config_default-development_DE.php create mode 100644 tests/_data/cli_sandbox/config/Shared/config_default.php create mode 100644 tests/_data/cli_sandbox/config/Shared/config_local.dist.php create mode 100644 tests/_data/cli_sandbox/config/Shared/config_propel.php create mode 100644 tests/_data/cli_sandbox/config/Shared/console_env_local.php create mode 100644 tests/_data/cli_sandbox/config/Shared/default_store.php create mode 100644 tests/_data/cli_sandbox/config/Shared/stores.php create mode 100644 tests/_data/console_runner.php create mode 100644 tests/_support/ConsoleTester.php create mode 100644 tests/_support/Helper/Console.php diff --git a/.travis.yml b/.travis.yml index a3dde22ad..85f6a21af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,15 +82,15 @@ before_script: - cp config/Shared/ci/travis/params_test_env.sh deploy/setup/params_test_env.sh - if [[ $TEST_GROUP == 'acceptance' ]]; then config/Shared/ci/travis/acceptance_env.sh; fi + - if [[ $TEST_GROUP == 'acceptance' ]]; then ./setup_test -f; fi + - if [[ $TEST_GROUP == 'without-acceptance' ]]; then ./setup_test -b; fi - vendor/bin/console twig:cache:warmer script: - - if [[ $TEST_GROUP == 'acceptance' ]]; then ./setup_test -f; fi - - if [[ $TEST_GROUP == 'without-acceptance' ]]; then ./setup_test -b; fi - - - if [[ $TEST_GROUP == 'without-acceptance' ]]; then vendor/bin/codecept run -x Acceptance ; fi - - if [[ $TEST_GROUP == 'acceptance' ]]; then vendor/bin/codecept run -g Acceptance ; fi + - vendor/bin/phantomjs --webdriver=4444 > /dev/null & + - if [[ $TEST_GROUP == 'without-acceptance' ]]; then vendor/bin/codecept run -x Acceptance -x Presentation -vvv ; fi + - if [[ $TEST_GROUP == 'acceptance' ]]; then vendor/bin/codecept run -g Acceptance -g Presentation ; fi - if [[ $TRAVIS_PHP_VERSION == 7.0 ]] ; then vendor/bin/console code:sniff ; fi diff --git a/codeception.yml b/codeception.yml index 56517e8c1..8c364d9b6 100644 --- a/codeception.yml +++ b/codeception.yml @@ -14,14 +14,6 @@ settings: memory_limit: 1024M log: true -modules: - config: - Db: - dsn: '' - user: '' - password: '' - dump: tests/_data/dump.sql - coverage: enabled: true remote: true @@ -33,4 +25,4 @@ extensions: - Codeception\Extension\Phantoman config: Codeception\Extension\Phantoman: - suites: ['Acceptance'] + suites: ['Acceptance', 'Presentation'] diff --git a/composer.json b/composer.json index 93fd6d89a..27863bfbd 100644 --- a/composer.json +++ b/composer.json @@ -163,7 +163,8 @@ "spryker/architecture-sniffer": "^0.3.0", "spryker/code-generator": "^0.2.0", "spryker/code-sniffer": "*", - "stecman/symfony-console-completion": "^0.7.0" + "stecman/symfony-console-completion": "^0.7.0", + "fzaninotto/faker": "^1.6" }, "autoload": { "psr-0": { @@ -171,9 +172,11 @@ "Unit": "tests", "YvesUnit": "tests", "Functional": "tests", - "Acceptance": "tests", - "Unit\\Spryker\\Shared\\Twig\\": "vendor/spryker/spryker/Bundles/Twig/tests" - } + "Acceptance": "tests" + }, + "files": [ + "vendor/spryker/spryker/autoload.php" + ] }, "autoload-dev": { "psr-4": { diff --git a/setup_test b/setup_test index 345c47b09..15fffede0 100755 --- a/setup_test +++ b/setup_test @@ -47,6 +47,14 @@ function backupTestingEnvData { $CONSOLE setup:install $VERBOSITY writeErrorMessage "Setup install failed" + labelText "Generate DataBuilders" + $CONSOLE transfer:databuilder:generate $VERBOSITY + writeErrorMessage "Generate DataBuilders failed" + + labelText "Running propel code generation/migrations" + $CONSOLE propel:diff $VERBOSITY + $CONSOLE propel:migrate $VERBOSITY + labelText "Importing Demo data" $CONSOLE import:demo-data $VERBOSITY writeErrorMessage "DemoData import failed" diff --git a/src/Pyz/Zed/Console/ConsoleDependencyProvider.php b/src/Pyz/Zed/Console/ConsoleDependencyProvider.php index 0516f1d89..0522e07b5 100644 --- a/src/Pyz/Zed/Console/ConsoleDependencyProvider.php +++ b/src/Pyz/Zed/Console/ConsoleDependencyProvider.php @@ -53,6 +53,7 @@ use Spryker\Zed\StateMachine\Communication\Console\CheckTimeoutConsole as StateMachineCheckTimeoutConsole; use Spryker\Zed\StateMachine\Communication\Console\ClearLocksConsole as StateMachineClearLocksConsole; use Spryker\Zed\Touch\Communication\Console\TouchCleanUpConsole; +use Spryker\Zed\Transfer\Communication\Console\DataBuilderGeneratorConsole; use Spryker\Zed\Transfer\Communication\Console\GeneratorConsole; use Spryker\Zed\Transfer\Communication\Console\ValidatorConsole; use Spryker\Zed\Twig\Communication\Console\CacheWarmerConsole; @@ -123,7 +124,9 @@ public function getConsoleCommands(Container $container) $commands[] = new GenerateYvesIdeAutoCompletionConsole(); $commands[] = new GenerateIdeAutoCompletionConsole(); $commands[] = new CacheWarmerConsole(); + $commands[] = new DataBuilderGeneratorConsole(); $commands[] = new CompletionCommand(); + $commands[] = new DataBuilderGeneratorConsole(); } return $commands; diff --git a/tests/Acceptance/Discount/Zed/PageObject/DiscountListPage.php b/src/Pyz/Zed/Transfer/TransferConfig.php similarity index 51% rename from tests/Acceptance/Discount/Zed/PageObject/DiscountListPage.php rename to src/Pyz/Zed/Transfer/TransferConfig.php index 373c07a0b..a97911e88 100644 --- a/tests/Acceptance/Discount/Zed/PageObject/DiscountListPage.php +++ b/src/Pyz/Zed/Transfer/TransferConfig.php @@ -5,13 +5,10 @@ * For full license information, please view the LICENSE file that was distributed with this source code. */ -namespace Acceptance\Discount\Zed\PageObject; +namespace Pyz\Zed\Transfer; -class DiscountListPage -{ - - const URL = '/discount/index/list'; - - const SELECTOR_DATA_TABLE = '.dataTables_wrapper'; +use Spryker\Zed\Transfer\TransferConfig as SprykerTransferConfig; +class TransferConfig extends SprykerTransferConfig +{ } diff --git a/tests/Acceptance.suite.yml b/tests/Acceptance.suite.yml index 3f5caa9ea..3a4f4f3b7 100644 --- a/tests/Acceptance.suite.yml +++ b/tests/Acceptance.suite.yml @@ -5,8 +5,16 @@ modules: url: '' browser: chrome window_size: 1920x1080 + + - \SprykerTest\Shared\Testify\Helper\Environment + - \SprykerTest\Shared\Propel\Helper\ConnectionHelper - \Application\Module\Yves - \Application\Module\Zed + - \SprykerTest\Shared\Testify\Helper\LocatorHelper + - \SprykerTest\Shared\Testify\Helper\DependencyHelper - \Module\Customer - Cli - Asserts + +coverage: + enabled: false diff --git a/tests/Acceptance/Customer/Yves/CustomerNewsletterCest.php b/tests/Acceptance/Customer/Yves/CustomerNewsletterCest.php index 1e7505534..87ae703d3 100644 --- a/tests/Acceptance/Customer/Yves/CustomerNewsletterCest.php +++ b/tests/Acceptance/Customer/Yves/CustomerNewsletterCest.php @@ -9,6 +9,9 @@ use Acceptance\Customer\Yves\PageObject\CustomerNewsletterPage; use Acceptance\Customer\Yves\Tester\CustomerLoginTester; +use Codeception\Util\Stub; +use Spryker\Zed\Newsletter\Dependency\Facade\NewsletterToMailInterface; +use Spryker\Zed\Newsletter\NewsletterDependencyProvider; /** * @group Acceptance @@ -28,6 +31,9 @@ public function testICanSubscribeNewsletter(CustomerLoginTester $i) { $i->amLoggedInCustomer(); $i->amOnPage(CustomerNewsletterPage::URL); + + $i->setDependency(NewsletterDependencyProvider::FACADE_MAIL, Stub::makeEmpty(NewsletterToMailInterface::class)); + $i->click(['name' => CustomerNewsletterPage::FORM_FIELD_SELECTOR_NEWSLETTER_SUBSCRIPTION]); $i->click(CustomerNewsletterPage::BUTTON_SUBMIT); $i->waitForText(CustomerNewsletterPage::SUCCESS_MESSAGE_SUBSCRIBED); @@ -41,6 +47,9 @@ public function testICanSubscribeNewsletter(CustomerLoginTester $i) public function testICanUnSubscribeNewsletter(CustomerLoginTester $i) { $i->amLoggedInCustomer(); + + $i->setDependency(NewsletterDependencyProvider::FACADE_MAIL, Stub::makeEmpty(NewsletterToMailInterface::class)); + $i->addNewsletterSubscription(CustomerNewsletterPage::NEW_CUSTOMER_EMAIL); $i->amOnPage(CustomerNewsletterPage::URL); $i->click(['name' => CustomerNewsletterPage::FORM_FIELD_SELECTOR_NEWSLETTER_SUBSCRIPTION]); diff --git a/tests/Acceptance/Discount/Zed/DiscountCreateCest.php b/tests/Acceptance/Discount/Zed/DiscountCreateCest.php deleted file mode 100644 index 60fd0091f..000000000 --- a/tests/Acceptance/Discount/Zed/DiscountCreateCest.php +++ /dev/null @@ -1,64 +0,0 @@ -wantTo('Create valid exclusive discount'); - $i->expect('Exclusive discount is successfully created'); - - $i->amLoggedInUser(); - - $i->amOnPage(DiscountCreatePage::URL); - $i->createDiscount(DiscountCreatePage::DISCOUNT_VALID_EXCLUSIVE); - - $i->see(DiscountCreatePage::MESSAGE_SUCCESSFUL_ALERT_CREATION); - -// $i->activateDiscountFromEditForm(); -// $i->see(DiscountCreatePage::MESSAGE_SUCCESSFUL_ALERT_ACTIVATION); - } - - /** - * @param \Acceptance\Discount\Zed\Tester\DiscountTester $i - * - * @return void - */ - public function testCreateNotExclusiveDiscountShouldShowSuccessMessage(DiscountTester $i) - { - $i->wantTo('Create valid not-exclusive discount'); - $i->expect('Not-exclusive discount is successfully created'); - - $i->amLoggedInUser(); - - $i->amOnPage(DiscountCreatePage::URL); - $i->createDiscount(DiscountCreatePage::DISCOUNT_VALID_NOT_EXCLUSIVE); - - $i->see(DiscountCreatePage::MESSAGE_SUCCESSFUL_ALERT_CREATION); - -// $i->activateDiscountFromEditForm(); -// $i->see(DiscountCreatePage::MESSAGE_SUCCESSFUL_ALERT_ACTIVATION); - } - -} diff --git a/tests/Acceptance/Discount/Zed/DiscountListCest.php b/tests/Acceptance/Discount/Zed/DiscountListCest.php deleted file mode 100644 index fb47e96c0..000000000 --- a/tests/Acceptance/Discount/Zed/DiscountListCest.php +++ /dev/null @@ -1,38 +0,0 @@ -wantTo('See a list of created discounts'); - $i->expect('A grid with discounts is shown'); - - $i->amLoggedInUser(); - - $i->amOnPage(DiscountListPage::URL); - $i->seeElement(DiscountListPage::SELECTOR_DATA_TABLE); - } - -} diff --git a/tests/Acceptance/Discount/Zed/PageObject/DiscountCreatePage.php b/tests/Acceptance/Discount/Zed/PageObject/DiscountCreatePage.php deleted file mode 100644 index fcd88c560..000000000 --- a/tests/Acceptance/Discount/Zed/PageObject/DiscountCreatePage.php +++ /dev/null @@ -1,45 +0,0 @@ - [ - 'type' => 'Cart rule', - 'name' => 'Exclusive Valid Discount', - 'description' => 'test test test', - 'excl' => '1', - 'calcType' => 'Calculator fixed', - 'amount' => '18,36', - 'applyTo' => 'attribute.width = \'15\'', - ], - self::DISCOUNT_VALID_NOT_EXCLUSIVE => [ - 'type' => 'Cart rule', - 'name' => 'Not Exclusive Valid Discount', - 'description' => 'test test test', - 'excl' => '0', - 'calcType' => 'Calculator fixed', - 'amount' => '18,36', - 'applyTo' => 'attribute.width = \'15\'', - ], - ]; - -} diff --git a/tests/Acceptance/Discount/Zed/Tester/DiscountTester.php b/tests/Acceptance/Discount/Zed/Tester/DiscountTester.php deleted file mode 100644 index f9c7c43b1..000000000 --- a/tests/Acceptance/Discount/Zed/Tester/DiscountTester.php +++ /dev/null @@ -1,61 +0,0 @@ -selectOption('#discount_discountGeneral_discount_type', DiscountCreatePage::$discountData[$discountName]['type']); - $i->fillField('#discount_discountGeneral_display_name', DiscountCreatePage::$discountData[$discountName]['name'] . ' ' . rand(1, 999)); - $i->fillField('#discount_discountGeneral_description', DiscountCreatePage::$discountData[$discountName]['description']); - $i->click('#discount_discountGeneral_is_exclusive_' . DiscountCreatePage::$discountData[$discountName]['excl']); - $i->fillField('#discount_discountGeneral_valid_from', $validFrom); - $i->fillField('#discount_discountGeneral_valid_to', $validTo); - - $i->click('//div[@class="tabs-container"]/ul/li[2]/a'); - $i->selectOption('#discount_discountCalculator_calculator_plugin', DiscountCreatePage::$discountData[$discountName]['calcType']); - $i->fillField('#discount_discountCalculator_amount', DiscountCreatePage::$discountData[$discountName]['amount']); - $i->click('#btn-calculation-get'); - $i->fillField('#discount_discountCalculator_collector_query_string', DiscountCreatePage::$discountData[$discountName]['applyTo']); - - $i->click('Conditions'); - $i->click('#btn-condition-get'); - $i->fillField('#discount_discountCondition_decision_rule_query_string', $applyWhen); - $i->click('#create-discount-button'); - } - - /** - * @return $this - */ - public function activateDiscountFromEditForm() - { - $i = $this; - $i->click('a.btn-sm:nth-child(1)'); - $i->wait(2); - - return $this; - } - -} diff --git a/tests/Console.suite.yml b/tests/Console.suite.yml new file mode 100644 index 000000000..54d59c54f --- /dev/null +++ b/tests/Console.suite.yml @@ -0,0 +1,6 @@ +class_name: ConsoleTester +modules: + enabled: + - Cli + - Filesystem + - \Helper\Console diff --git a/tests/Console/GenerateBundleCest.php b/tests/Console/GenerateBundleCest.php new file mode 100644 index 000000000..496a8dbdb --- /dev/null +++ b/tests/Console/GenerateBundleCest.php @@ -0,0 +1,27 @@ +runSprykerCommand('code:generate:bundle:zed Acme -vvv'); + $i->seeInShellOutput('Generated: Pyz/Zed/Acme/AcmeConfig.php'); + $i->seeInShellOutput('Generated: ZedBundleCodeGenerator'); + $bundleDir = codecept_data_dir() . Console::SANDBOX_DIR . 'src/Pyz/Zed/Acme'; + $i->seeFileFound('AcmeConfig.php', $bundleDir); + $i->seeFileFound('AcmeDependencyProvider.php', $bundleDir); + $i->seeFileFound('AcmeFacade.php', $bundleDir . '/Business'); + } + +} diff --git a/tests/Console/GenerateDataBuildersCest.php b/tests/Console/GenerateDataBuildersCest.php new file mode 100644 index 000000000..63e1bafa0 --- /dev/null +++ b/tests/Console/GenerateDataBuildersCest.php @@ -0,0 +1,22 @@ +runSprykerCommand('transfer:databuilder:generate -vvv'); + $i->seeInShellOutput('CustomerBuilder.php was generated'); + $i->seeFileFound(codecept_data_dir() . 'cli_sandbox/src/Generated/Shared/DataBuilder/CustomerBuilder.php'); + } + +} diff --git a/tests/Console/_bootstrap.php b/tests/Console/_bootstrap.php new file mode 100644 index 000000000..b3d9bbc7f --- /dev/null +++ b/tests/Console/_bootstrap.php @@ -0,0 +1 @@ + 'UTF-8', + PayoneConstants::PAYONE_CREDENTIALS_KEY => '', + PayoneConstants::PAYONE_CREDENTIALS_MID => '', + PayoneConstants::PAYONE_CREDENTIALS_AID => '', + PayoneConstants::PAYONE_CREDENTIALS_PORTAL_ID => '', + PayoneConstants::PAYONE_PAYMENT_GATEWAY_URL => 'https://api.pay1.de/post-gateway/', + PayoneConstants::PAYONE_REDIRECT_SUCCESS_URL => $config[ApplicationConstants::HOST_YVES] . '/checkout/success/', + PayoneConstants::PAYONE_REDIRECT_ERROR_URL => $config[ApplicationConstants::HOST_YVES] . '/checkout/index/', + PayoneConstants::PAYONE_REDIRECT_BACK_URL => $config[ApplicationConstants::HOST_YVES] . '/checkout/regular-redirect-payment-cancellation/', + PayoneConstants::PAYONE_MODE => '', +]; + +$config[TwigConstants::ZED_TWIG_OPTIONS] = [ + 'cache' => APPLICATION_ROOT_DIR . '/data/' . Store::getInstance()->getStoreName() . '/cache/Yves/twig', +]; + +$config[TwigConstants::YVES_TWIG_OPTIONS] = [ + 'cache' => APPLICATION_ROOT_DIR . '/data/' . Store::getInstance()->getStoreName() . '/cache/Yves/twig', +]; + +$config[ZedNavigationConstants::ZED_NAVIGATION_CACHE_ENABLED] = true; + +$config[AclConstants::ACL_USER_RULE_WHITELIST][] = [ + 'bundle' => 'wdt', + 'controller' => '*', + 'action' => '*', + 'type' => 'allow', +]; + +$config[PropelConstants::PROPEL_DEBUG] = true; +$config[PropelConstants::PROPEL_SHOW_EXTENDED_EXCEPTION] = true; + +$config[ErrorHandlerConstants::DISPLAY_ERRORS] = true; +$config[ErrorHandlerConstants::ERROR_RENDERER] = WebExceptionErrorRenderer::class; + +$config[ApplicationConstants::ENABLE_APPLICATION_DEBUG] = true; +$config[ZedRequestConstants::SET_REPEAT_DATA] = true; +$config[KernelConstants::STORE_PREFIX] = 'DEV'; + +$config[ApplicationConstants::ENABLE_WEB_PROFILER] = true; +$config[KernelConstants::AUTO_LOADER_UNRESOLVABLE_CACHE_ENABLED] = false; + +$config[KernelConstants::SPRYKER_ROOT] = APPLICATION_ROOT_DIR . '/vendor/spryker/spryker/Bundles'; + +$config[EventJournalConstants::LOCK_OPTIONS][EventJournalConstants::NO_LOCK] = true; + +$config[LogConstants::LOG_LEVEL] = \Monolog\Logger::INFO; + +$config[TwigConstants::YVES_PATH_CACHE_FILE] = APPLICATION_ROOT_DIR . '/data/' . Store::getInstance()->getStoreName() . '/' . APPLICATION_ENV . '/cache/Yves/twig/.pathCache'; +$config[TwigConstants::ZED_PATH_CACHE_FILE] = APPLICATION_ROOT_DIR . '/data/' . Store::getInstance()->getStoreName() . '/' . APPLICATION_ENV . '/cache/Zed/twig/.pathCache'; diff --git a/tests/_data/cli_sandbox/config/Shared/config_default-development_DE.php b/tests/_data/cli_sandbox/config/Shared/config_default-development_DE.php new file mode 100644 index 000000000..d4229f3b6 --- /dev/null +++ b/tests/_data/cli_sandbox/config/Shared/config_default-development_DE.php @@ -0,0 +1,85 @@ + ['log_path' => APPLICATION_ROOT_DIR . '/data/DE/logs/'], +]; diff --git a/tests/_data/cli_sandbox/config/Shared/config_default.php b/tests/_data/cli_sandbox/config/Shared/config_default.php new file mode 100644 index 000000000..525201770 --- /dev/null +++ b/tests/_data/cli_sandbox/config/Shared/config_default.php @@ -0,0 +1,439 @@ + APPLICATION_ROOT_DIR . '/data/' . Store::getInstance()->getStoreName() . '/cache/Zed/twig', +]; + +$config[TwigConstants::YVES_TWIG_OPTIONS] = [ + 'cache' => APPLICATION_ROOT_DIR . '/data/' . Store::getInstance()->getStoreName() . '/cache/Yves/twig', +]; + +$config[TwigConstants::YVES_PATH_CACHE_FILE] = APPLICATION_ROOT_DIR . '/data/' . Store::getInstance()->getStoreName() . '/cache/Yves/twig/.pathCache'; +$config[TwigConstants::ZED_PATH_CACHE_FILE] = APPLICATION_ROOT_DIR . '/data/' . Store::getInstance()->getStoreName() . '/cache/Zed/twig/.pathCache'; + +$config[PropelConstants::ZED_DB_ENGINE_MYSQL] = PropelConfig::DB_ENGINE_MYSQL; +$config[PropelConstants::ZED_DB_ENGINE_PGSQL] = PropelConfig::DB_ENGINE_PGSQL; +$config[PropelConstants::ZED_DB_SUPPORTED_ENGINES] = [ + PropelConfig::DB_ENGINE_MYSQL => 'MySql', + PropelConfig::DB_ENGINE_PGSQL => 'PostgreSql', +]; + +/** + * Elasticsearch settings + */ +$config[ApplicationConstants::ELASTICA_PARAMETER__HOST] + = $config[SearchConstants::ELASTICA_PARAMETER__HOST] + = 'localhost'; +$config[ApplicationConstants::ELASTICA_PARAMETER__TRANSPORT] + = $config[SearchConstants::ELASTICA_PARAMETER__TRANSPORT] + = 'http'; +$config[ApplicationConstants::ELASTICA_PARAMETER__PORT] + = $config[SearchConstants::ELASTICA_PARAMETER__PORT] + = '10005'; +$config[ApplicationConstants::ELASTICA_PARAMETER__AUTH_HEADER] + = $config[SearchConstants::ELASTICA_PARAMETER__AUTH_HEADER] + = ''; +$config[ApplicationConstants::ELASTICA_PARAMETER__INDEX_NAME] + = $config[CollectorConstants::ELASTICA_PARAMETER__INDEX_NAME] + = $config[SearchConstants::ELASTICA_PARAMETER__INDEX_NAME] + = null; // Store related config +$config[ApplicationConstants::ELASTICA_PARAMETER__DOCUMENT_TYPE] + = $config[CollectorConstants::ELASTICA_PARAMETER__DOCUMENT_TYPE] + = $config[SearchConstants::ELASTICA_PARAMETER__DOCUMENT_TYPE] + = 'page'; + +/** + * Page search settings + */ +$config[SearchConstants::FULL_TEXT_BOOSTED_BOOSTING_VALUE] = 3; +$config[SearchConstants::SEARCH_INDEX_NAME_SUFFIX] = ''; + +/** + * Hostname(s) for Yves - Shop frontend + * In production you probably use a CDN for static content + */ +$config[ApplicationConstants::HOST_YVES] + = $config[ProductManagementConstants::HOST_YVES] + = $config[PayoneConstants::HOST_YVES] + = $config[PayolutionConstants::HOST_YVES] + = $config[NewsletterConstants::HOST_YVES] + = $config[CustomerConstants::HOST_YVES] + = $config[ApplicationConstants::HOST_STATIC_ASSETS] + = $config[ApplicationConstants::HOST_STATIC_MEDIA] + = $config[ApplicationConstants::HOST_SSL_YVES] + = $config[ApplicationConstants::HOST_SSL_STATIC_ASSETS] + = $config[ApplicationConstants::HOST_SSL_STATIC_MEDIA] + = 'www.de.project.local'; + +/** + * Hostname(s) for Zed - Shop frontend + * In production you probably use HTTPS for Zed + */ +$config[ApplicationConstants::HOST_ZED_GUI] + = $config[ApplicationConstants::HOST_ZED_API] + = $config[ApplicationConstants::HOST_SSL_ZED_GUI] + = $config[ApplicationConstants::HOST_SSL_ZED_API] + = 'zed.de.project.local'; + +$config[ApplicationConstants::YVES_TRUSTED_HOSTS] = []; + +$config[ApplicationConstants::ZED_HTTP_STRICT_TRANSPORT_SECURITY_ENABLED] = + $config[ApplicationConstants::YVES_HTTP_STRICT_TRANSPORT_SECURITY_ENABLED] = false; + +$config[ApplicationConstants::ZED_HTTP_STRICT_TRANSPORT_SECURITY_CONFIG] = + $config[ApplicationConstants::YVES_HTTP_STRICT_TRANSPORT_SECURITY_CONFIG] = [ + 'max_age' => 31536000, + 'include_sub_domains' => true, + 'preload' => true, + ]; + +$config[LogConstants::LOG_LEVEL] = Logger::INFO; + +$config[ZedRequestConstants::TRANSFER_USERNAME] = 'yves'; +$config[ZedRequestConstants::TRANSFER_PASSWORD] = 'o7&bg=Fz;nSslHBC'; + +$config[ZedRequestConstants::TRANSFER_DEBUG_SESSION_FORWARD_ENABLED] = false; +$config[ZedRequestConstants::TRANSFER_DEBUG_SESSION_NAME] = 'XDEBUG_SESSION'; + +$config[KernelConstants::SPRYKER_ROOT] = APPLICATION_ROOT_DIR . '/vendor/spryker/spryker/Bundles'; + +$config[StorageConstants::STORAGE_KV_SOURCE] = 'redis'; +$config[StorageConstants::STORAGE_PERSISTENT_CONNECTION] = true; + +$config[SessionConstants::YVES_SESSION_SAVE_HANDLER] = SessionConstants::SESSION_HANDLER_REDIS_LOCKING; +$config[SessionConstants::YVES_SESSION_TIME_TO_LIVE] = SessionConstants::SESSION_LIFETIME_1_HOUR; +$config[SessionConstants::YVES_SESSION_FILE_PATH] = session_save_path(); +$config[SessionConstants::YVES_SESSION_COOKIE_NAME] = $config[ApplicationConstants::HOST_YVES]; +$config[SessionConstants::YVES_SESSION_COOKIE_DOMAIN] = $config[ApplicationConstants::HOST_YVES]; +$config[SessionConstants::YVES_SESSION_PERSISTENT_CONNECTION] = $config[StorageConstants::STORAGE_PERSISTENT_CONNECTION]; + +$config[SessionConstants::ZED_SESSION_SAVE_HANDLER] = SessionConstants::SESSION_HANDLER_REDIS; +$config[SessionConstants::ZED_SESSION_TIME_TO_LIVE] = SessionConstants::SESSION_LIFETIME_1_HOUR; +$config[SessionConstants::ZED_SESSION_FILE_PATH] = session_save_path(); +$config[SessionConstants::ZED_SESSION_COOKIE_NAME] = $config[ApplicationConstants::HOST_ZED_GUI]; +$config[SessionConstants::ZED_SESSION_PERSISTENT_CONNECTION] = $config[StorageConstants::STORAGE_PERSISTENT_CONNECTION]; + +$config[SessionConstants::SESSION_HANDLER_REDIS_LOCKING_TIMEOUT_MILLISECONDS] = 0; +$config[SessionConstants::SESSION_HANDLER_REDIS_LOCKING_RETRY_DELAY_MICROSECONDS] = 0; +$config[SessionConstants::SESSION_HANDLER_REDIS_LOCKING_LOCK_TTL_MILLISECONDS] = 0; + +$config[ApplicationConstants::ZED_SSL_ENABLED] = false; +$config[ZedRequestConstants::ZED_API_SSL_ENABLED] = false; +$config[ApplicationConstants::ZED_SSL_EXCLUDED] = ['heartbeat/index']; + +$config[TwigConstants::YVES_THEME] + = $config[CmsConstants::YVES_THEME] = 'default'; + +$config[ApplicationConstants::YVES_TRUSTED_PROXIES] = []; +$config[ApplicationConstants::YVES_SSL_ENABLED] = false; +$config[ApplicationConstants::YVES_COMPLETE_SSL_ENABLED] = false; +$config[ApplicationConstants::YVES_SSL_EXCLUDED] = [ + 'heartbeat' => '/heartbeat', +]; + +$config[ErrorHandlerConstants::YVES_ERROR_PAGE] = APPLICATION_ROOT_DIR . '/public/Yves/errorpage/error.html'; +$config[ErrorHandlerConstants::ZED_ERROR_PAGE] = APPLICATION_ROOT_DIR . '/public/Yves/errorpage/error.html'; +$config[ErrorHandlerConstants::ERROR_RENDERER] = WebHtmlErrorRenderer::class; + +$config[SessionConstants::YVES_SESSION_COOKIE_DOMAIN] = $config[ApplicationConstants::HOST_YVES]; +$config[ApplicationConstants::YVES_COOKIE_DEVICE_ID_NAME] = 'did'; +$config[ApplicationConstants::YVES_COOKIE_DEVICE_ID_VALID_FOR] = '+5 year'; +$config[ApplicationConstants::YVES_COOKIE_VISITOR_ID_NAME] = 'vid'; +$config[ApplicationConstants::YVES_COOKIE_VISITOR_ID_VALID_FOR] = '+30 minute'; + +$config[CustomerConstants::CUSTOMER_SECURED_PATTERN] = '(^/login_check$|^/customer|^/wishlist)'; +$config[CustomerConstants::CUSTOMER_ANONYMOUS_PATTERN] = '^/.*'; + +$currentStore = Store::getInstance()->getStoreName(); + +$config[ApplicationConstants::CLOUD_ENABLED] = false; +$config[ApplicationConstants::CLOUD_OBJECT_STORAGE_ENABLED] = false; +$config[ApplicationConstants::CLOUD_CDN_ENABLED] = false; +$config[ApplicationConstants::CLOUD_CDN_STATIC_MEDIA_PREFIX] = 'media'; +$config[ApplicationConstants::CLOUD_CDN_STATIC_MEDIA_HTTP] = ''; +$config[ApplicationConstants::CLOUD_CDN_STATIC_MEDIA_HTTPS] = ''; +$config[ApplicationConstants::CLOUD_CDN_PRODUCT_IMAGES_PATH_NAME] = '/images/products/'; + +$config[PriceConstants::DEFAULT_PRICE_TYPE] = + $config[PriceCartConnectorConstants::DEFAULT_PRICE_TYPE] = 'DEFAULT'; + +$config[UserConstants::USER_SYSTEM_USERS] = [ + 'yves_system', +]; + +/** For a better performance you can turn off Zed authentication */ +$config[AuthConstants::AUTH_ZED_ENABLED] + = $config[ZedRequestConstants::AUTH_ZED_ENABLED] = true; + +$config[AuthConstants::AUTH_DEFAULT_CREDENTIALS] = [ + 'yves_system' => [ + 'rules' => [ + [ + 'bundle' => '*', + 'controller' => 'gateway', + 'action' => '*', + ], + ], + 'token' => 'JDJ5JDEwJFE0cXBwYnVVTTV6YVZXSnVmM2l1UWVhRE94WkQ4UjBUeHBEWTNHZlFRTEd4U2F6QVBqejQ2', // Please replace this token for your project + ], +]; + +/** + * ACL: Allow or disallow of urls for Zed Admin GUI for ALL users + */ +$config[AclConstants::ACL_DEFAULT_RULES] = [ + [ + 'bundle' => 'auth', + 'controller' => 'login', + 'action' => 'index', + 'type' => 'allow', + ], + [ + 'bundle' => 'auth', + 'controller' => 'login', + 'action' => 'check', + 'type' => 'allow', + ], + [ + 'bundle' => 'auth', + 'controller' => 'password', + 'action' => 'reset', + 'type' => 'allow', + ], + [ + 'bundle' => 'auth', + 'controller' => 'password', + 'action' => 'reset-request', + 'type' => 'allow', + ], + [ + 'bundle' => 'acl', + 'controller' => 'index', + 'action' => 'denied', + 'type' => 'allow', + ], + [ + 'bundle' => 'heartbeat', + 'controller' => 'index', + 'action' => 'index', + 'type' => 'allow', + ], +]; + +/** + * ACL: Allow or disallow of urls for Zed Admin GUI + */ +$config[AclConstants::ACL_USER_RULE_WHITELIST] = [ + [ + 'bundle' => 'application', + 'controller' => '*', + 'action' => '*', + 'type' => 'allow', + ], + [ + 'bundle' => 'auth', + 'controller' => '*', + 'action' => '*', + 'type' => 'allow', + ], + [ + 'bundle' => 'heartbeat', + 'controller' => 'heartbeat', + 'action' => 'index', + 'type' => 'allow', + ], +]; + +/** + * ACL: Special rules for specific users + */ +$config[AclConstants::ACL_DEFAULT_CREDENTIALS] = [ + 'yves_system' => [ + 'rules' => [ + [ + 'bundle' => '*', + 'controller' => 'gateway', + 'action' => '*', + 'type' => 'allow', + ], + ], + ], +]; + +/** + * Zed Navigation Cache + * The cache should always be activated. Refresh/build with CLI command: + * vendor/bin/console application:build-navigation-cache + */ +$config[ZedNavigationConstants::ZED_NAVIGATION_CACHE_ENABLED] = true; + +$config[EventJournalConstants::COLLECTORS]['YVES'] = [ + '\\Spryker\\Shared\\EventJournal\\Model\\Collector\\ServerDataCollector', + '\\Spryker\\Shared\\EventJournal\\Model\\Collector\\RequestDataCollector', + '\\Spryker\\Shared\\EventJournal\\Model\\Collector\\EnvironmentDataCollector', + '\\Pyz\\Yves\\EventJournal\\Collector\\YvesDataCollector', +]; +$config[EventJournalConstants::LOCK_OPTIONS][EventJournalConstants::NO_LOCK] = false; +$config[EventJournalConstants::WRITERS]['YVES'] = [ + '\\Spryker\\Shared\\EventJournal\\Model\\Writer\\File', +]; + +$config[EventJournalConstants::COLLECTORS]['ZED'] = [ + '\\Spryker\\Shared\\EventJournal\\Model\\Collector\\ServerDataCollector', + '\\Spryker\\Shared\\EventJournal\\Model\\Collector\\RequestDataCollector', + '\\Spryker\\Shared\\EventJournal\\Model\\Collector\\EnvironmentDataCollector', +]; +$config[EventJournalConstants::WRITERS]['ZED'] = [ + '\\Spryker\\Shared\\EventJournal\\Model\\Writer\\File', +]; + +$config[EventJournalConstants::FILTERS]['ZED'] = [ + '\\Spryker\\Shared\\EventJournal\\Model\\Filter\\RecursiveFieldFilter', +]; + +$config[EventJournalConstants::FILTERS]['YVES'] = [ + '\\Spryker\\Shared\\EventJournal\\Model\\Filter\\RecursiveFieldFilter', +]; + +$config[EventJournalConstants::FILTER_OPTIONS] = [ + '\\Spryker\\Shared\\EventJournal\\Model\\Filter\\RecursiveFieldFilter' => [ + 'filter_pattern' => [ + ['registerForm', 'password', 'first'], + ['registerForm', 'password', 'second'], + ['_password'], + ['transfer_data', 'login', 'password'], + ], + 'filtered_string' => '***', + ], +]; + +$config[EventJournalConstants::WRITER_OPTIONS] = [ + '\\Spryker\\Shared\\EventJournal\\Model\\Writer\\File' => [ + 'log_path' => APPLICATION_ROOT_DIR . '/data/DE/logs/', + ], +]; + +$config[SequenceNumberConstants::ENVIRONMENT_PREFIX] + = $config[SalesConstants::ENVIRONMENT_PREFIX] + = ''; + +$config[NewRelicConstants::NEWRELIC_API_KEY] = null; + +$config[LogConstants::LOG_FILE_PATH] = APPLICATION_ROOT_DIR . '/data/DE/logs/application.log'; + +// Due to some deprecation notices we silence all deprecations for the time being +$config[ErrorHandlerConstants::ERROR_LEVEL] = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED; + +// To only log e.g. deprecations instead of throwing exceptions here use +//$config[ErrorHandlerConstants::ERROR_LEVEL] = E_ALL +//$config[ErrorHandlerConstants::ERROR_LEVEL_LOG_ONLY] = E_DEPRECATED | E_USER_DEPRECATED; + +$config[KernelConstants::AUTO_LOADER_CACHE_FILE_NO_LOCK] = false; +$config[KernelConstants::AUTO_LOADER_UNRESOLVABLE_CACHE_ENABLED] = false; +$config[KernelConstants::AUTO_LOADER_UNRESOLVABLE_CACHE_PROVIDER] = \Spryker\Shared\Kernel\ClassResolver\Cache\Provider\File::class; +$config[ApplicationConstants::ENABLE_WEB_PROFILER] = false; + +$config[PropelConstants::ZED_DB_ENGINE_MYSQL] = PropelConfig::DB_ENGINE_MYSQL; +$config[PropelConstants::ZED_DB_ENGINE_PGSQL] = PropelConfig::DB_ENGINE_PGSQL; +$config[PropelConstants::ZED_DB_SUPPORTED_ENGINES] = [ + PropelConfig::DB_ENGINE_MYSQL => 'MySql', + PropelConfig::DB_ENGINE_PGSQL => 'PostgreSql', +]; +$config[PropelConstants::SCHEMA_FILE_PATH_PATTERN] = APPLICATION_VENDOR_DIR . '/*/*/src/*/Zed/*/Persistence/Propel/Schema/'; +$config[PropelConstants::USE_SUDO_TO_MANAGE_DATABASE] = true; + +$config[KernelConstants::DEPENDENCY_INJECTOR_YVES] = [ + 'Checkout' => [ + 'DummyPayment', + ], +]; + +$config[KernelConstants::DEPENDENCY_INJECTOR_ZED] = [ + 'Payment' => [ + 'DummyPayment', + ], + 'Oms' => [ + 'DummyPayment', + ], +]; + +$config[OmsConstants::PROCESS_LOCATION] = [ + OmsConfig::DEFAULT_PROCESS_LOCATION, + $config[KernelConstants::SPRYKER_ROOT] . '/DummyPayment/config/Zed/Oms', +]; + +$config[OmsConstants::ACTIVE_PROCESSES] = [ + 'DummyPayment01', +]; + +$config[SalesConstants::PAYMENT_METHOD_STATEMACHINE_MAPPING] = [ + DummyPaymentConfig::PAYMENT_METHOD_INVOICE => 'DummyPayment01', + DummyPaymentConfig::PAYMENT_METHOD_CREDIT_CARD => 'DummyPayment01', +]; + +$config[TaxConstants::DEFAULT_TAX_RATE] = 19; + +$config[QueueConstants::QUEUE_SERVER_ID] = (gethostname()) ?: php_uname('n'); +$config[QueueConstants::QUEUE_WORKER_INTERVAL_MILLISECONDS] = 10000; +$config[QueueConstants::QUEUE_WORKER_MAX_THRESHOLD_SECONDS] = 59; + +/* + * Queues can have different adapters and maximum worker number + * QUEUE_ADAPTER_CONFIGURATION can have the array like this as an example: + * + * 'mailQueue' => [ + * QueueConfig::CONFIG_QUEUE_ADAPTER => \Spryker\Client\RabbitMq\Model\RabbitMqAdapter::class, + * QueueConfig::CONFIG_MAX_WORKER_NUMBER => 5 + * ], + * + */ +$config[QueueConstants::QUEUE_ADAPTER_CONFIGURATION] = []; diff --git a/tests/_data/cli_sandbox/config/Shared/config_local.dist.php b/tests/_data/cli_sandbox/config/Shared/config_local.dist.php new file mode 100644 index 000000000..ea6fc4e8d --- /dev/null +++ b/tests/_data/cli_sandbox/config/Shared/config_local.dist.php @@ -0,0 +1,4 @@ +getStoreName(); + +$dsn = sprintf( + '%s:host=%s;port=%d;dbname=%s', + $config[PropelConstants::ZED_DB_ENGINE], + $config[PropelConstants::ZED_DB_HOST], + $config[PropelConstants::ZED_DB_PORT], + $config[PropelConstants::ZED_DB_DATABASE] +); + +$connections = [ + 'pgsql' => [ + 'adapter' => PropelConfig::DB_ENGINE_PGSQL, + 'dsn' => $dsn, + 'user' => $config[PropelConstants::ZED_DB_USERNAME], + 'password' => $config[PropelConstants::ZED_DB_PASSWORD], + 'settings' => [], + ], + 'mysql' => [ + 'adapter' => PropelConfig::DB_ENGINE_MYSQL, + 'dsn' => $dsn, + 'user' => $config[PropelConstants::ZED_DB_USERNAME], + 'password' => $config[PropelConstants::ZED_DB_PASSWORD], + 'settings' => [ + 'charset' => 'utf8', + 'queries' => [ + 'utf8' => 'SET NAMES utf8 COLLATE utf8_unicode_ci, COLLATION_CONNECTION = utf8_unicode_ci, COLLATION_DATABASE = utf8_unicode_ci, COLLATION_SERVER = utf8_unicode_ci', + ], + ], + ], +]; + +$config[PropelConstants::PROPEL] = [ + 'database' => [ + 'connections' => [], + ], + 'runtime' => [ + 'defaultConnection' => 'default', + 'connections' => ['default', 'zed'], + ], + 'generator' => [ + 'defaultConnection' => 'default', + 'connections' => ['default', 'zed'], + 'objectModel' => [ + 'defaultKeyType' => 'fieldName', + 'builders' => [ + 'object' => '\Spryker\Zed\Propel\Business\Builder\ObjectBuilder', + 'query' => '\Spryker\Zed\Propel\Business\Builder\QueryBuilder', + ], + ], + ], + 'paths' => [ + 'phpDir' => APPLICATION_ROOT_DIR, + 'sqlDir' => APPLICATION_ROOT_DIR . '/src/Orm/Propel/' . $currentStore . '/Sql', + 'migrationDir' => APPLICATION_ROOT_DIR . '/src/Orm/Propel/' . $currentStore . '/Migration_' . $config[PropelConstants::ZED_DB_ENGINE], + 'schemaDir' => APPLICATION_ROOT_DIR . '/src/Orm/Propel/' . $currentStore . '/Schema', + 'phpConfDir' => APPLICATION_ROOT_DIR . '/src/Orm/Propel/' . $currentStore . '/Config/' . APPLICATION_ENV . '/', + ], +]; + +$engine = $config[PropelConstants::ZED_DB_ENGINE]; +$config[PropelConstants::PROPEL]['database']['connections']['default'] = $connections[$engine]; +$config[PropelConstants::PROPEL]['database']['connections']['zed'] = $connections[$engine]; diff --git a/tests/_data/cli_sandbox/config/Shared/console_env_local.php b/tests/_data/cli_sandbox/config/Shared/console_env_local.php new file mode 100644 index 000000000..9534eb589 --- /dev/null +++ b/tests/_data/cli_sandbox/config/Shared/console_env_local.php @@ -0,0 +1,3 @@ + [ + // shared settings for all contexts + '*' => [ + 'timezone' => 'Europe/Berlin', + 'dateFormat' => [ + // short date (01.02.12) + 'short' => 'd/m/Y', + // medium Date (01. Feb 2012) + 'medium' => 'd. M Y', + // date formatted as described in RFC 2822 + 'rfc' => 'r', + 'datetime' => 'Y-m-d H:i:s', + ], + ], + // settings for contexts (overwrite shared) + 'yves' => [], + 'zed' => [ + 'dateFormat' => [ + // short date (2012-12-28) + 'short' => 'Y-m-d', + ], + ], + ], + 'locales' => [ + // first entry is default + 'en' => 'en_US', + 'de' => 'de_DE', + ], + // first entry is default + 'countries' => ['DE', 'AT'], + // internal and shop + 'currencyIsoCode' => 'EUR', +]; + +return $stores; diff --git a/tests/_data/console_runner.php b/tests/_data/console_runner.php new file mode 100644 index 000000000..b83078813 --- /dev/null +++ b/tests/_data/console_runner.php @@ -0,0 +1,12 @@ +run(); diff --git a/tests/_support/ConsoleTester.php b/tests/_support/ConsoleTester.php new file mode 100644 index 000000000..e900db555 --- /dev/null +++ b/tests/_support/ConsoleTester.php @@ -0,0 +1,23 @@ + ['data', 'src'], + ]; + + /** + * @param \Codeception\TestInterface $test + * + * @return void + */ + public function _after(TestInterface $test) + { + foreach ($this->config['cleanup_dirs'] as $dir) { + $dir = codecept_data_dir() . self::SANDBOX_DIR . $dir; + $this->debugSection('Cleanup', $dir); + FileSystem::deleteDir($dir); + } + } + + /** + * @param string $command + * + * @return void + */ + public function runSprykerCommand($command) + { + $command = 'php ' . codecept_data_dir() . self::RUNNER . " $command"; + $this->getCli()->runShellCommand($command); + } + + /** + * @return \Codeception\Module\Cli|\Codeception\Module + */ + protected function getCli() + { + return $this->getModule('Cli'); + } + +} diff --git a/tests/_support/Module/Customer.php b/tests/_support/Module/Customer.php index 2183b80e6..d65dedd33 100644 --- a/tests/_support/Module/Customer.php +++ b/tests/_support/Module/Customer.php @@ -11,7 +11,8 @@ use Acceptance\Customer\Yves\PageObject\Customer as PageObjectCustomer; use Acceptance\Customer\Yves\PageObject\CustomerLoginPage; use Codeception\Module; -use Codeception\TestCase; +use Codeception\TestInterface; +use Codeception\Util\Stub; use Generated\Shared\Transfer\NewsletterSubscriberTransfer; use Generated\Shared\Transfer\NewsletterSubscriptionRequestTransfer; use Generated\Shared\Transfer\NewsletterTypeTransfer; @@ -20,20 +21,27 @@ use Orm\Zed\Customer\Persistence\SpyCustomerAddress; use Orm\Zed\Customer\Persistence\SpyCustomerQuery; use Pyz\Shared\Newsletter\NewsletterConstants; +use SprykerTest\Shared\Testify\Helper\DependencyHelperTrait; +use SprykerTest\Shared\Testify\Helper\LocatorHelperTrait; use Spryker\Client\Session\SessionClient; -use Spryker\Zed\Customer\Business\CustomerFacade; +use Spryker\Zed\Customer\CustomerDependencyProvider; +use Spryker\Zed\Customer\Dependency\Facade\CustomerToMailBridge; +use Spryker\Zed\Mail\Business\MailFacadeInterface; use Spryker\Zed\Newsletter\Business\NewsletterFacade; use Symfony\Component\HttpFoundation\Session\Session; class Customer extends Module { + use DependencyHelperTrait; + use LocatorHelperTrait; + /** - * @param \Codeception\TestCase $step + * @param \Codeception\TestInterface $step * * @return void */ - public function _before(TestCase $step) + public function _before(TestInterface $step) { $this->cleanUpDatabase(); } @@ -129,8 +137,25 @@ public function haveRegisteredCustomer($email) $customerTransfer = PageObjectCustomer::getCustomerData($email); - $customerFacade = new CustomerFacade(); - $customerFacade->registerCustomer($customerTransfer); + $mailMock = new CustomerToMailBridge($this->getMailMock()); + $this->setDependency(CustomerDependencyProvider::FACADE_MAIL, $mailMock); + $this->getFacade()->registerCustomer($customerTransfer); + } + + /** + * @return \Spryker\Zed\Customer\Business\CustomerFacadeInterface + */ + private function getFacade() + { + return $this->getLocator()->customer()->facade(); + } + + /** + * @return object|\Spryker\Zed\Mail\Business\MailFacadeInterface + */ + private function getMailMock() + { + return Stub::makeEmpty(MailFacadeInterface::class); } /** @@ -196,10 +221,10 @@ public function addNewsletterSubscription($email, $type = NewsletterConstants::E public function amLoggedInCustomer($email = PageObjectCustomer::NEW_CUSTOMER_EMAIL) { $this->haveRegisteredCustomer($email); + $customerTransfer = PageObjectCustomer::getCustomerData($email); $i = $this->getWebDriver(); $i->amOnPage(CustomerLoginPage::URL); - $customerTransfer = PageObjectCustomer::getCustomerData($email); $i->submitForm(['name' => 'loginForm'], [ CustomerLoginPage::FORM_FIELD_SELECTOR_EMAIL => $customerTransfer->getEmail(), CustomerLoginPage::FORM_FIELD_SELECTOR_PASSWORD => $customerTransfer->getPassword(), @@ -209,7 +234,7 @@ public function amLoggedInCustomer($email = PageObjectCustomer::NEW_CUSTOMER_EMA } /** - * @return \Codeception\Module\WebDriver + * @return \Codeception\Module|\Codeception\Module\WebDriver */ protected function getWebDriver() { diff --git a/tests/_support/Module/Functional.php b/tests/_support/Module/Functional.php index 8cf926b73..d9694c510 100644 --- a/tests/_support/Module/Functional.php +++ b/tests/_support/Module/Functional.php @@ -14,14 +14,6 @@ class Functional extends Module { - /** - * @param array|null $config - */ - public function __construct($config = null) - { - parent::__construct($config); - } - /** * @param \Codeception\TestCase $test *