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 spec\Sylius\Behat\Service; |
13
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
15
|
|
|
use Sylius\Behat\Exception\NotificationExpectationMismatchException; |
16
|
|
|
use Sylius\Behat\Service\Accessor\NotificationAccessorInterface; |
17
|
|
|
use Sylius\Behat\Service\NotificationChecker; |
18
|
|
|
use Sylius\Behat\Service\NotificationCheckerInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @mixin NotificationChecker |
22
|
|
|
* |
23
|
|
|
* @author Łukasz Chruściel <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class NotificationCheckerSpec extends ObjectBehavior |
26
|
|
|
{ |
27
|
|
|
function let(NotificationAccessorInterface $notificationAccessor) |
28
|
|
|
{ |
29
|
|
|
$this->beConstructedWith($notificationAccessor); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function it_is_initializable() |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
$this->shouldHaveType('Sylius\Behat\Service\NotificationChecker'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
function it_implements_notification_checker_interface() |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
$this->shouldImplement(NotificationCheckerInterface::class); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
function it_checks_if_successful_creation_notifaction_has_appeared(NotificationAccessorInterface $notificationAccessor) |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
$notificationAccessor->hasSuccessMessage()->willReturn(true); |
45
|
|
|
$notificationAccessor->hasMessage('Success Some resource has been successfully created.')->willReturn(true); |
46
|
|
|
|
47
|
|
|
$this->checkCreationNotification('some_resource'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
function it_checks_if_successful_edition_notifaction_has_appeared(NotificationAccessorInterface $notificationAccessor) |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$notificationAccessor->hasSuccessMessage()->willReturn(true); |
53
|
|
|
$notificationAccessor->hasMessage('Success Some resource has been successfully updated.')->willReturn(true); |
54
|
|
|
|
55
|
|
|
$this->checkEditionNotification('some_resource'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
function it_checks_if_successful_deletion_notifaction_has_appeared(NotificationAccessorInterface $notificationAccessor) |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
$notificationAccessor->hasSuccessMessage()->willReturn(true); |
61
|
|
|
$notificationAccessor->hasMessage('Success Some resource has been successfully deleted.')->willReturn(true); |
62
|
|
|
|
63
|
|
|
$this->checkDeletionNotification('some_resource'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
function it_checks_if_successful_notifaction_has_appeared(NotificationAccessorInterface $notificationAccessor) |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
$notificationAccessor->hasSuccessMessage()->willReturn(true); |
69
|
|
|
$notificationAccessor->hasMessage('Success Some resource has been successfully deleted.')->willReturn(true); |
70
|
|
|
|
71
|
|
|
$this->checkSuccessNotificationMessage('Success Some resource has been successfully deleted.'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
function it_throws_notification_mismatch_exception_if_diffrent_or_no_notifaction_has_been_found( |
|
|
|
|
75
|
|
|
NotificationAccessorInterface $notificationAccessor |
76
|
|
|
) { |
77
|
|
|
$notificationAccessor->hasSuccessMessage()->willReturn(true); |
78
|
|
|
$notificationAccessor->hasMessage('Success Some resource has been successfully created.')->willReturn(false); |
79
|
|
|
$notificationAccessor->getMessageType()->willReturn('success'); |
80
|
|
|
$notificationAccessor->getMessage()->willReturn('Success Some resource has been successfully updated.'); |
81
|
|
|
|
82
|
|
|
$this->shouldThrow( |
83
|
|
|
new NotificationExpectationMismatchException( |
84
|
|
|
'success', |
85
|
|
|
'Success Some resource has been successfully created.', |
86
|
|
|
'success', |
87
|
|
|
'Success Some resource has been successfully updated.' |
88
|
|
|
) |
89
|
|
|
)->during('checkSuccessNotificationMessage', ['Success Some resource has been successfully created.']); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
function it_throws_notification_mismatch_exception_if_diffrent_message_type_has_been_found( |
|
|
|
|
93
|
|
|
NotificationAccessorInterface $notificationAccessor |
94
|
|
|
) { |
95
|
|
|
$notificationAccessor->hasSuccessMessage()->willReturn(false); |
96
|
|
|
$notificationAccessor->hasMessage('Success Some resource has been successfully created.')->willReturn(false); |
97
|
|
|
$notificationAccessor->getMessageType()->willReturn('failure'); |
98
|
|
|
$notificationAccessor->getMessage()->willReturn('Success Some resource has been successfully created.'); |
99
|
|
|
|
100
|
|
|
$this->shouldThrow( |
101
|
|
|
new NotificationExpectationMismatchException( |
102
|
|
|
'success', |
103
|
|
|
'Success Some resource has been successfully created.', |
104
|
|
|
'failure', |
105
|
|
|
'Success Some resource has been successfully created.' |
106
|
|
|
) |
107
|
|
|
)->during('checkSuccessNotificationMessage', ['Success Some resource has been successfully created.']); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
This check marks method names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.