These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\NotificationType; |
||
17 | use Sylius\Behat\Service\Accessor\NotificationAccessorInterface; |
||
18 | use Sylius\Behat\Service\NotificationChecker; |
||
19 | use Sylius\Behat\Service\NotificationCheckerInterface; |
||
20 | |||
21 | /** |
||
22 | * @mixin NotificationChecker |
||
23 | * |
||
24 | * @author Łukasz Chruściel <[email protected]> |
||
25 | * @author Arkadiusz Krakowiak <[email protected]> |
||
26 | */ |
||
27 | class NotificationCheckerSpec extends ObjectBehavior |
||
28 | { |
||
29 | function let(NotificationAccessorInterface $notificationAccessor) |
||
30 | { |
||
31 | $this->beConstructedWith($notificationAccessor); |
||
32 | } |
||
33 | |||
34 | function it_is_initializable() |
||
35 | { |
||
36 | $this->shouldHaveType('Sylius\Behat\Service\NotificationChecker'); |
||
37 | } |
||
38 | |||
39 | function it_implements_notification_checker_interface() |
||
40 | { |
||
41 | $this->shouldImplement(NotificationCheckerInterface::class); |
||
42 | } |
||
43 | |||
44 | function it_checks_if_successful_creation_notification_has_appeared(NotificationAccessorInterface $notificationAccessor) |
||
0 ignored issues
–
show
|
|||
45 | { |
||
46 | $notificationAccessor->getType()->willReturn(NotificationType::success()); |
||
47 | $notificationAccessor->getMessage()->willReturn('Some resource has been successfully created.'); |
||
48 | |||
49 | $this->checkCreationNotification('some_resource'); |
||
50 | } |
||
51 | |||
52 | function it_checks_if_successful_edition_notification_has_appeared(NotificationAccessorInterface $notificationAccessor) |
||
0 ignored issues
–
show
The method it_checks_if_successful_edition_notification_has_appeared is not named in camelCase.
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
Loading history...
|
|||
53 | { |
||
54 | $notificationAccessor->getType()->willReturn(NotificationType::success()); |
||
55 | $notificationAccessor->getMessage()->willReturn('Some resource has been successfully updated.'); |
||
56 | |||
57 | $this->checkEditionNotification('some_resource'); |
||
58 | } |
||
59 | |||
60 | function it_checks_if_successful_deletion_notification_has_appeared(NotificationAccessorInterface $notificationAccessor) |
||
0 ignored issues
–
show
The method it_checks_if_successful_deletion_notification_has_appeared is not named in camelCase.
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
Loading history...
|
|||
61 | { |
||
62 | $notificationAccessor->getType()->willReturn(NotificationType::success()); |
||
63 | $notificationAccessor->getMessage()->willReturn('Some resource has been successfully deleted.'); |
||
64 | |||
65 | $this->checkDeletionNotification('some_resource'); |
||
66 | } |
||
67 | |||
68 | function it_checks_if_successful_notification_has_appeared(NotificationAccessorInterface $notificationAccessor) |
||
69 | { |
||
70 | $notificationAccessor->getType()->willReturn(NotificationType::success()); |
||
71 | $notificationAccessor->getMessage()->willReturn('Some resource has been successfully deleted.'); |
||
72 | |||
73 | $this->checkNotification('Some resource has been successfully deleted.', NotificationType::success()); |
||
74 | } |
||
75 | |||
76 | function it_checks_if_failure_notification_has_appeared(NotificationAccessorInterface $notificationAccessor) |
||
77 | { |
||
78 | $notificationAccessor->getType()->willReturn(NotificationType::failure()); |
||
79 | $notificationAccessor->getMessage()->willReturn('Something went wrong.'); |
||
80 | |||
81 | $this->checkNotification('Something went wrong.', NotificationType::failure()); |
||
82 | } |
||
83 | |||
84 | function it_throws_notification_mismatch_exception_if_different_or_no_success_notification_has_been_found( |
||
85 | NotificationAccessorInterface $notificationAccessor |
||
86 | ) { |
||
87 | $notificationAccessor->getType()->willReturn(NotificationType::success()); |
||
88 | $notificationAccessor->getMessage()->willReturn('Some resource has been successfully updated.'); |
||
89 | |||
90 | $this->shouldThrow( |
||
91 | new NotificationExpectationMismatchException( |
||
92 | NotificationType::success(), |
||
93 | 'Some resource has been successfully created.', |
||
94 | NotificationType::success(), |
||
95 | 'Some resource has been successfully updated.' |
||
96 | ) |
||
97 | )->during('checkNotification', ['Some resource has been successfully created.', NotificationType::success()]); |
||
98 | } |
||
99 | |||
100 | function it_throws_notification_mismatch_exception_if_failure_message_type_has_been_found_but_expect_success( |
||
101 | NotificationAccessorInterface $notificationAccessor |
||
102 | ) { |
||
103 | $notificationAccessor->getType()->willReturn(NotificationType::failure()); |
||
104 | $notificationAccessor->getMessage()->willReturn('Some resource has been successfully created.'); |
||
105 | |||
106 | $this->shouldThrow( |
||
107 | new NotificationExpectationMismatchException( |
||
108 | NotificationType::success(), |
||
109 | 'Some resource has been successfully created.', |
||
110 | NotificationType::failure(), |
||
111 | 'Some resource has been successfully created.' |
||
112 | ) |
||
113 | )->during('checkNotification', ['Some resource has been successfully created.', NotificationType::success()]); |
||
114 | } |
||
115 | |||
116 | function it_throws_notification_mismatch_exception_if_different_or_no_failure_notification_has_been_found( |
||
117 | NotificationAccessorInterface $notificationAccessor |
||
118 | ) { |
||
119 | $notificationAccessor->getType()->willReturn(NotificationType::failure()); |
||
120 | $notificationAccessor->getMessage()->willReturn('Something different went wrong.'); |
||
121 | |||
122 | $this->shouldThrow( |
||
123 | new NotificationExpectationMismatchException( |
||
124 | NotificationType::failure(), |
||
125 | 'Something went wrong.', |
||
126 | NotificationType::failure(), |
||
127 | 'Something different went wrong.' |
||
128 | ) |
||
129 | )->during('checkNotification', ['Something went wrong.', NotificationType::failure()]); |
||
130 | } |
||
131 | |||
132 | function it_throws_notification_mismatch_exception_if_success_message_type_has_been_found_but_expect_failure( |
||
133 | NotificationAccessorInterface $notificationAccessor |
||
134 | ) { |
||
135 | $notificationAccessor->getType()->willReturn(NotificationType::success()); |
||
136 | $notificationAccessor->getMessage()->willReturn('Something went wrong.'); |
||
137 | |||
138 | $this->shouldThrow( |
||
139 | new NotificationExpectationMismatchException( |
||
140 | NotificationType::failure(), |
||
141 | 'Something went wrong.', |
||
142 | NotificationType::success(), |
||
143 | 'Something went wrong.' |
||
144 | ) |
||
145 | )->during('checkNotification', ['Something went wrong.', NotificationType::failure()]); |
||
146 | } |
||
147 | } |
||
148 |
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
.