Skip to content

Commit d8505d3

Browse files
committed
* Renamed VerifyObject.php to VerifyBaseObject.php
* Add use function statements * Updated supported_verifiers.md
1 parent d5ee0b8 commit d8505d3

12 files changed

Lines changed: 263 additions & 245 deletions

docs/supported_verifiers.md

Lines changed: 92 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -17,81 +17,107 @@ notSameSize
1717
sameSize
1818
```
1919

20+
### Callable
21+
```
22+
throws
23+
doesNotThrow
24+
```
25+
26+
### Class
27+
```
28+
hasAttribute
29+
hasStaticAttribute
30+
notHasAttribute
31+
notHasStaticAttribute
32+
```
33+
2034
### Directory
2135
```
22-
directoryDoesNotExist
23-
directoryExists
24-
directoryIsNotReadable
25-
directoryIsNotWritable
26-
directoryIsReadable
27-
directoryIsWritable
36+
doesNotExist
37+
exists
38+
isNotReadable
39+
isNotWritable
40+
isReadable
41+
isWritable
2842
```
43+
2944
### File
3045
```
31-
setIsFileExpectation
46+
doesNotExists
3247
equals
33-
notEquals
48+
equalsCanonicalizing
49+
equalsIgnoringCase
3450
exists
35-
notExists
51+
isNotReadable
52+
isNotWritable
53+
isReadable
54+
isWritable
55+
notEquals
56+
notEqualsCanonicalizing
57+
notEqualsIgnoringCase
58+
```
59+
60+
### JsonFile
61+
```
3662
equalsJsonFile
37-
equalsXmlFile
38-
fileEqualsCanonicalizing
39-
fileEqualsIgnoringCase
40-
fileIsNotReadable
41-
fileIsNotWritable
42-
fileIsReadable
43-
fileIsWritable
44-
fileNotEqualsCanonicalizing
45-
fileNotEqualsIgnoringCase
46-
jsonFileNotEqualsJsonFile
47-
jsonStringNotEqualsJsonFile
63+
notEqualsJsonFile
64+
```
65+
66+
### JsonString
67+
```
68+
equalsJsonFile
69+
equalsJsonString
70+
notEqualsJsonFile
71+
notEqualsJsonString
4872
```
4973

5074
### Mixed
5175
```
52-
isEmpty
76+
empty
77+
equals
5378
equalsCanonicalizing
5479
equalsIgnoringCase
5580
equalsWithDelta
5681
false
5782
finite
5883
greaterThan
59-
greaterOrEquals
84+
greaterThanOrEqual
6085
infinite
61-
isInstanceOf
62-
array
63-
bool
64-
callable
86+
instanceOf
87+
isArray
88+
isBool
89+
isCallable
6590
isClosedResource
66-
float
67-
int
91+
isFloat
92+
isInt
6893
isIterable
69-
notArray
70-
notBool
71-
notCallable
94+
isNotArray
95+
isNotBool
96+
isNotCallable
7297
isNotClosedResource
73-
notFloat
74-
notInt
98+
isNotFloat
99+
isNotInt
75100
isNotIterable
76-
notNumeric
77-
notObject
78-
notResource
79-
notScalar
80-
notString
81-
numeric
82-
object
83-
resource
84-
scalar
85-
string
101+
isNotNumeric
102+
isNotObject
103+
isNotResource
104+
isNotScalar
105+
isNotString
106+
isNumeric
107+
isObject
108+
isResource
109+
isScalar
110+
isString
86111
lessThan
87-
lessOrEquals
112+
lessThanOrEqual
88113
nan
89114
notEmpty
115+
notEquals
90116
notEqualsCanonicalizing
91117
notEqualsIgnoringCase
92118
notEqualsWithDelta
93119
notFalse
94-
isNotInstanceOf
120+
notInstanceOf
95121
notNull
96122
notSame
97123
notTrue
@@ -103,55 +129,39 @@ true
103129

104130
### String
105131
```
106-
hasStaticAttribute
107-
notHasStaticAttribute
108-
json
109-
jsonStringNotEqualsJsonString
110-
notRegExp
111-
equalsJsonString
112-
regExp
113-
stringContainsString
114-
stringContainsStringIgnoringCase
115-
stringEqualsFileCanonicalizing
116-
stringEqualsFileIgnoringCase
117-
stringNotEqualsFileCanonicalizing
118-
stringNotEqualsFileIgnoringCase
119-
notEndsWith
132+
containsString
133+
containsStringIgnoringCase
134+
doesNotMatchRegExp
120135
endsWith
121136
equalsFile
137+
equalsFileCanonicalizing
138+
equalsFileIgnoringCase
139+
json
122140
matchesFormat
123141
matchesFormatFile
124-
stringNotContainsString
125-
stringNotContainsStringIgnoringCase
142+
matchesRegExp
143+
notContainsString
144+
notContainsStringIgnoringCase
145+
notEndsWith
146+
notEqualsFile
147+
notEqualsFileCanonicalizing
148+
notEqualsFileIgnoringCase
126149
notMatchesFormat
127150
notMatchesFormatFile
128-
notStartsWith
151+
startsNotWith
129152
startsWith
130-
notEqualsFile
131153
```
132154

133-
### Union
134-
##### Object/String
135-
```
136-
hasAttribute
137-
notHasAttribute
138-
```
139-
##### File/Directory
140-
```
141-
isNotReadable
142-
isNotWritable
143-
```
144-
145-
### Throwable
155+
### String
146156
```
147-
throws
148-
doesNotThrow
157+
equalsXmlFile
158+
notEqualsXmlFile
149159
```
150160

151-
### Xml
161+
### XmlString
152162
```
163+
equalsXmlFile
153164
equalsXmlString
154-
xmlFileNotEqualsXmlFile
155-
xmlStringNotEqualsXmlFile
156-
xmlStringNotEqualsXmlString
165+
notEqualsXmlFile
166+
notEqualsXmlString
157167
```

src/Codeception/Exception/InvalidVerifyException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Codeception\Exception;
44

55
use InvalidArgumentException;
6+
use function gettype;
7+
use function sprintf;
68

79
final class InvalidVerifyException extends InvalidArgumentException
810
{

src/Codeception/Verify/Verifiers/VerifyArray.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Codeception\Verify\Verify;
88
use Countable;
99
use PHPUnit\Framework\Assert;
10+
use function basename;
11+
use function is_array;
12+
use function is_iterable;
1013

1114
class VerifyArray extends Verify
1215
{
@@ -26,7 +29,7 @@ public function __construct($actual)
2629
parent::__construct($actual);
2730
return;
2831
}
29-
throw new InvalidVerifyException(basename(__CLASS__), $actual);
32+
throw new InvalidVerifyException(basename(self::class), $actual);
3033
}
3134

3235
/**

src/Codeception/Verify/Verifiers/VerifyObject.php renamed to src/Codeception/Verify/Verifiers/VerifyBaseObject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use Codeception\Verify\Verify;
66
use PHPUnit\Framework\Assert;
77

8-
class VerifyObject extends Verify
8+
class VerifyBaseObject extends Verify
99
{
1010
use VerifyDataTrait;
1111

1212
/**
13-
* VerifyObject constructor
13+
* VerifyBaseObject constructor
1414
*
1515
* @param object $object
1616
*/

src/Codeception/Verify/Verifiers/VerifyCallable.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ public function throws($throws = null, $message = false): self
3030

3131
try {
3232
call_user_func($this->actual);
33-
} catch (Throwable $e) {
33+
} catch (Throwable $exception) {
3434
if (!$throws) {
3535
return $this; // it throws
3636
}
3737

38-
$actualThrows = get_class($e);
39-
$actualMessage = $e->getMessage();
38+
$actualThrows = get_class($exception);
39+
$actualMessage = $exception->getMessage();
4040

41-
Assert::assertSame($throws, $actualThrows, "exception '$throws' was expected, but '$actualThrows' was thrown");
41+
Assert::assertSame($throws, $actualThrows, sprintf('exception \'%s\' was expected, but \'%s\' was thrown', $throws, $actualThrows));
4242

4343
if ($message) {
44-
Assert::assertSame($message, $actualMessage, "exception message '$message' was expected, but '$actualMessage' was received");
44+
Assert::assertSame($message, $actualMessage, sprintf('exception message \'%s\' was expected, but \'%s\' was received', $message, $actualMessage));
4545
}
4646
}
4747

48-
if (!isset($e)) {
49-
throw new ExpectationFailedException("exception '$throws' was not thrown as expected");
48+
if (!isset($exception)) {
49+
throw new ExpectationFailedException(sprintf('exception \'%s\' was not thrown as expected', $throws));
5050
}
5151

5252
return $this;
@@ -66,23 +66,24 @@ public function doesNotThrow($throws = null, $message = false): self
6666

6767
try {
6868
call_user_func($this->actual);
69-
} catch (Throwable $e) {
69+
} catch (Throwable $exception) {
7070
if (!$throws) {
7171
throw new ExpectationFailedException('exception was not expected to be thrown');
7272
}
7373

74-
$actualThrows = get_class($e);
75-
$actualMessage = $e->getMessage();
74+
$actualThrows = get_class($exception);
75+
$actualMessage = $exception->getMessage();
7676

7777
if ($throws !== $actualThrows) {
7878
return $this;
7979
}
80+
8081
if (!$message) {
81-
throw new ExpectationFailedException("exception '$throws' was not expected to be thrown");
82+
throw new ExpectationFailedException(sprintf('exception \'%s\' was not expected to be thrown', $throws));
8283
}
8384

8485
if ($message === $actualMessage) {
85-
throw new ExpectationFailedException("exception '$throws' with message '$message' was not expected to be thrown");
86+
throw new ExpectationFailedException(sprintf('exception \'%s\' with message \'%s\' was not expected to be thrown', $throws, $message));
8687
}
8788
}
8889

src/Codeception/Verify/Verifiers/VerifyClass.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,41 +33,41 @@ public function hasAttribute(string $attributeName, string $message = ''): self
3333
}
3434

3535
/**
36-
* Verifies that a class does not have a specified attribute.
36+
* Verifies that a class has a specified static attribute.
3737
*
3838
* @param string $attributeName
3939
* @param string $message
4040
* @return self
4141
*/
42-
public function notHasAttribute(string $attributeName, string $message = ''): self
42+
public function hasStaticAttribute(string $attributeName, string $message = ''): self
4343
{
44-
Assert::assertClassNotHasAttribute($attributeName, $this->actual, $message);
44+
Assert::assertClassHasStaticAttribute($attributeName, $this->actual, $message);
4545
return $this;
4646
}
4747

4848
/**
49-
* Verifies that a class does not have a specified static attribute.
49+
* Verifies that a class does not have a specified attribute.
5050
*
5151
* @param string $attributeName
5252
* @param string $message
5353
* @return self
5454
*/
55-
public function notHasStaticAttribute(string $attributeName, string $message = ''): self
55+
public function notHasAttribute(string $attributeName, string $message = ''): self
5656
{
57-
Assert::assertClassNotHasStaticAttribute($attributeName, $this->actual, $message);
57+
Assert::assertClassNotHasAttribute($attributeName, $this->actual, $message);
5858
return $this;
5959
}
6060

6161
/**
62-
* Verifies that a class has a specified static attribute.
62+
* Verifies that a class does not have a specified static attribute.
6363
*
6464
* @param string $attributeName
6565
* @param string $message
6666
* @return self
6767
*/
68-
public function hasStaticAttribute(string $attributeName, string $message = ''): self
68+
public function notHasStaticAttribute(string $attributeName, string $message = ''): self
6969
{
70-
Assert::assertClassHasStaticAttribute($attributeName, $this->actual, $message);
70+
Assert::assertClassNotHasStaticAttribute($attributeName, $this->actual, $message);
7171
return $this;
7272
}
7373
}

0 commit comments

Comments
 (0)