|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Paraunit\Configuration; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class PHPUnitConfig |
|
7
|
|
|
* @package Paraunit\Configuration |
|
8
|
|
|
*/ |
|
9
|
|
|
class PHPUnitConfig |
|
10
|
|
|
{ |
|
11
|
|
|
const DEFAULT_FILE_NAME = 'phpunit.xml.dist'; |
|
12
|
|
|
|
|
13
|
|
|
/** @var string */ |
|
14
|
|
|
private $configFile; |
|
15
|
|
|
|
|
16
|
|
|
/** @var PHPUnitOption[] */ |
|
17
|
|
|
private $phpunitOptions; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @param string $inputPathOrFileName |
|
21
|
|
|
* @throws \InvalidArgumentException |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __construct($inputPathOrFileName) |
|
24
|
|
|
{ |
|
25
|
|
|
$inputPathOrFileName = realpath($inputPathOrFileName); |
|
26
|
|
|
|
|
27
|
|
|
if (false === $inputPathOrFileName) { |
|
28
|
|
|
throw new \InvalidArgumentException('Config path/file provided is not valid (does it exist?)'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
$configFile = is_dir($inputPathOrFileName) |
|
32
|
|
|
? $inputPathOrFileName . DIRECTORY_SEPARATOR . self::DEFAULT_FILE_NAME |
|
33
|
|
|
: $inputPathOrFileName; |
|
34
|
|
|
|
|
35
|
|
|
if (! is_file($configFile) || ! is_readable($configFile)) { |
|
36
|
|
|
throw new \InvalidArgumentException('Config file ' . $configFile . ' does not exist or is not readable'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
$this->configFile = $configFile; |
|
40
|
|
|
$this->phpunitOptions = array(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Get the full path for this configuration file |
|
45
|
|
|
* @return string |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getFileFullPath() |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->configFile; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Get the directory which contains this configuration file |
|
54
|
|
|
* @return string |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getDirectory() |
|
57
|
|
|
{ |
|
58
|
|
|
return dirname($this->configFile); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param PHPUnitOption $option |
|
63
|
|
|
*/ |
|
64
|
|
|
public function addPhpunitOption(PHPUnitOption $option) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->phpunitOptions[] = $option; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return PHPUnitOption[] |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getPhpunitOptions() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->phpunitOptions; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|