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

SeleniumSessionRestarter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscribedEvents() 0 6 1
A stopSession() 0 6 3
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