Completed
Push — master ( 420f16...68b944 )
by Alexander
03:24
created

TestEvent   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 66
ccs 13
cts 13
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTestCase() 0 4 1
A getSession() 0 4 1
A __construct() 0 5 1
A validateSubscriber() 0 8 3
1
<?php
2
/**
3
 * This file is part of the phpunit-mink library.
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @copyright Alexander Obuhovich <[email protected]>
8
 * @link      https://github.com/aik099/phpunit-mink
9
 */
10
11
namespace aik099\PHPUnit\Event;
12
13
14
use aik099\PHPUnit\BrowserTestCase;
15
use Behat\Mink\Session;
16
use Symfony\Component\EventDispatcher\Event;
17
18
class TestEvent extends Event
19
{
20
21
	/**
22
	 * Test case.
23
	 *
24
	 * @var BrowserTestCase
25
	 */
26
	private $_testCase;
27
28
	/**
29
	 * Session.
30
	 *
31
	 * @var Session
32
	 */
33
	private $_session;
34
35
	/**
36
	 * Creates test event.
37
	 *
38
	 * @param BrowserTestCase $test_case Test case.
39
	 * @param Session         $session   Session.
40
	 */
41 48
	public function __construct(BrowserTestCase $test_case, Session $session = null)
42
	{
43 48
		$this->_testCase = $test_case;
44 48
		$this->_session = $session;
45 48
	}
46
47
	/**
48
	 * Returns test case.
49
	 *
50
	 * @return BrowserTestCase
51
	 */
52 33
	public function getTestCase()
53
	{
54 33
		return $this->_testCase;
55
	}
56
57
	/**
58
	 * Returns session.
59
	 *
60
	 * @return Session
61
	 */
62 11
	public function getSession()
63
	{
64 11
		return $this->_session;
65
	}
66
67
	/**
68
	 * Determines if received event is designed for given test case.
69
	 *
70
	 * @param BrowserTestCase $test_case Test case for comparison.
71
	 *
72
	 * @return boolean
73
	 */
74 28
	public function validateSubscriber(BrowserTestCase $test_case)
75
	{
76 28
		$event_test_case = $this->getTestCase();
77
78 28
		return get_class($event_test_case) === get_class($test_case)
79 28
			&& $event_test_case->getName() === $test_case->getName()
80 28
			&& $event_test_case->getBrowser()->getChecksum() === $test_case->getBrowser()->getChecksum();
81
	}
82
83
}
84