|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Behat Symfony2Extension. |
|
5
|
|
|
* (c) Konstantin Kudryashov <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Behat\Symfony2Extension\Suite; |
|
12
|
|
|
|
|
13
|
|
|
use Behat\Testwork\Suite\Suite; |
|
14
|
|
|
use Symfony\Component\HttpKernel\Bundle\BundleInterface; |
|
15
|
|
|
use Behat\Testwork\Suite\Exception\ParameterNotFoundException; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author Christophe Coevoet <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class SymfonyBundleSuite implements Suite |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
private $name; |
|
26
|
|
|
/** |
|
27
|
|
|
* @var BundleInterface |
|
28
|
|
|
*/ |
|
29
|
|
|
private $bundle; |
|
30
|
|
|
/** |
|
31
|
|
|
* @var array |
|
32
|
|
|
*/ |
|
33
|
|
|
private $settings = array(); |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Initiailzes suite. |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $name |
|
39
|
|
|
* @param BundleInterface $bundle |
|
40
|
|
|
* @param array $settings |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct($name, BundleInterface $bundle, array $settings) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->name = $name; |
|
45
|
|
|
$this->bundle = $bundle; |
|
46
|
|
|
$this->settings = $settings; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritdoc} |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getName() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->name; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Returns suite bundle. |
|
59
|
|
|
* |
|
60
|
|
|
* @return BundleInterface |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getBundle() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->bundle; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* {@inheritdoc} |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getSettings() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->settings; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* {@inheritdoc} |
|
77
|
|
|
*/ |
|
78
|
|
|
public function hasSetting($key) |
|
79
|
|
|
{ |
|
80
|
|
|
return isset($this->settings[$key]); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* {@inheritdoc} |
|
85
|
|
|
* |
|
86
|
|
|
* @throws ParameterNotFoundException If setting is not set |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getSetting($key) |
|
89
|
|
|
{ |
|
90
|
|
|
if (!$this->hasSetting($key)) { |
|
91
|
|
|
throw new ParameterNotFoundException(sprintf( |
|
92
|
|
|
'`%s` suite does not have a `%s` setting.', |
|
93
|
|
|
$this->getName(), |
|
94
|
|
|
$key |
|
95
|
|
|
), $this->getName(), $key); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
return $this->settings[$key]; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|