1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sylius\Behat\Context\Ui; |
13
|
|
|
|
14
|
|
|
use Behat\Behat\Context\Context; |
15
|
|
|
use Behat\Mink\Exception\ElementNotFoundException; |
16
|
|
|
use Sylius\Behat\Page\Admin\Customer\ShowPageInterface; |
17
|
|
|
use Sylius\Behat\Page\Shop\Account\LoginPageInterface; |
18
|
|
|
use Sylius\Behat\Page\Shop\HomePageInterface; |
19
|
|
|
use Sylius\Behat\Page\Shop\User\RegisterPageInterface; |
20
|
|
|
use Sylius\Behat\Service\SharedStorageInterface; |
21
|
|
|
use Sylius\Component\User\Repository\UserRepositoryInterface; |
22
|
|
|
use Webmozart\Assert\Assert; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @author Magdalena Banasiak <[email protected]> |
26
|
|
|
* @author Mateusz Zalewski <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
final class UserContext implements Context |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @var SharedStorageInterface |
32
|
|
|
*/ |
33
|
|
|
private $sharedStorage; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var UserRepositoryInterface |
37
|
|
|
*/ |
38
|
|
|
private $userRepository; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var ShowPageInterface |
42
|
|
|
*/ |
43
|
|
|
private $customerShowPage; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var HomePageInterface |
47
|
|
|
*/ |
48
|
|
|
private $homePage; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param SharedStorageInterface $sharedStorage |
52
|
|
|
* @param UserRepositoryInterface $userRepository |
53
|
|
|
* @param ShowPageInterface $customerShowPage |
54
|
|
|
* @param HomePageInterface $homePage |
55
|
|
|
*/ |
56
|
|
|
public function __construct( |
57
|
|
|
SharedStorageInterface $sharedStorage, |
58
|
|
|
UserRepositoryInterface $userRepository, |
59
|
|
|
ShowPageInterface $customerShowPage, |
60
|
|
|
HomePageInterface $homePage |
61
|
|
|
) { |
62
|
|
|
$this->sharedStorage = $sharedStorage; |
63
|
|
|
$this->userRepository = $userRepository; |
64
|
|
|
$this->customerShowPage = $customerShowPage; |
65
|
|
|
$this->homePage = $homePage; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @When I log out |
70
|
|
|
*/ |
71
|
|
|
public function iLogOut() |
72
|
|
|
{ |
73
|
|
|
$this->homePage->logOut(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @When I delete the account of :email user |
78
|
|
|
*/ |
79
|
|
|
public function iDeleteAccount($email) |
80
|
|
|
{ |
81
|
|
|
$user = $this->userRepository->findOneByEmail($email); |
82
|
|
|
|
83
|
|
|
$this->sharedStorage->set('deleted_user', $user); |
84
|
|
|
|
85
|
|
|
$this->customerShowPage->open(['id' => $user->getCustomer()->getId()]); |
86
|
|
|
$this->customerShowPage->deleteAccount(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @Then the user account should be deleted |
91
|
|
|
*/ |
92
|
|
|
public function accountShouldBeDeleted() |
93
|
|
|
{ |
94
|
|
|
$deletedUser = $this->sharedStorage->get('deleted_user'); |
95
|
|
|
|
96
|
|
|
$this->customerShowPage->open(['id' => $deletedUser->getCustomer()->getId()]); |
97
|
|
|
|
98
|
|
|
Assert::false($this->customerShowPage->isRegistered()); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|