mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Fix after review
This commit is contained in:
parent
f4e9def74e
commit
83ce73244f
11 changed files with 105 additions and 26 deletions
|
|
@ -1,15 +1,24 @@
|
|||
@customer_account
|
||||
Feature: Viewing a customer's addresses
|
||||
Feature: Viewing customer's addresses
|
||||
In order to see all my addresses in address book
|
||||
As a Customer
|
||||
I want to be able to browse my addresses
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And there is a customer "John Doe" identified by an email "doe@example.com" and a password "banana"
|
||||
And this customer has an address "John Doe", "Banana Street", "90232", "New York", "United States" in address book
|
||||
And I am a logged in customer
|
||||
And I have an address "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States" in address book
|
||||
|
||||
@ui
|
||||
Scenario: Viewing all addresses
|
||||
Given I have an address "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States" in address book
|
||||
When I browse my addresses
|
||||
Then I should see a single address in a list
|
||||
Then I should see a single address in the list
|
||||
And this address should be assigned to "Lucifer Morningstar"
|
||||
And I should not see an address assigned to "John Doe"
|
||||
|
||||
@ui
|
||||
Scenario: Viewing empty address book
|
||||
When I browse my addresses
|
||||
Then I should see information about no existing addresses
|
||||
|
|
|
|||
|
|
@ -186,13 +186,21 @@ final class CustomerContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Given /^I have an (address "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)") in address book$/
|
||||
* @Given /^I have an (address "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+") in address book$/
|
||||
*/
|
||||
public function iHaveAnAddressInAddressBook(AddressInterface $address)
|
||||
{
|
||||
$user = $this->sharedStorage->get('user');
|
||||
$user->getCustomer()->addAddress($address);
|
||||
|
||||
$this->thisCustomerHasAnAddressInAddressBook($user->getCustomer(), $address);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^(this customer) has an (address "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+") in address book$/
|
||||
*/
|
||||
public function thisCustomerHasAnAddressInAddressBook(CustomerInterface $customer, AddressInterface $address)
|
||||
{
|
||||
$customer->addAddress($address);
|
||||
|
||||
$this->customerManager->flush();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ final class AccountContext implements Context
|
|||
Assert::same(
|
||||
(int) $numberOfItems,
|
||||
$this->orderShowPage->countItems(),
|
||||
'%s items should appear on order page, but %s rows has been found'
|
||||
'%s items should appear on order page, but %s rows has been found.'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -430,7 +430,7 @@ final class AccountContext implements Context
|
|||
{
|
||||
Assert::true(
|
||||
$this->profileUpdatePage->isSubscribedToTheNewsletter(),
|
||||
'I should be subscribed to the newsletter, but I am not'
|
||||
'I should be subscribed to the newsletter, but I am not.'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -465,9 +465,9 @@ final class AccountContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then I should see a single address in a list
|
||||
* @Then I should see a single address in the list
|
||||
*/
|
||||
public function iShouldSeeASingleAddressInAList()
|
||||
public function iShouldSeeASingleAddressInTheList()
|
||||
{
|
||||
Assert::true(
|
||||
$this->addressBookIndexPage->isSingleAddressOnList(),
|
||||
|
|
@ -475,6 +475,39 @@ final class AccountContext implements Context
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then this address should be assigned to :fullName
|
||||
*/
|
||||
public function thisAddressShouldHavePersonFirstNameAndLastName($fullName)
|
||||
{
|
||||
Assert::true(
|
||||
$this->addressBookIndexPage->hasAddressFullName($fullName),
|
||||
sprintf('The full name in address should be %s, but it does not.', $fullName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see information about no existing addresses
|
||||
*/
|
||||
public function iShouldSeeInformationAboutNoExistingAddresses()
|
||||
{
|
||||
Assert::true(
|
||||
$this->addressBookIndexPage->hasNoExistingAddressesMessage(),
|
||||
'There should be information about no existing addresses, but it does not.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should not see an address assigned to :fullName
|
||||
*/
|
||||
public function iShouldNotSeeAnAddressAssignedTo($fullName)
|
||||
{
|
||||
Assert::false(
|
||||
$this->addressBookIndexPage->hasAddressFullName($fullName),
|
||||
sprintf('The full name in address should not be %s, but it does.', $fullName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PageInterface $page
|
||||
* @param string $element
|
||||
|
|
@ -487,5 +520,4 @@ final class AccountContext implements Context
|
|||
sprintf('There should be a message: "%s".', $expectedMessage)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,13 +34,30 @@ class IndexPage extends SymfonyPage implements IndexPageInterface
|
|||
return 1 === count($this->getElement('addresses')->findAll('css', '.title'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasAddressFullName($fullName)
|
||||
{
|
||||
return null !== $this->getElement('addresses')->find('css', sprintf('.title:contains("%s")', $fullName));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasNoExistingAddressesMessage()
|
||||
{
|
||||
return false !== strpos($this->getElement('no_addresses_message' )->getText(), 'no addresses to display');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefinedElements()
|
||||
{
|
||||
return array_merge(parent::getDefinedElements(), [
|
||||
'addresses' => '.addresses',
|
||||
'addresses' => '#addresses',
|
||||
'no_addresses_message' => '#addresses > .message',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,16 @@ interface IndexPageInterface extends SymfonyPageInterface
|
|||
* @return bool
|
||||
*/
|
||||
public function isSingleAddressOnList();
|
||||
|
||||
/**
|
||||
* @param string $fullName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAddressFullName($fullName);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasNoExistingAddressesMessage();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
|
||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
<parameters>
|
||||
<parameter key="sylius.behat.page.shop.account.address_book.index.class">Sylius\Behat\Page\Shop\Account\AddressBook\IndexPage</parameter>
|
||||
<parameter key="sylius.behat.page.shop.account.change_password.class">Sylius\Behat\Page\Shop\Account\ChangePasswordPage</parameter>
|
||||
<parameter key="sylius.behat.page.shop.account.dashboard.class">Sylius\Behat\Page\Shop\Account\DashboardPage</parameter>
|
||||
<parameter key="sylius.behat.page.shop.account.login.class">Sylius\Behat\Page\Shop\Account\LoginPage</parameter>
|
||||
<parameter key="sylius.behat.page.shop.account.address_book.index.class">Sylius\Behat\Page\Shop\Account\AddressBook\IndexPage</parameter>
|
||||
<parameter key="sylius.behat.page.shop.account.order.index.class">Sylius\Behat\Page\Shop\Account\Order\IndexPage</parameter>
|
||||
<parameter key="sylius.behat.page.shop.account.order.show.class">Sylius\Behat\Page\Shop\Account\Order\ShowPage</parameter>
|
||||
<parameter key="sylius.behat.page.shop.account.profile_update.class">Sylius\Behat\Page\Shop\Account\ProfileUpdatePage</parameter>
|
||||
|
|
@ -26,10 +26,10 @@
|
|||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius.behat.page.shop.account.address_book.index" class="%sylius.behat.page.shop.account.address_book.index.class%" parent="sylius.behat.symfony_page" scope="scenario" public="false" />
|
||||
<service id="sylius.behat.page.shop.account.change_password" class="%sylius.behat.page.shop.account.change_password.class%" parent="sylius.behat.symfony_page" scope="scenario" public="false" />
|
||||
<service id="sylius.behat.page.shop.account.dashboard" class="%sylius.behat.page.shop.account.dashboard.class%" parent="sylius.behat.symfony_page" scope="scenario" public="false" />
|
||||
<service id="sylius.behat.page.shop.account.login" class="%sylius.behat.page.shop.account.login.class%" parent="sylius.behat.symfony_page" scope="scenario" public="false" />
|
||||
<service id="sylius.behat.page.shop.account.address_book.index" class="%sylius.behat.page.shop.account.address_book.index.class%" parent="sylius.behat.symfony_page" scope="scenario" public="false" />
|
||||
<service id="sylius.behat.page.shop.account.order.index" class="%sylius.behat.page.shop.account.order.index.class%" parent="sylius.behat.symfony_page" scope="scenario" public="false">
|
||||
<argument type="service" id="sylius.behat.table_accessor" />
|
||||
</service>
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class AddressRepository extends EntityRepository implements AddressRepositoryInt
|
|||
public function findByCustomer(CustomerInterface $customer)
|
||||
{
|
||||
return $this->createQueryBuilder('o')
|
||||
->leftJoin('o.customers','customer')
|
||||
->where('customer.id = customer_id')
|
||||
->leftJoin('o.customer','customer')
|
||||
->where('customer.id = :customer_id')
|
||||
->setParameter('customer_id', $customer->getId())
|
||||
->getQuery()
|
||||
->getResult()
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ sylius:
|
|||
menu:
|
||||
shop:
|
||||
account:
|
||||
header: Your account
|
||||
dashboard: Dashboard
|
||||
personal_information: Personal information
|
||||
change_password: Change password
|
||||
order_history: Order history
|
||||
address_book: Address book
|
||||
address_book: 'Address book'
|
||||
change_password: 'Change password'
|
||||
dashboard: 'Dashboard'
|
||||
header: 'Your account'
|
||||
order_history: 'Order history'
|
||||
personal_information: 'Personal information'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<div class="ui accordion addresses">
|
||||
<div class="ui accordion">
|
||||
{% for address in addresses %}
|
||||
<div class="title">
|
||||
<i class="dropdown icon"></i>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{% extends '@SyliusShop/Account/layout.html.twig' %}
|
||||
|
||||
{% import '@SyliusUi/Macro/messages.html.twig' as messages %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
|
@ -21,8 +22,8 @@
|
|||
<div class="ten wide column">
|
||||
{{ messages.info('sylius.ui.no_default_address'|trans) }}
|
||||
</div>
|
||||
<div class="six wide column">
|
||||
{% if(addresses is empty) %}
|
||||
<div class="six wide column" id="addresses">
|
||||
{% if addresses is empty %}
|
||||
{{ messages.info('sylius.ui.no_addresses'|trans) }}
|
||||
{% else %}
|
||||
{% include '@SyliusShop/Account/AddressBook/_addresses.html.twig' with {'addresses': addresses} %}
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ sylius:
|
|||
no_label: 'No'
|
||||
no_account: 'No account yet'
|
||||
no_account: no account
|
||||
no_addresses: 'There is no adresses to display'
|
||||
no_addresses: 'There are no addresses to display'
|
||||
no_association_types_to_display: 'There are no association types defined'
|
||||
no_comment: 'No comment'
|
||||
no_default_address: 'There is no selected default address'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue