11<?php
22
3+ declare (strict_types=1 );
4+
35namespace Codeception \Util \Shared ;
46
57use Codeception \PHPUnit \TestCase ;
6- use PHPUnit \Framework \Constraint \Constraint ;
8+ use PHPUnit \Framework \Assert as PHPUnitAssert ;
9+ use PHPUnit \Framework \Constraint \Constraint as PHPUnitConstraint ;
710use PHPUnit \Framework \Constraint \LogicalNot ;
811
912trait Asserts
1013{
1114 use InheritedAsserts;
1215
13- /**
14- * @param $arguments
15- * @param bool $not
16- */
17- protected function assert ($ arguments , $ not = false )
16+ protected function assert (array $ arguments , bool $ not = false )
1817 {
1918 $ not = $ not ? 'Not ' : '' ;
2019 $ method = ucfirst (array_shift ($ arguments ));
2120 if (($ method === 'True ' ) && $ not ) {
2221 $ method = 'False ' ;
2322 $ not = '' ;
2423 }
24+
2525 if (($ method === 'False ' ) && $ not ) {
2626 $ method = 'True ' ;
2727 $ not = '' ;
2828 }
2929
30- call_user_func_array ([' \PHPUnit\Framework\Assert ' , 'assert ' . $ not . $ method ], $ arguments );
30+ call_user_func_array ([PHPUnitAssert::class , 'assert ' . $ not . $ method ], $ arguments );
3131 }
3232
3333 protected function assertNot ($ arguments )
@@ -37,82 +37,66 @@ protected function assertNot($arguments)
3737
3838 /**
3939 * Asserts that a file does not exist.
40- *
41- * @param string $filename
42- * @param string $message
4340 */
44- protected function assertFileNotExists ($ filename , $ message = '' )
41+ protected function assertFileNotExists (string $ filename , string $ message = '' )
4542 {
46- TestCase::assertFileNotExists ($ filename , $ message );
43+ TestCase::assertFileDoesNotExist ($ filename , $ message );
4744 }
4845
4946 /**
5047 * Asserts that a value is greater than or equal to another value.
5148 *
52- * @param $expected
53- * @param $actual
54- * @param string $message
49+ * @param mixed $expected
50+ * @param mixed $actual
5551 */
56- protected function assertGreaterOrEquals ($ expected , $ actual , $ message = '' )
52+ protected function assertGreaterOrEquals ($ expected , $ actual , string $ message = '' )
5753 {
5854 TestCase::assertGreaterThanOrEqual ($ expected , $ actual , $ message );
5955 }
6056
6157 /**
6258 * Asserts that a variable is empty.
6359 *
64- * @param $actual
65- * @param string $message
60+ * @param mixed $actual
6661 */
67- protected function assertIsEmpty ($ actual , $ message = '' )
62+ protected function assertIsEmpty ($ actual , string $ message = '' )
6863 {
6964 TestCase::assertEmpty ($ actual , $ message );
7065 }
7166
7267 /**
7368 * Asserts that a value is smaller than or equal to another value.
7469 *
75- * @param $expected
76- * @param $actual
77- * @param string $message
70+ * @param mixed $expected
71+ * @param mixed $actual
7872 */
79- protected function assertLessOrEquals ($ expected , $ actual , $ message = '' )
73+ protected function assertLessOrEquals ($ expected , $ actual , string $ message = '' )
8074 {
8175 TestCase::assertLessThanOrEqual ($ expected , $ actual , $ message );
8276 }
8377
8478 /**
8579 * Asserts that a string does not match a given regular expression.
86- *
87- * @param string $pattern
88- * @param string $string
89- * @param string $message
9080 */
91- protected function assertNotRegExp ($ pattern , $ string , $ message = '' )
81+ protected function assertNotRegExp (string $ pattern , string $ string , string $ message = '' )
9282 {
93- TestCase::assertNotRegExp ($ pattern , $ string , $ message );
83+ TestCase::assertDoesNotMatchRegularExpression ($ pattern , $ string , $ message );
9484 }
9585
9686 /**
9787 * Asserts that a string matches a given regular expression.
98- *
99- * @param string $pattern
100- * @param string $string
101- * @param string $message
10288 */
103- protected function assertRegExp ($ pattern , $ string , $ message = '' )
89+ protected function assertRegExp (string $ pattern , string $ string , string $ message = '' )
10490 {
105- TestCase::assertRegExp ($ pattern , $ string , $ message );
91+ TestCase::assertMatchesRegularExpression ($ pattern , $ string , $ message );
10692 }
10793
10894 /**
10995 * Evaluates a PHPUnit\Framework\Constraint matcher object.
11096 *
111- * @param $value
112- * @param Constraint $constraint
113- * @param string $message
97+ * @param mixed $value
11498 */
115- protected function assertThatItsNot ($ value , $ constraint , $ message = '' )
99+ protected function assertThatItsNot ($ value , PHPUnitConstraint $ constraint , string $ message = '' )
116100 {
117101 $ constraint = new LogicalNot ($ constraint );
118102 TestCase::assertThat ($ value , $ constraint , $ message );
0 commit comments