Completed
Push — master ( c78447...627e0e )
by Kamil
13s
created

it_checks_if_successful_notifaction_has_appeared()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
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\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()
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...
33
    {
34
        $this->shouldHaveType('Sylius\Behat\Service\NotificationChecker');
35
    }
36
37
    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...
38
    {
39
        $this->shouldImplement(NotificationCheckerInterface::class);
40
    }
41
42
    function it_checks_if_successful_creation_notifaction_has_appeared(NotificationAccessorInterface $notificationAccessor)
0 ignored issues
show
Coding Style Naming introduced by
The method it_checks_if_successful_creation_notifaction_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...
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)
0 ignored issues
show
Coding Style Naming introduced by
The method it_checks_if_successful_edition_notifaction_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...
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)
0 ignored issues
show
Coding Style Naming introduced by
The method it_checks_if_successful_deletion_notifaction_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...
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)
0 ignored issues
show
Coding Style Naming introduced by
The method it_checks_if_successful_notifaction_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...
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(
0 ignored issues
show
Coding Style Naming introduced by
The method it_throws_notification_mismatch_exception_if_diffrent_or_no_notifaction_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...
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(
0 ignored issues
show
Coding Style Naming introduced by
The method it_throws_notification_mismatch_exception_if_diffrent_message_type_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->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