[Admin][Customer] Implement checking subscription to the newsletter on the customer show page

This commit is contained in:
Grzegorz Sadowski 2016-08-30 15:11:12 +02:00
parent e6baa9e796
commit 3762d5c951
7 changed files with 51 additions and 1 deletions

View file

@ -28,7 +28,7 @@ Feature: Seeing customer's details
When I view details of the customer "f.baggins@shire.me"
Then I should see information about no existing account for this customer
@todo
@ui
Scenario: Seeing information about subscribed to the newsletter
Given he subscribes to the newsletter
When I view details of the customer "f.baggins@shire.me"

View file

@ -229,4 +229,14 @@ final class CustomerContext implements Context
$this->sharedStorage->set('customer', $customer);
$this->customerRepository->add($customer);
}
/**
* @Given /^(he) subscribes to the newsletter$/
*/
public function heSubscribesToTheNewsletter(CustomerInterface $customer)
{
$customer->setSubscribedToNewsletter(true);
$this->customerManager->flush();
}
}

View file

@ -498,4 +498,15 @@ final class ManagingCustomersContext implements Context
'There should be information about no account, but there is none.'
);
}
/**
* @Then I should see that this customer subscribes to the newsletter
*/
public function iShouldSeeThatThisCustomerSubscribesToTheNewsletter()
{
Assert::true(
$this->showPage->isSubscribedToNewsletter(),
'There should be information that this customer subscribes to the newsletter.'
);
}
}

View file

@ -86,6 +86,19 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
return $this->hasElement('no_account');
}
/**
* {@inheritdoc}
*/
public function isSubscribedToNewsletter()
{
$subscribedToNewsletter = $this->getElement('subscribed_to_newsletter');
if ($subscribedToNewsletter->find('css', 'i.green')) {
return true;
}
return false;
}
/**
* {@inheritdoc}
*/
@ -107,6 +120,7 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
'no_account' => '#no-account',
'registration_date' => '#info .content .date',
'shipping_address' => '#shippingAddress address',
'subscribed_to_newsletter' => '#subscribed-to-newsletter',
]);
}
}

View file

@ -63,4 +63,9 @@ interface ShowPageInterface extends PageInterface
* @return bool
*/
public function hasAccount();
/**
* @return bool
*/
public function isSubscribedToNewsletter();
}

View file

@ -36,6 +36,15 @@
<div class="meta">
<span class="date">{{ 'sylius.ui.customer_since'|trans }} {{ customer.createdAt|date }}</span>
</div>
<br />
<div id="subscribed-to-newsletter">
{% if customer.subscribedToNewsletter %}
<i class="green checkmark icon"></i>
{% else %}
<i class="red remove icon"></i>
{% endif %}
{{ 'sylius.ui.subscribed_to_newsletter'|trans }}
</div>
</div>
<div class="extra content">
<a href="mailto: {{ customer.email }}">

View file

@ -661,6 +661,7 @@ sylius:
street: Street
string_blocks: 'String blocks'
subject: Subject
subscribed_to_newsletter: Subscribe to the newsletter
subtotal: Subtotal
success: Success
summary: Summary