Subversion Repositories web.creative

Rev

Details | Last modification | View Log

Rev Author Line No. Line
1 mjordaan 1
<?php
2
/*
3
 * This file is part of PHPUnit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
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
/**
12
 * Constraint that checks if the file(name) that it is evaluated for exists.
13
 *
14
 * The file path to check is passed as $other in evaluate().
15
 */
16
class PHPUnit_Framework_Constraint_FileExists extends PHPUnit_Framework_Constraint
17
{
18
    /**
19
     * Evaluates the constraint for parameter $other. Returns true if the
20
     * constraint is met, false otherwise.
21
     *
22
     * @param mixed $other Value or object to evaluate.
23
     *
24
     * @return bool
25
     */
26
    protected function matches($other)
27
    {
28
        return file_exists($other);
29
    }
30
 
31
    /**
32
     * Returns the description of the failure
33
     *
34
     * The beginning of failure messages is "Failed asserting that" in most
35
     * cases. This method should return the second part of that sentence.
36
     *
37
     * @param mixed $other Evaluated value or object.
38
     *
39
     * @return string
40
     */
41
    protected function failureDescription($other)
42
    {
43
        return sprintf(
44
            'file "%s" exists',
45
            $other
46
        );
47
    }
48
 
49
    /**
50
     * Returns a string representation of the constraint.
51
     *
52
     * @return string
53
     */
54
    public function toString()
55
    {
56
        return 'file exists';
57
    }
58
}