Completed
Pull Request — 3.1 (#347)
by Łukasz
16:49 queued 11:36
created

MessageContext   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 47
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A iShouldSeeErrorMessageSaying() 0 6 1
A iShouldSeeWarningMessageSaying() 0 6 1
A iShouldSeeInformationalMessageSaying() 0 6 1
A iShouldSeeSuccessMessageSaying() 0 6 1
A getMessagesElement() 0 4 1
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace FSi\Bundle\AdminBundle\Behat\Context;
13
14
use Behat\Gherkin\Node\PyStringNode;
15
use FSi\Bundle\AdminBundle\Behat\Element\Messages;
16
use SensioLabs\Behat\PageObjectExtension\Context\PageObjectContext;
17
18
class MessageContext extends PageObjectContext
19
{
20
    /**
21
     * @Then I should see an error message saying:
22
     */
23
    public function iShouldSeeErrorMessageSaying(PyStringNode $message)
24
    {
25
        $notifications = $this->getMessagesElement();
26
27
        expect($notifications->getMessageText('danger'))->toBe($message->getRaw());
28
    }
29
30
    /**
31
     * @Then I should see a warning message saying:
32
     */
33
    public function iShouldSeeWarningMessageSaying(PyStringNode $message)
34
    {
35
        $notifications = $this->getMessagesElement();
36
37
        expect($notifications->getMessageText('warning'))->toBe($message->getRaw());
38
    }
39
40
    /**
41
     * @Then I should see an informational message saying:
42
     */
43
    public function iShouldSeeInformationalMessageSaying(PyStringNode $message)
44
    {
45
        $notifications = $this->getMessagesElement();
46
47
        expect($notifications->getMessageText('info'))->toBe($message->getRaw());
48
    }
49
50
    /**
51
     * @Then I should see a success message saying:
52
     */
53
    public function iShouldSeeSuccessMessageSaying(PyStringNode $message)
54
    {
55
        $notifications = $this->getMessagesElement();
56
57
        expect($notifications->getMessageText('success'))->toBe($message->getRaw());
58
    }
59
60
    private function getMessagesElement(): Messages
61
    {
62
        return $this->getElement('Messages');
63
    }
64
}
65