/
ReversePageConstraint.php
61 lines (55 loc) · 1.43 KB
/
ReversePageConstraint.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace Illuminate\Foundation\Testing\Constraints;
class ReversePageConstraint extends PageConstraint
{
/**
* The page constraint instance.
*
* @var \Illuminate\Foundation\Testing\Constraints\PageConstraint
*/
protected $pageConstraint;
/**
* Create a new reverse page constraint instance.
*
* @param \Illuminate\Foundation\Testing\Constraints\PageConstraint $pageConstraint
* @return void
*/
public function __construct(PageConstraint $pageConstraint)
{
$this->pageConstraint = $pageConstraint;
}
/**
* Reverse the original page constraint result.
*
* @param \Symfony\Component\DomCrawler\Crawler $crawler
* @return bool
*/
public function matches($crawler)
{
return ! $this->pageConstraint->matches($crawler);
}
/**
* Get the description of the failure.
*
* This method will attempt to negate the original description.
*
* @return string
*/
protected function getFailureDescription()
{
return str_replace(
['contains', 'is', 'has'],
['does not contain', 'is not', 'does not have'],
$this->pageConstraint->getFailureDescription()
);
}
/**
* Get a string representation of the object.
*
* @return string
*/
public function toString()
{
return $this->pageConstraint->toString();
}
}