Completed
Push — master ( 6f962e...f87bab )
by Paweł
15s
created

it_checks_if_successful_creation_notification_has_appeared()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
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()
0 ignored issues
show
Coding Style Naming introduced by
The method it_is_initializable 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 databaseConnectionString.

Loading history...
35
    {
36
        $this->shouldHaveType('Sylius\Behat\Service\NotificationChecker');
37
    }
38
39
    function it_implements_notification_checker_interface()
0 ignored issues
show
Coding Style Naming introduced by
The method it_implements_notification_checker_interface 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 databaseConnectionString.

Loading history...
40
    {
41
        $this->shouldImplement(NotificationCheckerInterface::class);
42
    }
43
44
    function it_checks_if_successful_notification_has_appeared(NotificationAccessorInterface $notificationAccessor)
0 ignored issues
show
Coding Style Naming introduced by
The method it_checks_if_successful_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 databaseConnectionString.

Loading history...
45
    {
46
        $notificationAccessor->getType()->willReturn(NotificationType::success());
47
        $notificationAccessor->getMessage()->willReturn('Some resource has been successfully deleted.');
48
49
        $this->checkNotification('Some resource has been successfully deleted.', NotificationType::success());
50
    }
51
52
    function it_checks_if_failure_notification_has_appeared(NotificationAccessorInterface $notificationAccessor)
0 ignored issues
show
Coding Style Naming introduced by
The method it_checks_if_failure_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 databaseConnectionString.

Loading history...
53
    {
54
        $notificationAccessor->getType()->willReturn(NotificationType::failure());
55
        $notificationAccessor->getMessage()->willReturn('Something went wrong.');
56
57
        $this->checkNotification('Something went wrong.', NotificationType::failure());
58
    }
59
60
    function it_throws_notification_mismatch_exception_if_different_or_no_success_notification_has_been_found(
0 ignored issues
show
Coding Style Naming introduced by
The method it_throws_notification_mismatch_exception_if_different_or_no_success_notification_has_been_found 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 databaseConnectionString.

Loading history...
61
        NotificationAccessorInterface $notificationAccessor
62
    ) {
63
        $notificationAccessor->getType()->willReturn(NotificationType::success());
64
        $notificationAccessor->getMessage()->willReturn('Some resource has been successfully updated.');
65
66
        $this->shouldThrow(
67
            new NotificationExpectationMismatchException(
68
                NotificationType::success(),
69
                'Some resource has been successfully created.',
70
                NotificationType::success(),
71
                'Some resource has been successfully updated.'
72
            )
73
        )->during('checkNotification', ['Some resource has been successfully created.', NotificationType::success()]);
74
    }
75
76
    function it_throws_notification_mismatch_exception_if_failure_message_type_has_been_found_but_expect_success(
0 ignored issues
show
Coding Style Naming introduced by
The method it_throws_notification_mismatch_exception_if_failure_message_type_has_been_found_but_expect_success 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 databaseConnectionString.

Loading history...
77
        NotificationAccessorInterface $notificationAccessor
78
    ) {
79
        $notificationAccessor->getType()->willReturn(NotificationType::failure());
80
        $notificationAccessor->getMessage()->willReturn('Some resource has been successfully created.');
81
82
        $this->shouldThrow(
83
            new NotificationExpectationMismatchException(
84
                NotificationType::success(),
85
                'Some resource has been successfully created.',
86
                NotificationType::failure(),
87
                'Some resource has been successfully created.'
88
            )
89
        )->during('checkNotification', ['Some resource has been successfully created.', NotificationType::success()]);
90
    }
91
92
    function it_throws_notification_mismatch_exception_if_different_or_no_failure_notification_has_been_found(
0 ignored issues
show
Coding Style Naming introduced by
The method it_throws_notification_mismatch_exception_if_different_or_no_failure_notification_has_been_found 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 databaseConnectionString.

Loading history...
93
        NotificationAccessorInterface $notificationAccessor
94
    ) {
95
        $notificationAccessor->getType()->willReturn(NotificationType::failure());
96
        $notificationAccessor->getMessage()->willReturn('Something different went wrong.');
97
98
        $this->shouldThrow(
99
            new NotificationExpectationMismatchException(
100
                NotificationType::failure(),
101
                'Something went wrong.',
102
                NotificationType::failure(),
103
                'Something different went wrong.'
104
            )
105
        )->during('checkNotification', ['Something went wrong.', NotificationType::failure()]);
106
    }
107
108
    function it_throws_notification_mismatch_exception_if_success_message_type_has_been_found_but_expect_failure(
0 ignored issues
show
Coding Style Naming introduced by
The method it_throws_notification_mismatch_exception_if_success_message_type_has_been_found_but_expect_failure 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 databaseConnectionString.

Loading history...
109
        NotificationAccessorInterface $notificationAccessor
110
    ) {
111
        $notificationAccessor->getType()->willReturn(NotificationType::success());
112
        $notificationAccessor->getMessage()->willReturn('Something went wrong.');
113
114
        $this->shouldThrow(
115
            new NotificationExpectationMismatchException(
116
                NotificationType::failure(),
117
                'Something went wrong.',
118
                NotificationType::success(),
119
                'Something went wrong.'
120
            )
121
        )->during('checkNotification', ['Something went wrong.', NotificationType::failure()]);
122
    }
123
}
124