Skip to content
This repository has been archived by the owner on Feb 4, 2019. It is now read-only.

Commit

Permalink
core1652 fixed Yves Customer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stereomon committed Aug 3, 2017
1 parent b437d1b commit 1c6372a
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 38 deletions.
4 changes: 2 additions & 2 deletions codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ include:
# - tests/PyzTest/Yves/Availability
#
# - tests/PyzTest/Yves/Cart
# - tests/PyzTest/Yves/Checkout
- tests/PyzTest/Yves/Customer
- tests/PyzTest/Yves/Checkout
# - tests/PyzTest/Yves/Customer
# - tests/PyzTest/Yves/Newsletter
# - tests/PyzTest/Zed/Calculation
# - tests/PyzTest/Zed/CmsGui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Spryker\Yves\Kernel\Application;
use Spryker\Yves\Kernel\Container;
use Spryker\Yves\Kernel\Plugin\Pimple;
use Spryker\Yves\Messenger\FlashMessenger\FlashMessengerInterface;

/**
* Auto-generated group annotations
Expand Down Expand Up @@ -52,7 +51,6 @@ public function testProvideDependencies()
$this->assertInstanceOf(AuthenticationHandler::class, $container[CustomerDependencyProvider::PLUGIN_AUTHENTICATION_HANDLER]);
$this->assertInstanceOf(CheckoutAuthenticationHandlerPluginInterface::class, $container[CustomerDependencyProvider::PLUGIN_LOGIN_AUTHENTICATION_HANDLER]);
$this->assertInstanceOf(CheckoutAuthenticationHandlerPluginInterface::class, $container[CustomerDependencyProvider::PLUGIN_GUEST_AUTHENTICATION_HANDLER]);
$this->assertInstanceOf(FlashMessengerInterface::class, $container[CustomerDependencyProvider::FLASH_MESSENGER]);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function testICanOpenForgotPasswordPage(CustomerPresentationTester $i)
public function testICanLoginWithValidData(CustomerPresentationTester $i)
{
$i->amOnPage(CustomerLoginPage::URL);
$i->haveRegisteredCustomer(CustomerLoginPage::NEW_CUSTOMER_EMAIL);
$i->submitLoginForm();
$customerTransfer = $i->haveRegisteredCustomer();
$i->submitLoginForm($customerTransfer->getEmail(), $customerTransfer->getPassword());
$i->seeCurrentUrlEquals(CustomerOverviewPage::URL);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class CustomerLogoutCest
public function testICanLogoutWhenLoggedIn(CustomerPresentationTester $i)
{
$i->amOnPage(CustomerLoginPage::URL);
$i->haveRegisteredCustomer(CustomerLoginPage::NEW_CUSTOMER_EMAIL);
$i->submitLoginForm();
$customerTransfer = $i->haveRegisteredCustomer();
$i->submitLoginForm($customerTransfer->getEmail(), $customerTransfer->getPassword());
$i->seeCurrentUrlEquals(CustomerOverviewPage::URL);

$i->amOnPage(CustomerLogoutPage::URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public function testICanSubscribeNewsletter(CustomerPresentationTester $i)
*/
public function testICanUnSubscribeNewsletter(CustomerPresentationTester $i)
{
$i->amLoggedInCustomer();
$customerTransfer = $i->amLoggedInCustomer();

$i->setDependency(NewsletterDependencyProvider::FACADE_MAIL, Stub::makeEmpty(NewsletterToMailInterface::class));

$i->addNewsletterSubscription(CustomerNewsletterPage::NEW_CUSTOMER_EMAIL);
$i->addNewsletterSubscription($customerTransfer->getEmail());
$i->amOnPage(CustomerNewsletterPage::URL);
$i->click(['name' => CustomerNewsletterPage::FORM_FIELD_SELECTOR_NEWSLETTER_SUBSCRIPTION]);
$i->click(CustomerNewsletterPage::BUTTON_SUBMIT);
Expand Down
18 changes: 0 additions & 18 deletions tests/PyzTest/Yves/Customer/Presentation/CustomerOverviewCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,6 @@ public function testCustomerWithoutAddressShouldSeeAddAddressInfoText(CustomerPr
$i->see(CustomerOverviewPage::INFO_TEXT_ADD_BILLING_ADDRESS);
}

/**
* @param \PyzTest\Yves\Customer\CustomerPresentationTester $i
*
* @return void
*/
public function testCustomerWithAddressShouldNotSeeAddressInfoText(CustomerPresentationTester $i)
{
$i->haveRegisteredCustomer(CustomerOverviewPage::NEW_CUSTOMER_EMAIL);
$i->addAddressToCustomer(CustomerOverviewPage::NEW_CUSTOMER_EMAIL, CustomerAddressesPage::ADDRESS_A);

$i->amLoggedInCustomer();

$i->amOnPage(CustomerOverviewPage::URL);

$i->dontSee(CustomerOverviewPage::INFO_TEXT_ADD_SHIPPING_ADDRESS);
$i->dontSee(CustomerOverviewPage::INFO_TEXT_ADD_BILLING_ADDRESS);
}

/**
* @param \PyzTest\Yves\Customer\CustomerPresentationTester $i
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testICanUpdateEmail(CustomerPresentationTester $i)
public function testICanNotUpdateEmailToAnAlreadyUsedOne(CustomerPresentationTester $i)
{
$i->amLoggedInCustomer();
$i->haveRegisteredCustomer(CustomerProfilePage::REGISTERED_CUSTOMER_EMAIL);
$i->haveRegisteredCustomer(['email' => CustomerProfilePage::REGISTERED_CUSTOMER_EMAIL]);
$i->amOnPage(CustomerProfilePage::URL);

$i->fillField(CustomerProfilePage::FORM_FIELD_SELECTOR_EMAIL, CustomerProfilePage::REGISTERED_CUSTOMER_EMAIL);
Expand All @@ -82,10 +82,9 @@ public function testICanNotUpdateEmailToAnAlreadyUsedOne(CustomerPresentationTes
*/
public function testICanChangePassword(CustomerPresentationTester $i)
{
$i->amLoggedInCustomer();
$customerTransfer = $i->amLoggedInCustomer();
$i->amOnPage(CustomerProfilePage::URL);

$customerTransfer = CustomerProfilePage::getCustomerData(CustomerProfilePage::REGISTERED_CUSTOMER_EMAIL);
$oldPassword = $customerTransfer->getPassword();
$newPassword = strrev($oldPassword);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ public function __construct(Scenario $scenario)
}

/**
* @param string $email
* @param string $password
*
* @return void
*/
public function submitLoginForm()
public function submitLoginForm($email, $password)
{
$i = $this;
$customerTransfer = CustomerLoginPage::getCustomerData(CustomerLoginPage::NEW_CUSTOMER_EMAIL);

$i->submitForm(['name' => 'loginForm'], [
CustomerLoginPage::FORM_FIELD_SELECTOR_EMAIL => $customerTransfer->getEmail(),
CustomerLoginPage::FORM_FIELD_SELECTOR_PASSWORD => $customerTransfer->getPassword(),
CustomerLoginPage::FORM_FIELD_SELECTOR_EMAIL => $email,
CustomerLoginPage::FORM_FIELD_SELECTOR_PASSWORD => $password,
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function loadCustomerByEmail($email)
*
* @return \Generated\Shared\Transfer\CustomerTransfer
*/
public function haveRegisteredCustomer(array $seed)
public function haveRegisteredCustomer(array $seed = [])
{
$this->setupSession();

Expand Down Expand Up @@ -219,7 +219,7 @@ public function addNewsletterSubscription($email, $type = NewsletterConstants::E
*
* @return \Generated\Shared\Transfer\CustomerTransfer
*/
public function amLoggedInCustomer(array $seed)
public function amLoggedInCustomer(array $seed = [])
{
$customerTransfer = $this->haveRegisteredCustomer($seed);

Expand Down
3 changes: 3 additions & 0 deletions tests/PyzTest/Yves/Customer/codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ suites:
enabled:
- \PyzTest\Shared\Testify\Helper\Environment
- \SprykerTest\Shared\Propel\Helper\ConnectionHelper
- \SprykerTest\Shared\Testify\Helper\LocatorHelper:
projectNamespaces: ['Pyz']
- \SprykerTest\Shared\Testify\Helper\DependencyHelper
- \PyzTest\Yves\Customer\Helper\CustomerHelper
- \SprykerTest\Shared\Config\Helper\ConfigInit
- \SprykerTest\Shared\Propel\Helper\PropelInstallHelper
Expand Down

0 comments on commit 1c6372a

Please sign in to comment.