OSDN Git Service

Добавлена возможность создавать новую запись предмета оборудования на основании уже...
[invent/invent.git] / vendor / codeception / lib-asserts / src / Codeception / Util / Shared / Asserts.php
1 <?php
2
3 namespace Codeception\Util\Shared;
4
5 use Codeception\PHPUnit\TestCase;
6 use PHPUnit\Framework\Constraint\Constraint;
7 use PHPUnit\Framework\Constraint\LogicalNot;
8
9 trait Asserts
10 {
11     use InheritedAsserts;
12
13     /**
14      * @param $arguments
15      * @param bool $not
16      */
17     protected function assert($arguments, $not = false)
18     {
19         $not = $not ? 'Not' : '';
20         $method = ucfirst(array_shift($arguments));
21         if (($method === 'True') && $not) {
22             $method = 'False';
23             $not = '';
24         }
25         if (($method === 'False') && $not) {
26             $method = 'True';
27             $not = '';
28         }
29
30         call_user_func_array(['\PHPUnit\Framework\Assert', 'assert' . $not . $method], $arguments);
31     }
32
33     protected function assertNot($arguments)
34     {
35         $this->assert($arguments, true);
36     }
37
38     /**
39      * Asserts that a file does not exist.
40      *
41      * @param string $filename
42      * @param string $message
43      */
44     protected function assertFileNotExists($filename, $message = '')
45     {
46         TestCase::assertFileNotExists($filename, $message);
47     }
48
49     /**
50      * Asserts that a value is greater than or equal to another value.
51      *
52      * @param $expected
53      * @param $actual
54      * @param string $message
55      */
56     protected function assertGreaterOrEquals($expected, $actual, $message = '')
57     {
58         TestCase::assertGreaterThanOrEqual($expected, $actual, $message);
59     }
60
61     /**
62      * Asserts that a variable is empty.
63      *
64      * @param $actual
65      * @param string $message
66      */
67     protected function assertIsEmpty($actual, $message = '')
68     {
69         TestCase::assertEmpty($actual, $message);
70     }
71
72     /**
73      * Asserts that a value is smaller than or equal to another value.
74      *
75      * @param $expected
76      * @param $actual
77      * @param string $message
78      */
79     protected function assertLessOrEquals($expected, $actual, $message = '')
80     {
81         TestCase::assertLessThanOrEqual($expected, $actual, $message);
82     }
83
84     /**
85      * Asserts that a string does not match a given regular expression.
86      *
87      * @param string $pattern
88      * @param string $string
89      * @param string $message
90      */
91     protected function assertNotRegExp($pattern, $string, $message = '')
92     {
93         TestCase::assertNotRegExp($pattern, $string, $message);
94     }
95
96     /**
97      * Asserts that a string matches a given regular expression.
98      *
99      * @param string $pattern
100      * @param string $string
101      * @param string $message
102      */
103     protected function assertRegExp($pattern, $string, $message = '')
104     {
105         TestCase::assertRegExp($pattern, $string, $message);
106     }
107
108     /**
109      * Evaluates a PHPUnit\Framework\Constraint matcher object.
110      *
111      * @param $value
112      * @param Constraint $constraint
113      * @param string $message
114      */
115     protected function assertThatItsNot($value, $constraint, $message = '')
116     {
117         $constraint = new LogicalNot($constraint);
118         TestCase::assertThat($value, $constraint, $message);
119     }
120 }