Completed
Push — a-bulwa-travis-is-2 ( 7c64aa )
by Kamil
41:24
created

SeleniumSessionRestarter::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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 Sylius\Behat\Extension\SeleniumExtension;
13
14
use Behat\Mink\Mink;
15
use Behat\Testwork\EventDispatcher\Event\AfterSuiteTested;
16
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17
18
/**
19
 * @author Kamil Kokot <[email protected]>
20
 */
21
final class SeleniumSessionRestarter implements EventSubscriberInterface
22
{
23
    /**
24
     * @var Mink
25
     */
26
    private $mink;
27
28
    /**
29
     * @param Mink $mink
30
     */
31
    public function __construct(Mink $mink)
32
    {
33
        $this->mink = $mink;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public static function getSubscribedEvents()
40
    {
41
        return [
42
            AfterSuiteTested::BEFORE => ['stopSession', 128],
43
        ];
44
    }
45
46
    public function stopSession()
47
    {
48
        if ($this->mink->hasSession('selenium2') && $this->mink->isSessionStarted('selenium2')) {
49
            $this->mink->getSession('selenium2')->stop();
50
        }
51
    }
52
}
53