|
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\TestSuite; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
use aik099\PHPUnit\BrowserTestCase; |
|
15
|
|
|
use PHPUnit\Framework\DataProviderTestSuite; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Test Suite class for a set of tests from a single Test Case Class executed with a particular browser. |
|
19
|
|
|
*/ |
|
20
|
|
|
class BrowserTestSuite extends AbstractTestSuite |
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Generates suite name by the browser configuration. |
|
25
|
|
|
* |
|
26
|
|
|
* @param array $browser Browser configuration. |
|
27
|
|
|
* |
|
28
|
|
|
* @return string |
|
29
|
|
|
*/ |
|
30
|
8 |
|
public function nameFromBrowser(array $browser) |
|
31
|
|
|
{ |
|
32
|
8 |
|
$try_settings = array('alias', 'browserName', 'name'); |
|
33
|
|
|
|
|
34
|
8 |
|
foreach ( $try_settings as $try_setting ) { |
|
35
|
8 |
|
if ( isset($browser[$try_setting]) ) { |
|
36
|
8 |
|
return $browser[$try_setting]; |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
1 |
|
return 'undefined'; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Sets given browser to be used in each underlying test cases and test suites. |
|
45
|
|
|
* |
|
46
|
|
|
* @param array $browser Browser configuration. |
|
47
|
|
|
* @param array $tests Tests to process. |
|
48
|
|
|
* |
|
49
|
|
|
* @return self |
|
50
|
|
|
*/ |
|
51
|
3 |
|
public function setBrowserFromConfiguration(array $browser, array $tests = null) |
|
52
|
|
|
{ |
|
53
|
3 |
|
if ( !isset($tests) ) { |
|
54
|
3 |
|
$tests = $this->tests(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
3 |
|
foreach ( $tests as $test ) { |
|
58
|
3 |
|
if ( $test instanceof DataProviderTestSuite ) { |
|
59
|
|
|
$this->setBrowserFromConfiguration($browser, $test->tests()); |
|
60
|
|
|
} |
|
61
|
|
|
else { |
|
62
|
|
|
/* @var $test BrowserTestCase */ |
|
|
|
|
|
|
63
|
3 |
|
$test->setBrowserFromConfiguration($browser); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
3 |
|
return $this; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|