1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PHPKitchen\CodeSpecs\Expectation\Matcher; |
4
|
|
|
|
5
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\Base\Matcher; |
6
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Mixin\FileStateExpectations; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* FileMatcher is designed to check given file matches expectation. |
10
|
|
|
* |
11
|
|
|
* @package PHPKitchen\CodeSpecs\Expectation |
12
|
|
|
* @author Dima Kolodko <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class FileMatcher extends Matcher { |
15
|
|
|
use FileStateExpectations; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @return $this |
19
|
|
|
*/ |
20
|
|
|
public function isExist(): self { |
21
|
|
|
$this->startStep('is exist') |
22
|
|
|
->assertFileExists(); |
23
|
|
|
|
24
|
|
|
return $this; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return $this |
29
|
|
|
*/ |
30
|
|
|
public function isNotExist(): self { |
31
|
|
|
$this->startStep('is not exist') |
32
|
|
|
->assertFileNotExists(); |
33
|
|
|
|
34
|
|
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return $this |
39
|
|
|
*/ |
40
|
|
|
public function isEqualTo($file): self { |
41
|
|
|
$this->startStep('is equal to file "' . $file . '"') |
42
|
|
|
->assertFileEquals($file); |
43
|
|
|
|
44
|
|
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return $this |
49
|
|
|
*/ |
50
|
|
|
public function isNotEqualTo($file): self { |
51
|
|
|
$this->startStep('is not equal to file "' . $file . '"') |
52
|
|
|
->assertFileNotEquals($file); |
53
|
|
|
|
54
|
|
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return $this |
59
|
|
|
*/ |
60
|
|
|
public function isEqualToJsonFile($file): self { |
61
|
|
|
$this->startStep('is equal to json file "' . $file . '"') |
62
|
|
|
->assertJsonFileEqualsJsonFile($file); |
63
|
|
|
|
64
|
|
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return $this |
69
|
|
|
*/ |
70
|
|
|
public function isNotEqualToJsonFile($file): self { |
71
|
|
|
$this->startStep('is not equal to json file "' . $file . '"') |
72
|
|
|
->assertJsonFileNotEqualsJsonFile($file); |
73
|
|
|
|
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return $this |
79
|
|
|
*/ |
80
|
|
|
public function isEqualToXmlFile($file): self { |
81
|
|
|
$this->startStep('is equal to xml file "' . $file . '"') |
82
|
|
|
->assertXmlFileEqualsXmlFile($file); |
83
|
|
|
|
84
|
|
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return $this |
89
|
|
|
*/ |
90
|
|
|
public function isNotEqualToXmlFile($file): self { |
91
|
|
|
$this->startStep('is not equal to xml file "' . $file . '"') |
92
|
|
|
->assertXmlFileNotEqualsXmlFile($file); |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
} |