├── tests
├── assets
│ ├── format-file.txt
│ ├── json-test-file.json
│ ├── equal-json-test-file.json
│ └── xml-test-file.xml
├── InheritanceTest.php
├── ExpectTest.php
└── VerifyTest.php
├── .gitignore
├── phpunit.xml
├── src
└── Codeception
│ ├── Exception
│ └── InvalidVerifyException.php
│ ├── bootstrap.php
│ └── Verify
│ ├── Verifiers
│ ├── VerifyCallable.php
│ ├── VerifyXmlFile.php
│ ├── VerifyJsonFile.php
│ ├── VerifyDataTrait.php
│ ├── VerifyJsonString.php
│ ├── VerifyBaseObject.php
│ ├── VerifyXmlString.php
│ ├── VerifyDirectory.php
│ ├── VerifyFile.php
│ ├── VerifyArray.php
│ ├── VerifyString.php
│ ├── VerifyAny.php
│ └── VerifyMixed.php
│ ├── Expectations
│ ├── ExpectCallable.php
│ ├── ExpectXmlFile.php
│ ├── ExpectJsonFile.php
│ ├── ExpectDataTrait.php
│ ├── ExpectJsonString.php
│ ├── ExpectClass.php
│ ├── ExpectBaseObject.php
│ ├── ExpectXmlString.php
│ ├── ExpectDirectory.php
│ ├── ExpectFile.php
│ ├── ExpectArray.php
│ ├── ExpectString.php
│ ├── ExpectAny.php
│ └── ExpectMixed.php
│ ├── Asserts
│ └── AssertThrows.php
│ ├── Verify.php
│ └── Expect.php
├── .github
└── workflows
│ └── main.yml
├── composer.json
├── LICENSE
├── CHANGELOG.md
├── docs
├── supported_verifiers.md
└── supported_expectations.md
├── README.md
└── UPGRADE.md
/tests/assets/format-file.txt:
--------------------------------------------------------------------------------
1 | %i
--------------------------------------------------------------------------------
/tests/assets/json-test-file.json:
--------------------------------------------------------------------------------
1 | {
2 | "some" : "data"
3 | }
--------------------------------------------------------------------------------
/tests/assets/equal-json-test-file.json:
--------------------------------------------------------------------------------
1 | {
2 | "some" : "data"
3 | }
--------------------------------------------------------------------------------
/tests/assets/xml-test-file.xml:
--------------------------------------------------------------------------------
1 | BazBaz
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor
2 | .idea
3 | .phpunit.result.cache
4 | composer.lock
5 | composer.phar
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | tests
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/Codeception/Exception/InvalidVerifyException.php:
--------------------------------------------------------------------------------
1 | success();
20 |
21 | $myVerify::Mixed('this also')->notEquals('works');
22 |
23 | verify(new MyVerify())->instanceOf(Verify::class);
24 | }
25 | }
26 |
27 |
28 | final class MyVerify extends Verify
29 | {
30 | public function __construct($actual = null)
31 | {
32 | parent::__construct($actual);
33 | }
34 |
35 | public function success(string $message = ''): void
36 | {
37 | Assert::assertTrue(true, $message);
38 | }
39 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyCallable.php:
--------------------------------------------------------------------------------
1 | assertThrows($throws, $message);
30 | }
31 |
32 | /**
33 | * @param Exception|string|null $throws
34 | * @param string|false $message
35 | * @return $this
36 | */
37 | public function doesNotThrow($throws = null, $message = false): self
38 | {
39 | return $this->assertDoesNotThrow($throws, $message);
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectCallable.php:
--------------------------------------------------------------------------------
1 | assertDoesNotThrow($throws, $message);
29 | }
30 |
31 | /**
32 | * @param Exception|string|null $throws
33 | * @param string|false $message
34 | * @return ExpectCallable
35 | * @throws Throwable
36 | */
37 | public function toThrow($throws = null, $message = false): self
38 | {
39 | return $this->assertThrows($throws, $message);
40 | }
41 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2020 Codeception PHP Testing Framework
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyXmlFile.php:
--------------------------------------------------------------------------------
1 | actual, $message);
27 | return $this;
28 | }
29 |
30 | /**
31 | * Verifies that two XML files are not equal.
32 | *
33 | * @param string $expectedFile
34 | * @param string $message
35 | * @return self
36 | */
37 | public function notEqualsXmlFile(string $expectedFile, string $message = ''): self
38 | {
39 | Assert::assertXmlFileNotEqualsXmlFile($expectedFile, $this->actual, $message);
40 | return $this;
41 | }
42 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectXmlFile.php:
--------------------------------------------------------------------------------
1 | actual, $message);
27 | return $this;
28 | }
29 |
30 | /**
31 | * Expect that two XML files are equal.
32 | *
33 | * @param string $expectedFile
34 | * @param string $message
35 | * @return self
36 | */
37 | public function toEqualXmlFile(string $expectedFile, string $message = ''): self
38 | {
39 | Assert::assertXmlFileEqualsXmlFile($expectedFile, $this->actual, $message);
40 | return $this;
41 | }
42 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyJsonFile.php:
--------------------------------------------------------------------------------
1 | actual, $message);
27 | return $this;
28 | }
29 |
30 | /**
31 | * Verifies that two JSON files are not equal.
32 | *
33 | * @param string $expectedFile
34 | * @param string $message
35 | * @return self
36 | */
37 | public function notEqualsJsonFile(string $expectedFile, string $message = ''): self
38 | {
39 | Assert::assertJsonFileNotEqualsJsonFile($expectedFile, $this->actual, $message);
40 | return $this;
41 | }
42 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectJsonFile.php:
--------------------------------------------------------------------------------
1 | actual, $message);
27 | return $this;
28 | }
29 |
30 | /**
31 | * Expect that two JSON files are equal.
32 | *
33 | * @param string $expectedFile
34 | * @param string $message
35 | * @return self
36 | */
37 | public function toEqualJsonFile(string $expectedFile, string $message = ''): self
38 | {
39 | Assert::assertJsonFileEqualsJsonFile($expectedFile, $this->actual, $message);
40 | return $this;
41 | }
42 | }
--------------------------------------------------------------------------------
/tests/ExpectTest.php:
--------------------------------------------------------------------------------
1 | bar = 'baz';
16 |
17 | expect($object)->baseObjectToHaveProperty('bar');
18 |
19 | verify(function () use ($object): void {
20 | expect($object)->baseObjectToHaveProperty('foo', 'foobar');
21 | })->callableThrows(new ExpectationFailedException("foobar\nFailed asserting that object of class \"stdClass\" has property \"foo\"."));
22 | }
23 |
24 | public function testObjectNotToHaveProperty(): void
25 | {
26 | $object = new \Stdclass();
27 | $object->bar = 'baz';
28 |
29 | expect($object)->baseObjectNotToHaveProperty('foo');
30 |
31 | verify(function () use ($object): void {
32 | expect($object)->baseObjectNotToHaveProperty('bar', 'foobar');
33 | })->callableThrows(new ExpectationFailedException("foobar\nFailed asserting that object of class \"stdClass\" does not have property \"bar\"."));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 2.1
4 |
5 | * Added new expect-toBe and expect-notTo BDD Syntax.
6 | * Added full documentation about Expectations.
7 | * Fixed minor bugs.
8 | * Deleted RoboFile and VERSION file.
9 | * **BC:** `expect` function now works with expectations instead of verifiers.
10 |
11 | ## 2.0
12 |
13 | * Support for Chained Verifiers.
14 | * The Verify API is now fully based on the PHPUnit public API.
15 | * Improved IDE autocompletion depending on the type of data you want to verify
16 | * Simplified data validations.
17 | * Improved code quality, performance and maintainability.
18 | * See **BC** details in the UPGRADE.md file.
19 |
20 | ## 1.5
21 |
22 | * Support for full PHPUnit API `(42 new verifiers!)`
23 | * Updated `supported_verifiers.md` documentation.
24 |
25 | ## 1.4
26 |
27 | * Improved code quality and maintainability.
28 | * Used strict types and namespaces.
29 | Created exception `InvalidVerifyException.php` in case verify is used with some invalid data.
30 | * Added documentation for all verifiers.
31 | * Divided the verifiers into traits depending on the type of data they verify.
32 | * Added data validations with php issers functions and instanceof.
33 |
34 | * **BC:** `equalXMLStructure` and its corresponding test were removed.
35 | * **BC:** hasntKey verifier renamed to hasNotKey for clarity.
36 | * **BC:** Removed support for PHP 7.0 and its corresponding versions of `PHPUnit` and `phpunit-wrapper`.
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyDataTrait.php:
--------------------------------------------------------------------------------
1 | actual, $message);
20 | return $this;
21 | }
22 |
23 | /**
24 | * Verifies that a file/dir is not writable.
25 | *
26 | * @param string $message
27 | * @return self
28 | */
29 | public function isNotWritable(string $message = ''): self
30 | {
31 | Assert::assertIsNotWritable($this->actual, $message);
32 | return $this;
33 | }
34 |
35 | /**
36 | * Verifies that a file/dir is readable.
37 | *
38 | * @param string $message
39 | * @return self
40 | */
41 | public function isReadable(string $message = ''): self
42 | {
43 | Assert::assertIsReadable($this->actual, $message);
44 | return $this;
45 | }
46 |
47 | /**
48 | * Verifies that a file/dir is writable.
49 | *
50 | * @param string $message
51 | * @return self
52 | */
53 | public function isWritable(string $message = ''): self
54 | {
55 | Assert::assertIsWritable($this->actual, $message);
56 | return $this;
57 | }
58 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectDataTrait.php:
--------------------------------------------------------------------------------
1 | actual, $message);
20 | return $this;
21 | }
22 |
23 | /**
24 | * Expect that a file/dir is not writable.
25 | *
26 | * @param string $message
27 | * @return self
28 | */
29 | public function notToBeWritable(string $message = ''): self
30 | {
31 | Assert::assertIsNotWritable($this->actual, $message);
32 | return $this;
33 | }
34 |
35 | /**
36 | * Expect that a file/dir is readable.
37 | *
38 | * @param string $message
39 | * @return self
40 | */
41 | public function toBeReadable(string $message = ''): self
42 | {
43 | Assert::assertIsReadable($this->actual, $message);
44 | return $this;
45 | }
46 |
47 | /**
48 | * Expect that a file/dir is writable.
49 | *
50 | * @param string $message
51 | * @return self
52 | */
53 | public function toBeWritable(string $message = ''): self
54 | {
55 | Assert::assertIsWritable($this->actual, $message);
56 | return $this;
57 | }
58 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectJsonString.php:
--------------------------------------------------------------------------------
1 | actual, $message);
27 | return $this;
28 | }
29 |
30 | /**
31 | * Expect that two given JSON encoded objects or arrays are not equal.
32 | *
33 | * @param string $expectedJson
34 | * @param string $message
35 | * @return self
36 | */
37 | public function notToEqualJsonString(string $expectedJson, string $message = ''): self
38 | {
39 | Assert::assertJsonStringNotEqualsJsonString($expectedJson, $this->actual, $message);
40 | return $this;
41 | }
42 |
43 | /**
44 | * Expect that the generated JSON encoded object and the content of the given file are equal.
45 | *
46 | * @param string $expectedFile
47 | * @param string $message
48 | * @return self
49 | */
50 | public function toEqualJsonFile(string $expectedFile, string $message = ''): self
51 | {
52 | Assert::assertJsonStringEqualsJsonFile($expectedFile, $this->actual, $message);
53 | return $this;
54 | }
55 |
56 | /**
57 | * Expect that two given JSON encoded objects or arrays are equal.
58 | *
59 | * @param string $expectedJson
60 | * @param string $message
61 | * @return self
62 | */
63 | public function toEqualJsonString(string $expectedJson, string $message = ''): self
64 | {
65 | Assert::assertJsonStringEqualsJsonString($expectedJson, $this->actual, $message);
66 | return $this;
67 | }
68 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyJsonString.php:
--------------------------------------------------------------------------------
1 | actual, $message);
27 | return $this;
28 | }
29 |
30 | /**
31 | * Verifies that two given JSON encoded objects or arrays are equal.
32 | *
33 | * @param string $expectedJson
34 | * @param string $message
35 | * @return self
36 | */
37 | public function equalsJsonString(string $expectedJson, string $message = ''): self
38 | {
39 | Assert::assertJsonStringEqualsJsonString($expectedJson, $this->actual, $message);
40 | return $this;
41 | }
42 |
43 | /**
44 | * Verifies that the generated JSON encoded object and the content of the given file are not equal.
45 | *
46 | * @param string $expectedFile
47 | * @param string $message
48 | * @return self
49 | */
50 | public function notEqualsJsonFile(string $expectedFile, string $message = ''): self
51 | {
52 | Assert::assertJsonStringNotEqualsJsonFile($expectedFile, $this->actual, $message);
53 | return $this;
54 | }
55 |
56 | /**
57 | * Verifies that two given JSON encoded objects or arrays are not equal.
58 | *
59 | * @param string $expectedJson
60 | * @param string $message
61 | * @return self
62 | */
63 | public function notEqualsJsonString(string $expectedJson, string $message = ''): self
64 | {
65 | Assert::assertJsonStringNotEqualsJsonString($expectedJson, $this->actual, $message);
66 | return $this;
67 | }
68 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectClass.php:
--------------------------------------------------------------------------------
1 | actual, $message);
35 | return $this;
36 | }
37 |
38 | /**
39 | * Expect that a class does not have a specified static attribute.
40 | *
41 | * @param string $attributeName
42 | * @param string $message
43 | * @return self
44 | */
45 | public function notToHaveStaticAttribute(string $attributeName, string $message = ''): self
46 | {
47 | Assert::assertClassNotHasStaticAttribute($attributeName, $this->actual, $message);
48 | return $this;
49 | }
50 |
51 | /**
52 | * Expect that a class has a specified attribute.
53 | *
54 | * @param string $attributeName
55 | * @param string $message
56 | * @return self
57 | */
58 | public function toHaveAttribute(string $attributeName, string $message = ''): self
59 | {
60 | Assert::assertClassHasAttribute($attributeName, $this->actual, $message);
61 | return $this;
62 | }
63 |
64 | /**
65 | * Expect that a class has a specified static attribute.
66 | *
67 | * @param string $attributeName
68 | * @param string $message
69 | * @return self
70 | */
71 | public function toHaveStaticAttribute(string $attributeName, string $message = ''): self
72 | {
73 | Assert::assertClassHasStaticAttribute($attributeName, $this->actual, $message);
74 | return $this;
75 | }
76 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyBaseObject.php:
--------------------------------------------------------------------------------
1 | actual, $message);
36 | return $this;
37 | }
38 |
39 | /**
40 | * Verifies that an object does not have a specified attribute.
41 | *
42 | * @deprecated Deprecated in favour of notHasProperty
43 | *
44 | * @param string $attributeName
45 | * @param string $message
46 | * @return self
47 | */
48 | public function notHasAttribute(string $attributeName, string $message = ''): self
49 | {
50 | Assert::assertObjectNotHasProperty($attributeName, $this->actual, $message);
51 | return $this;
52 | }
53 |
54 | /**
55 | * Verifies that an object has a specified property.
56 | *
57 | * @param string $propertyName
58 | * @param string $message
59 | * @return self
60 | */
61 | public function hasProperty(string $propertyName, string $message = ''): self
62 | {
63 | Assert::assertObjectHasProperty($propertyName, $this->actual, $message);
64 | return $this;
65 | }
66 |
67 | /**
68 | * Verifies that an object does not have a specified property.
69 | *
70 | * @param string $propertyName
71 | * @param string $message
72 | * @return self
73 | */
74 | public function notHasProperty(string $propertyName, string $message = ''): self
75 | {
76 | Assert::assertObjectNotHasProperty($propertyName, $this->actual, $message);
77 | return $this;
78 | }
79 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectBaseObject.php:
--------------------------------------------------------------------------------
1 | actual, $message);
36 | return $this;
37 | }
38 |
39 | /**
40 | * Expect that an object has a specified attribute.
41 | *
42 | * @deprecated Deprecated in favour of toHaveProperty
43 | *
44 | * @param string $attributeName
45 | * @param string $message
46 | * @return self
47 | */
48 | public function toHaveAttribute(string $attributeName, string $message = ''): self
49 | {
50 | Assert::assertObjectHasProperty($attributeName, $this->actual, $message);
51 | return $this;
52 | }
53 |
54 | /**
55 | * Expect that an object does not have a specified property.
56 | *
57 | * @param string $propertyName
58 | * @param string $message
59 | * @return self
60 | */
61 | public function notToHaveProperty(string $propertyName, string $message = ''): self
62 | {
63 | Assert::assertObjectNotHasProperty($propertyName, $this->actual, $message);
64 | return $this;
65 | }
66 |
67 | /**
68 | * Expect that an object has a specified property.
69 | *
70 | * @param string $propertyName
71 | * @param string $message
72 | * @return self
73 | */
74 | public function toHaveProperty(string $propertyName, string $message = ''): self
75 | {
76 | Assert::assertObjectHasProperty($propertyName, $this->actual, $message);
77 | return $this;
78 | }
79 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectXmlString.php:
--------------------------------------------------------------------------------
1 | actual, $message);
41 | return $this;
42 | }
43 |
44 | /**
45 | * Expect that two XML documents are not equal.
46 | *
47 | * @param DOMDocument|string $expectedXml
48 | * @param string $message
49 | * @return self
50 | */
51 | public function notToEqualXmlString($expectedXml, string $message = ''): self
52 | {
53 | Assert::assertXmlStringNotEqualsXmlString($expectedXml, $this->actual, $message);
54 | return $this;
55 | }
56 |
57 | /**
58 | * Expect that two XML documents are equal.
59 | *
60 | * @param string $expectedFile
61 | * @param string $message
62 | * @return self
63 | */
64 | public function toEqualXmlFile(string $expectedFile, string $message = ''): self
65 | {
66 | Assert::assertXmlStringEqualsXmlFile($expectedFile, $this->actual, $message);
67 | return $this;
68 | }
69 |
70 | /**
71 | * Expect that two XML documents are equal.
72 | *
73 | * @param DOMDocument|string $expectedXml
74 | * @param string $message
75 | * @return self
76 | */
77 | public function toEqualXmlString($expectedXml, string $message = ''): self
78 | {
79 | Assert::assertXmlStringEqualsXmlString($expectedXml, $this->actual, $message);
80 | return $this;
81 | }
82 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyXmlString.php:
--------------------------------------------------------------------------------
1 | actual, $message);
41 | return $this;
42 | }
43 |
44 | /**
45 | * Verifies that two XML documents are equal.
46 | *
47 | * @param DOMDocument|string $expectedXml
48 | * @param string $message
49 | * @return self
50 | */
51 | public function equalsXmlString($expectedXml, string $message = ''): self
52 | {
53 | Assert::assertXmlStringEqualsXmlString($expectedXml, $this->actual, $message);
54 | return $this;
55 | }
56 |
57 | /**
58 | * Verifies that two XML documents are not equal.
59 | *
60 | * @param string $expectedFile
61 | * @param string $message
62 | * @return self
63 | */
64 | public function notEqualsXmlFile(string $expectedFile, string $message = ''): self
65 | {
66 | Assert::assertXmlStringNotEqualsXmlFile($expectedFile, $this->actual, $message);
67 | return $this;
68 | }
69 |
70 | /**
71 | * Verifies that two XML documents are not equal.
72 | *
73 | * @param DOMDocument|string $expectedXml
74 | * @param string $message
75 | * @return self
76 | */
77 | public function notEqualsXmlString($expectedXml, string $message = ''): self
78 | {
79 | Assert::assertXmlStringNotEqualsXmlString($expectedXml, $this->actual, $message);
80 | return $this;
81 | }
82 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyDirectory.php:
--------------------------------------------------------------------------------
1 | actual, $message);
33 | return $this;
34 | }
35 |
36 | /**
37 | * Verifies that a directory exists.
38 | *
39 | * @param string $message
40 | * @return self
41 | */
42 | public function exists(string $message = ''): self
43 | {
44 | Assert::assertDirectoryExists($this->actual, $message);
45 | return $this;
46 | }
47 |
48 | /**
49 | * Verifies that a directory exists and is not readable.
50 | *
51 | * @param string $message
52 | * @return self
53 | */
54 | public function existsAndIsNotReadable(string $message = ''): self
55 | {
56 | Assert::assertDirectoryIsNotReadable($this->actual, $message);
57 | return $this;
58 | }
59 |
60 | /**
61 | * Verifies that a directory exists and is not writable.
62 | *
63 | * @param string $message
64 | * @return self
65 | */
66 | public function existsAndIsNotWritable(string $message = ''): self
67 | {
68 | Assert::assertDirectoryIsNotWritable($this->actual, $message);
69 | return $this;
70 | }
71 |
72 | /**
73 | * Verifies that a directory exists and is readable.
74 | *
75 | * @param string $message
76 | * @return self
77 | */
78 | public function existsAndIsReadable(string $message = ''): self
79 | {
80 | Assert::assertDirectoryIsReadable($this->actual, $message);
81 | return $this;
82 | }
83 |
84 | /**
85 | * Verifies that a directory exists and is writable.
86 | *
87 | * @param string $message
88 | * @return self
89 | */
90 | public function existsAndIsWritable(string $message = ''): self
91 | {
92 | Assert::assertDirectoryIsWritable($this->actual, $message);
93 | return $this;
94 | }
95 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectDirectory.php:
--------------------------------------------------------------------------------
1 | actual, $message);
33 | return $this;
34 | }
35 |
36 | /**
37 | * Expect that a directory exists.
38 | *
39 | * @param string $message
40 | * @return self
41 | */
42 | public function toExist(string $message = ''): self
43 | {
44 | Assert::assertDirectoryExists($this->actual, $message);
45 | return $this;
46 | }
47 |
48 | /**
49 | * Expect that a directory exists and is not readable.
50 | *
51 | * @param string $message
52 | * @return self
53 | */
54 | public function toExistAndNotToBeReadable(string $message = ''): self
55 | {
56 | Assert::assertDirectoryIsNotReadable($this->actual, $message);
57 | return $this;
58 | }
59 |
60 | /**
61 | * Expect that a directory exists and is not writable.
62 | *
63 | * @param string $message
64 | * @return self
65 | */
66 | public function toExistAndNotToBeWritable(string $message = ''): self
67 | {
68 | Assert::assertDirectoryIsNotWritable($this->actual, $message);
69 | return $this;
70 | }
71 |
72 | /**
73 | * Expect that a directory exists and is readable.
74 | *
75 | * @param string $message
76 | * @return self
77 | */
78 | public function toExistAndToBeReadable(string $message = ''): self
79 | {
80 | Assert::assertDirectoryIsReadable($this->actual, $message);
81 | return $this;
82 | }
83 |
84 | /**
85 | * Expect that a directory exists and is writable.
86 | *
87 | * @param string $message
88 | * @return self
89 | */
90 | public function toExistAndToBeWritable(string $message = ''): self
91 | {
92 | Assert::assertDirectoryIsWritable($this->actual, $message);
93 | return $this;
94 | }
95 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Asserts/AssertThrows.php:
--------------------------------------------------------------------------------
1 | getMessage();
18 | $throws = get_class($throws);
19 | }
20 |
21 | try {
22 | call_user_func($this->actual);
23 | } catch (Throwable $throwable) {
24 | if (!$throws) {
25 | return $this; // it throws
26 | }
27 |
28 | $actualThrows = get_class($throwable);
29 | $actualMessage = $throwable->getMessage();
30 |
31 | Assert::assertSame($throws, $actualThrows, sprintf("exception '%s' was expected, but '%s' was thrown", $throws, $actualThrows));
32 |
33 | if ($message) {
34 | Assert::assertSame($message, $actualMessage, sprintf("exception message '%s' was expected, but '%s' was received", $message, $actualMessage));
35 | }
36 | }
37 |
38 | if (!isset($throwable)) {
39 | throw new ExpectationFailedException(sprintf("exception '%s' was not thrown as expected", $throws));
40 | }
41 |
42 | return $this;
43 | }
44 |
45 | public function assertDoesNotThrow($throws = null, $message = false): self
46 | {
47 | if ($throws instanceof Exception) {
48 | $message = $throws->getMessage();
49 | $throws = get_class($throws);
50 | }
51 |
52 | try {
53 | call_user_func($this->actual);
54 | } catch (Throwable $exception) {
55 | if (!$throws) {
56 | throw new ExpectationFailedException('exception was not expected to be thrown');
57 | }
58 |
59 | $actualThrows = get_class($exception);
60 | $actualMessage = $exception->getMessage();
61 |
62 | if ($throws !== $actualThrows) {
63 | return $this;
64 | }
65 |
66 | if (!$message) {
67 | throw new ExpectationFailedException(sprintf("exception '%s' was not expected to be thrown", $throws));
68 | }
69 |
70 | if ($message === $actualMessage) {
71 | throw new ExpectationFailedException(sprintf("exception '%s' with message '%s' was not expected to be thrown", $throws, $message));
72 | }
73 | }
74 |
75 | return $this;
76 | }
77 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verify.php:
--------------------------------------------------------------------------------
1 | actual = $actual;
34 | }
35 |
36 | /**
37 | * @param mixed $actual
38 | * @return self
39 | */
40 | public function __invoke($actual): self
41 | {
42 | return $this($actual);
43 | }
44 |
45 | public static function File(string $filename): VerifyFile
46 | {
47 | return new VerifyFile($filename);
48 | }
49 |
50 | public static function JsonFile(string $filename): VerifyJsonFile
51 | {
52 | return new VerifyJsonFile($filename);
53 | }
54 |
55 | public static function JsonString(string $json): VerifyJsonString
56 | {
57 | return new VerifyJsonString($json);
58 | }
59 |
60 | public static function XmlFile(string $filename): VerifyXmlFile
61 | {
62 | return new VerifyXmlFile($filename);
63 | }
64 |
65 | public static function XmlString(string $xml): VerifyXmlString
66 | {
67 | return new VerifyXmlString($xml);
68 | }
69 |
70 | public static function BaseObject(object $object): VerifyBaseObject
71 | {
72 | return new VerifyBaseObject($object);
73 | }
74 |
75 | public static function Directory(string $directory): VerifyDirectory
76 | {
77 | return new VerifyDirectory($directory);
78 | }
79 |
80 | /**
81 | * @param array|ArrayAccess|Countable|iterable $array
82 | * @return VerifyArray
83 | */
84 | public static function Array($array): VerifyArray
85 | {
86 | return new VerifyArray($array);
87 | }
88 |
89 | public static function String(string $string): VerifyString
90 | {
91 | return new VerifyString($string);
92 | }
93 |
94 | public static function Callable(callable $callable): VerifyCallable
95 | {
96 | return new VerifyCallable($callable);
97 | }
98 |
99 | /**
100 | * @param mixed $actual
101 | * @return VerifyMixed
102 | */
103 | public static function Mixed($actual): VerifyMixed
104 | {
105 | return new VerifyMixed($actual);
106 | }
107 | }
--------------------------------------------------------------------------------
/docs/supported_verifiers.md:
--------------------------------------------------------------------------------
1 | ## Verifiers List
2 |
3 | `verify()` supports all the verifiers listed here! :rocket:
4 |
5 | ### Array
6 | ```
7 | contains
8 | containsEquals
9 | containsOnly
10 | containsOnlyInstancesOf
11 | count
12 | hasKey
13 | hasNotKey
14 | notContains
15 | notContainsEquals
16 | notContainsOnly
17 | notCount
18 | notSameSize
19 | sameSize
20 | ```
21 |
22 | ### BaseObject
23 | ```
24 | hasProperty
25 | notHasProperty
26 | ```
27 |
28 | ### Callable
29 | ```
30 | throws
31 | doesNotThrow
32 | ```
33 |
34 | ### Class
35 | ```
36 | hasAttribute
37 | hasStaticAttribute
38 | notHasAttribute
39 | notHasStaticAttribute
40 | ```
41 |
42 | ### Directory
43 | ```
44 | doesNotExist
45 | exists
46 | existsAndIsNotReadable
47 | existsAndIsNotWritable
48 | existsAndIsReadable
49 | existsAndIsWritable
50 | isNotReadable
51 | isNotWritable
52 | isReadable
53 | isWritable
54 | ```
55 |
56 | ### File
57 | ```
58 | doesNotExists
59 | equals
60 | equalsCanonicalizing
61 | equalsIgnoringCase
62 | exists
63 | existsAndIsNotReadable
64 | existsAndIsNotWritable
65 | existsAndIsReadable
66 | existsAndIsWritable
67 | isNotReadable
68 | isNotWritable
69 | isReadable
70 | isWritable
71 | notEquals
72 | notEqualsCanonicalizing
73 | notEqualsIgnoringCase
74 | ```
75 |
76 | ### JsonFile
77 | ```
78 | equalsJsonFile
79 | notEqualsJsonFile
80 | ```
81 |
82 | ### JsonString
83 | ```
84 | equalsJsonFile
85 | equalsJsonString
86 | notEqualsJsonFile
87 | notEqualsJsonString
88 | ```
89 |
90 | ### Mixed
91 | ```
92 | empty
93 | equals
94 | equalsCanonicalizing
95 | equalsIgnoringCase
96 | equalsWithDelta
97 | false
98 | finite
99 | greaterThan
100 | greaterThanOrEqual
101 | infinite
102 | instanceOf
103 | isArray
104 | isBool
105 | isCallable
106 | isClosedResource
107 | isFloat
108 | isInt
109 | isIterable
110 | isNotArray
111 | isNotBool
112 | isNotCallable
113 | isNotClosedResource
114 | isNotFloat
115 | isNotInt
116 | isNotIterable
117 | isNotNumeric
118 | isNotObject
119 | isNotResource
120 | isNotScalar
121 | isNotString
122 | isNumeric
123 | isObject
124 | isResource
125 | isScalar
126 | isString
127 | lessThan
128 | lessThanOrEqual
129 | nan
130 | notEmpty
131 | notEquals
132 | notEqualsCanonicalizing
133 | notEqualsIgnoringCase
134 | notEqualsWithDelta
135 | notFalse
136 | notInstanceOf
137 | notNull
138 | notSame
139 | notTrue
140 | null
141 | same
142 | true
143 | ```
144 |
145 | ### String
146 | ```
147 | containsString
148 | containsStringIgnoringCase
149 | doesNotMatchRegExp
150 | endsWith
151 | equalsFile
152 | equalsFileCanonicalizing
153 | equalsFileIgnoringCase
154 | json
155 | matchesFormat
156 | matchesFormatFile
157 | matchesRegExp
158 | notContainsString
159 | notContainsStringIgnoringCase
160 | notEndsWith
161 | notEqualsFile
162 | notEqualsFileCanonicalizing
163 | notEqualsFileIgnoringCase
164 | notMatchesFormat
165 | notMatchesFormatFile
166 | startsNotWith
167 | startsWith
168 | ```
169 |
170 | ### XmlFile
171 | ```
172 | equalsXmlFile
173 | notEqualsXmlFile
174 | ```
175 |
176 | ### XmlString
177 | ```
178 | equalsXmlFile
179 | equalsXmlString
180 | notEqualsXmlFile
181 | notEqualsXmlString
182 | ```
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expect.php:
--------------------------------------------------------------------------------
1 | actual = $actual;
34 | }
35 |
36 | /**
37 | * @param mixed $actual
38 | * @return self
39 | */
40 | public function __invoke($actual): self
41 | {
42 | return $this($actual);
43 | }
44 |
45 | public static function File(string $filename): ExpectFile
46 | {
47 | return new ExpectFile($filename);
48 | }
49 |
50 | public static function JsonFile(string $filename): ExpectJsonFile
51 | {
52 | return new ExpectJsonFile($filename);
53 | }
54 |
55 | public static function JsonString(string $json): ExpectJsonString
56 | {
57 | return new ExpectJsonString($json);
58 | }
59 |
60 | public static function XmlFile(string $filename): ExpectXmlFile
61 | {
62 | return new ExpectXmlFile($filename);
63 | }
64 |
65 | public static function XmlString(string $xml): ExpectXmlString
66 | {
67 | return new ExpectXmlString($xml);
68 | }
69 |
70 | public static function BaseObject(object $object): ExpectBaseObject
71 | {
72 | return new ExpectBaseObject($object);
73 | }
74 |
75 | public static function Class(string $className): ExpectClass
76 | {
77 | return new ExpectClass($className);
78 | }
79 |
80 | public static function Directory(string $directory): ExpectDirectory
81 | {
82 | return new ExpectDirectory($directory);
83 | }
84 |
85 | /**
86 | * @param array|ArrayAccess|Countable|iterable $array
87 | * @return ExpectArray
88 | */
89 | public static function Array($array): ExpectArray
90 | {
91 | return new ExpectArray($array);
92 | }
93 |
94 | public static function String(string $string): ExpectString
95 | {
96 | return new ExpectString($string);
97 | }
98 |
99 | public static function Callable(callable $callable): ExpectCallable
100 | {
101 | return new ExpectCallable($callable);
102 | }
103 |
104 | /**
105 | * @param mixed $actual
106 | * @return ExpectCallable
107 | */
108 | public static function Mixed($actual): ExpectCallable
109 | {
110 | return new ExpectCallable($actual);
111 | }
112 | }
--------------------------------------------------------------------------------
/docs/supported_expectations.md:
--------------------------------------------------------------------------------
1 | ## Expectations List
2 |
3 | `expect()` supports all the expectations listed here! :rocket:
4 |
5 | ### Array
6 | ```
7 | notToContain
8 | notToContainEqual
9 | notToContainOnly
10 | notToHaveCount
11 | notToHaveKey
12 | notToHaveSameSizeAs
13 | toContain
14 | toContainEqual
15 | toContainOnly
16 | toContainOnlyInstancesOf
17 | toHaveCount
18 | toHaveKey
19 | toHaveSameSizeAs
20 | ```
21 |
22 | ### BaseObject
23 | ```
24 | notToHaveProperty
25 | toHaveProperty
26 | ```
27 |
28 | ### Callable
29 | ```
30 | notToThrow
31 | toThrow
32 | ```
33 |
34 | ### Class
35 | ```
36 | notToHaveAttribute
37 | notToHaveStaticAttribute
38 | toHaveAttribute
39 | toHaveStaticAttribute
40 | ```
41 |
42 | ### Directory
43 | ```
44 | notToBeReadable
45 | notToBeWritable
46 | notToExist
47 | toBeReadable
48 | toBeWritable
49 | toExist
50 | toExistAndNotToBeReadable
51 | toExistAndNotToBeWritable
52 | toExistAndToBeReadable
53 | toExistAndToBeWritable
54 | ```
55 |
56 | ### File
57 | ```
58 | notToBeReadable
59 | notToBeWritable
60 | notToExist
61 | toBeEqual
62 | toBeEqualCanonicalizing
63 | toBeEqualIgnoringCase
64 | toBeReadable
65 | toBeWritable
66 | toExist
67 | toExistAndNotToBeReadable
68 | toExistAndNotToBeWritable
69 | toExistAndToBeReadable
70 | toExistAndToBeWritable
71 | toNotEqual
72 | toNotEqualCanonicalizing
73 | toNotEqualIgnoringCase
74 | ```
75 |
76 | ### JsonFile
77 | ```
78 | notToEqualJsonFile
79 | toEqualJsonFile
80 | ```
81 |
82 | ### JsonString
83 | ```
84 | notToEqualJsonFile
85 | notToEqualJsonString
86 | toEqualJsonFile
87 | toEqualJsonString
88 | ```
89 |
90 | ### Mixed
91 | ```
92 | notToBe
93 | notToBeArray
94 | notToBeBool
95 | notToBeCallable
96 | notToBeClosedResource
97 | notToBeEmpty
98 | notToBeFalse
99 | notToBeFloat
100 | notToBeInstanceOf
101 | notToBeInt
102 | notToBeIterable
103 | notToBeNull
104 | notToBeNumeric
105 | notToBeObject
106 | notToBeResource
107 | notToBeScalar
108 | notToBeString
109 | notToBeTrue
110 | notToEqual
111 | notToEqualCanonicalizing
112 | notToEqualIgnoringCase
113 | notToEqualWithDelta
114 | toBe
115 | toBeArray
116 | toBeBool
117 | toBeCallable
118 | toBeClosedResource
119 | toBeEmpty
120 | toBeFalse
121 | toBeFinite
122 | toBeFloat
123 | toBeGreaterThan
124 | toBeGreaterThanOrEqualTo
125 | toBeInfinite
126 | toBeInstanceOf
127 | toBeInt
128 | toBeIterable
129 | toBeLessThan
130 | toBeLessThanOrEqualTo
131 | toBeNan
132 | toBeNull
133 | toBeNumeric
134 | toBeObject
135 | toBeResource
136 | toBeScalar
137 | toBeString
138 | toBeTrue
139 | toEqual
140 | toEqualCanonicalizing
141 | toEqualIgnoringCase
142 | toEqualWithDelta
143 | ```
144 |
145 | ### String
146 | ```
147 | notToContainString
148 | notToContainStringIgnoringCase
149 | notToEndWith
150 | notToEqualFile
151 | notToEqualFileCanonicalizing
152 | notToEqualFileIgnoringCase
153 | notToMatchFormat
154 | notToMatchFormatFile
155 | notToMatchRegExp
156 | notToStartWith
157 | toBeJson
158 | toContainString
159 | toContainStringIgnoringCase
160 | toEndWith
161 | toEqualFile
162 | toEqualFileCanonicalizing
163 | toEqualFileIgnoringCase
164 | toMatchFormat
165 | toMatchFormatFile
166 | toMatchRegExp
167 | toStartWith
168 | ```
169 |
170 | ### XmlFile
171 | ```
172 | notToEqualXmlFile
173 | toEqualXmlFile
174 | ```
175 |
176 | ### XmlString
177 | ```
178 | notToEqualXmlFile
179 | notToEqualXmlString
180 | toEqualXmlFile
181 | toEqualXmlString
182 | ```
183 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Verify
2 | ======
3 |
4 | BDD Assertions for [PHPUnit][1] or [Codeception][2]
5 |
6 | [](https://packagist.org/packages/codeception/verify)
7 | [](https://packagist.org/packages/codeception/verify)
8 | [](https://travis-ci.org/Codeception/Verify)
9 | [](https://packagist.org/packages/codeception/verify)
10 | [](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
11 |
12 |
13 | This is very tiny wrapper for PHPUnit assertions, that are aimed to make tests a bit more readable.
14 | With [BDD][3] assertions influenced by [Chai][4], [Jasmine][5], and [RSpec][6] your assertions would be a bit closer to natural language.
15 |
16 | ⚠️ This is the Verify 2.0 documentation, to see v1.x docs click [here.](https://github.com/Codeception/Verify/tree/1.x)
17 |
18 | ## Installation
19 |
20 | *Requires PHP 7.4 or higher*
21 |
22 | ```
23 | composer require codeception/verify --dev
24 | ```
25 |
26 | > :arrow_up: **Upgrade from 1.x by following [the upgrade guide.][10]**
27 |
28 |
29 | ## Usage
30 |
31 | Use in any test `verify` function instead of `$this->assert*` methods:
32 |
33 | ```php
34 | use Codeception\Verify\Verify;
35 |
36 | $user = User::find(1);
37 |
38 | // equals
39 | verify($user->getName())->equals('davert');
40 |
41 | verify($user->getNumPosts())
42 | ->equals(5, 'user have 5 posts')
43 | ->notEquals(3);
44 |
45 | // contains
46 | Verify::Array($user->getRoles())
47 | ->contains('admin', 'first user is admin')
48 | ->notContains('banned', 'first user is not banned');
49 |
50 |
51 | // greater / less
52 | verify($user->getRate())
53 | ->greaterThan(5)
54 | ->lessThan(10)
55 | ->equals(7, 'first user rate is 7');
56 |
57 | // true / false / null
58 | verify($user->isAdmin())->true();
59 | verify($user->isBanned())->false();
60 | verify($user->invitedBy)->null();
61 | verify($user->getPosts())->notNull();
62 |
63 | // empty
64 | verify($user->getComments())->empty();
65 | verify($user->getRoles())->notEmpty();
66 |
67 | // throws
68 | Verify::Callable($callback)
69 | ->throws()
70 | ->throws(Exception::class)
71 | ->throws(Exception::class, 'exception message')
72 | ->throws(new Exception())
73 | ->throws(new Exception('message'));
74 |
75 | // does not throw
76 | Verify::Callable($callback)
77 | ->doesNotThrow()
78 | ->throws(Exception::class)
79 | ->doesNotThrow(new Exception());
80 |
81 | // and many more !
82 | ```
83 |
84 | > :page_facing_up: **See Verifiers full list [here.][7]**
85 |
86 | ## Alternative Syntax
87 |
88 | If you follow TDD/BDD you'd rather use `expect` instead of `verify`:
89 |
90 | ```php
91 | expect($user->getNumPosts())
92 | ->notToBeNull()
93 | ->toBeInt()
94 | ->toEqual(5, 'user have 5 posts');
95 | ```
96 | > :page_facing_up: **See Expectations full list [here.][8]**
97 | >
98 | Or `verify_that` which is just an alias function:
99 |
100 | ```php
101 | verify_that($user->getRate())->equals(7, 'first user rate is 7');
102 | ```
103 |
104 | ## Extending
105 |
106 | In order to add more assertions you can extend the abstract class `Verify`:
107 |
108 | ```php
109 | use Codeception\Verify\Verify;
110 | use PHPUnit\Framework\Assert;
111 |
112 | class MyVerify extends Verify {
113 |
114 | //you can type $actual to only receive a specific data type
115 |
116 | public function __construct($actual = null)
117 | {
118 | parent::__construct($actual);
119 | }
120 |
121 | public function success(string $message = '')
122 | {
123 | Assert::assertTrue(true, $message);
124 | }
125 |
126 | }
127 | ```
128 |
129 | And use it!
130 |
131 | ```php
132 | $myVerify = new MyVerify;
133 |
134 | $myVerify->success('it works!');
135 |
136 | $myVerify::Mixed('this also')->notEquals('works');
137 | ```
138 |
139 | ## License
140 |
141 | Verify is open-sourced software licensed under the [MIT][9] License.
142 | © Codeception PHP Testing Framework
143 |
144 | [1]: https://phpunit.de/
145 | [2]: https://codeception.com/
146 | [3]: https://en.wikipedia.org/wiki/Behavior-driven_development
147 | [4]: https://chaijs.com/
148 | [5]: https://jasmine.github.io/
149 | [6]: https://rspec.info/
150 | [7]: ./docs/supported_verifiers.md
151 | [8]: ./docs/supported_expectations.md
152 | [9]: ./LICENSE
153 | [10]: ./UPGRADE.md
154 |
--------------------------------------------------------------------------------
/UPGRADE.md:
--------------------------------------------------------------------------------
1 | UPGRADE FROM 1.X TO 2.X
2 | =======================
3 |
4 |
5 | PHP version
6 | ------
7 |
8 | * Removed support for `PHP 7.1` & `PHP 7.2`.
9 |
10 |
11 | Verify function
12 | -------
13 |
14 | In version `2.x`, `verifiers` can be used as classes. Each verifier class handles a specific type of data.
15 |
16 | Thanks to this you can enjoy an autocompletion of your `IDE` much more intelligent than before...
17 |
18 | That is why **we remove some global functions** that have a less intuitive behavior.
19 |
20 | According to the above:
21 |
22 | * `verify` no longer receives a `string $message` as a parameter, now each _**verifier**_ fulfills this function.
23 | * `verify_not` was deleted. Use `verify()->empty` instead.
24 | * `expect_that` and `expect_not` were deleted. Use `expect()->notEmpty` and `expect()->empty` instead.
25 | * `expect_file` and `setIsFileExpectation` were deleted. Use `Verify::File()` instead.
26 |
27 | Verifiers
28 | -------
29 |
30 | | Verify 1.x | Verify 2.x |
31 | |-------------------------------------------------|-------------------------------------------------|
32 | | `verify()->array` | `verify()->isArray` |
33 | | `verify()->bool` | `verify()->isBool` |
34 | | `verify()->callable` | `verify()->isCallable` |
35 | | `verify()->float` | `verify()->isFloat` |
36 | | `verify()->greaterOrEquals` | `verify()->greaterThanOrEqual` |
37 | | `verify()->int` | `verify()->isInt` |
38 | | `verify()->isEmpty` | `verify()->empty` |
39 | | `verify()->isInstanceOf` | `verify()->instanceOf` |
40 | | `verify()->isNotInstanceOf` | `verify()->notInstanceOf` |
41 | | `verify()->lessOrEquals` | `verify()->lessThanOrEqual` |
42 | | `verify()->notArray` | `verify()->isNotArray` |
43 | | `verify()->notBool` | `verify()->isNotBool` |
44 | | `verify()->notCallable` | `verify()->isNotCallable` |
45 | | `verify()->notFloat` | `verify()->isNotFloat` |
46 | | `verify()->notInt` | `verify()->isNotInt` |
47 | | `verify()->notNumeric` | `verify()->isNotNumeric` |
48 | | `verify()->notObject` | `verify()->isNotObject` |
49 | | `verify()->notResource` | `verify()->isNotResource` |
50 | | `verify()->notScalar` | `verify()->isNotScalar` |
51 | | `verify()->notString` | `verify()->isNotString` |
52 | | `verify()->numeric` | `verify()->isNumeric` |
53 | | `verify()->object` | `verify()->isObject` |
54 | | `verify()->resource` | `verify()->isResource` |
55 | | `verify()->scalar` | `verify()->isScalar` |
56 | | `verify()->string` | `verify()->isString` |
57 | | `verify()->hasAttribute` | `Verify()->baseObjectHasAttribute` |
58 | | `verify()->notHasAttribute` | `Verify()->baseObjectNotHasAttribute` |
59 | | `verify()->throws` | `Verify()->callableThrows` |
60 | | `verify()->doesNotThrow` | `Verify()->callableDoesNotThrow` |
61 | | `verify()->hasStaticAttribute` | `Verify()->classHasStaticAttribute` |
62 | | `verify()->notHasStaticAttribute` | `Verify()->classNotHasStaticAttribute` |
63 | | `verify()->hasAttribute` | `Verify()->classHasAttribute` |
64 | | `verify()->notHasAttribute` | `Verify()->classNotHasAttribute` |
65 | | `verify()->notExists` | `Verify()->fileDoesNotExists` |
66 | | `verify()->regExp` | `Verify()->stringMatchesRegExp` |
67 | | `verify()->notRegExp` | `Verify()->stringDoesNotMatchRegExp` |
68 | | `verify()->notStartsWith` | `Verify()->stringNotStartsWith` |
69 |
70 |
71 | Extending
72 | -------
73 |
74 | * `Codeception\Verify::$override` was removed, extend from abstract `Codeception\Verify\Verify` class instead.
75 |
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyFile.php:
--------------------------------------------------------------------------------
1 | actual, $message);
28 | return $this;
29 | }
30 |
31 | /**
32 | * Verifies that the contents of one file is equal to the contents of another file.
33 | *
34 | * @param string $expected
35 | * @param string $message
36 | * @return self
37 | */
38 | public function equals(string $expected, string $message = ''): self
39 | {
40 | Assert::assertFileEquals($expected, $this->actual, $message);
41 | return $this;
42 | }
43 |
44 | /**
45 | * Verifies that the contents of one file is equal to the contents of another file (canonicalizing).
46 | *
47 | * @param string $expected
48 | * @param string $message
49 | * @return self
50 | */
51 | public function equalsCanonicalizing(string $expected, string $message = ''): self
52 | {
53 | Assert::assertFileEqualsCanonicalizing($expected, $this->actual, $message);
54 | return $this;
55 | }
56 |
57 | /**
58 | * Verifies that the contents of one file is equal to the contents of another file (ignoring case).
59 | *
60 | * @param string $expected
61 | * @param string $message
62 | * @return self
63 | */
64 | public function equalsIgnoringCase(string $expected, string $message = ''): self
65 | {
66 | Assert::assertFileEqualsIgnoringCase($expected, $this->actual, $message);
67 | return $this;
68 | }
69 |
70 | /**
71 | * Verifies that a file exists.
72 | *
73 | * @param string $message
74 | * @return self
75 | */
76 | public function exists(string $message = ''): self
77 | {
78 | Assert::assertFileExists($this->actual, $message);
79 | return $this;
80 | }
81 |
82 | /**
83 | * Verifies that a file exists and is not readable.
84 | *
85 | * @param string $message
86 | * @return self
87 | */
88 | public function existsAndIsNotReadable(string $message = ''): self
89 | {
90 | Assert::assertFileIsNotReadable($this->actual, $message);
91 | return $this;
92 | }
93 |
94 | /**
95 | * Verifies that a file exists and is not writable.
96 | *
97 | * @param string $message
98 | * @return self
99 | */
100 | public function existsAndIsNotWritable(string $message = ''): self
101 | {
102 | Assert::assertFileIsNotWritable($this->actual, $message);
103 | return $this;
104 | }
105 |
106 | /**
107 | * Verifies that a file exists and is readable.
108 | *
109 | * @param string $message
110 | * @return self
111 | */
112 | public function existsAndIsReadable(string $message = ''): self
113 | {
114 | Assert::assertFileIsReadable($this->actual, $message);
115 | return $this;
116 | }
117 |
118 | /**
119 | * Verifies that a file exists and is writable.
120 | *
121 | * @param string $message
122 | * @return self
123 | */
124 | public function existsAndIsWritable(string $message = ''): self
125 | {
126 | Assert::assertFileIsWritable($this->actual, $message);
127 | return $this;
128 | }
129 |
130 | /**
131 | * Verifies that the contents of one file is not equal to the contents of another file.
132 | *
133 | * @param $expected
134 | * @param string $message
135 | * @return self
136 | */
137 | public function notEquals(string $expected, string $message = ''): self
138 | {
139 | Assert::assertFileNotEquals($expected, $this->actual, $message);
140 | return $this;
141 | }
142 |
143 | /**
144 | * Verifies that the contents of one file is not equal to the contents of another file (canonicalizing).
145 | *
146 | * @param $expected
147 | * @param string $message
148 | * @return self
149 | */
150 | public function notEqualsCanonicalizing(string $expected, string $message = ''): self
151 | {
152 | Assert::assertFileNotEqualsCanonicalizing($expected, $this->actual, $message);
153 | return $this;
154 | }
155 |
156 | /**
157 | * Verifies that the contents of one file is not equal to the contents of another file (ignoring case).
158 | *
159 | * @param $expected
160 | * @param string $message
161 | * @return self
162 | */
163 | public function notEqualsIgnoringCase(string $expected, string $message = ''): self
164 | {
165 | Assert::assertFileNotEqualsIgnoringCase($expected, $this->actual, $message);
166 | return $this;
167 | }
168 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectFile.php:
--------------------------------------------------------------------------------
1 | actual, $message);
28 | return $this;
29 | }
30 |
31 | /**
32 | * Expect that the contents of one file is equal to the contents of another file.
33 | *
34 | * @param string $expected
35 | * @param string $message
36 | * @return self
37 | */
38 | public function toBeEqual(string $expected, string $message = ''): self
39 | {
40 | Assert::assertFileEquals($expected, $this->actual, $message);
41 | return $this;
42 | }
43 |
44 | /**
45 | * Expect that the contents of one file is equal to the contents of another file (canonicalizing).
46 | *
47 | * @param string $expected
48 | * @param string $message
49 | * @return self
50 | */
51 | public function toBeEqualCanonicalizing(string $expected, string $message = ''): self
52 | {
53 | Assert::assertFileEqualsCanonicalizing($expected, $this->actual, $message);
54 | return $this;
55 | }
56 |
57 | /**
58 | * Expect that the contents of one file is equal to the contents of another file (ignoring case).
59 | *
60 | * @param string $expected
61 | * @param string $message
62 | * @return self
63 | */
64 | public function toBeEqualIgnoringCase(string $expected, string $message = ''): self
65 | {
66 | Assert::assertFileEqualsIgnoringCase($expected, $this->actual, $message);
67 | return $this;
68 | }
69 |
70 | /**
71 | * Expect that a file exists.
72 | *
73 | * @param string $message
74 | * @return self
75 | */
76 | public function toExist(string $message = ''): self
77 | {
78 | Assert::assertFileExists($this->actual, $message);
79 | return $this;
80 | }
81 |
82 | /**
83 | * Expect that a file exists and is not readable.
84 | *
85 | * @param string $message
86 | * @return self
87 | */
88 | public function toExistAndNotToBeReadable(string $message = ''): self
89 | {
90 | Assert::assertFileIsNotReadable($this->actual, $message);
91 | return $this;
92 | }
93 |
94 | /**
95 | * Expect that a file exists and is not writable.
96 | *
97 | * @param string $message
98 | * @return self
99 | */
100 | public function toExistAndNotToBeWritable(string $message = ''): self
101 | {
102 | Assert::assertFileIsNotWritable($this->actual, $message);
103 | return $this;
104 | }
105 |
106 | /**
107 | * Expect that a file exists and is readable.
108 | *
109 | * @param string $message
110 | * @return self
111 | */
112 | public function toExistAndToBeReadable(string $message = ''): self
113 | {
114 | Assert::assertFileIsReadable($this->actual, $message);
115 | return $this;
116 | }
117 |
118 | /**
119 | * Expect that a file exists and is writable.
120 | *
121 | * @param string $message
122 | * @return self
123 | */
124 | public function toExistAndToBeWritable(string $message = ''): self
125 | {
126 | Assert::assertFileIsWritable($this->actual, $message);
127 | return $this;
128 | }
129 |
130 | /**
131 | * Expect that the contents of one file is not equal to the contents of another file.
132 | *
133 | * @param $expected
134 | * @param string $message
135 | * @return self
136 | */
137 | public function toNotEqual(string $expected, string $message = ''): self
138 | {
139 | Assert::assertFileNotEquals($expected, $this->actual, $message);
140 | return $this;
141 | }
142 |
143 | /**
144 | * Expect that the contents of one file is not equal to the contents of another file (canonicalizing).
145 | *
146 | * @param $expected
147 | * @param string $message
148 | * @return self
149 | */
150 | public function toNotEqualCanonicalizing(string $expected, string $message = ''): self
151 | {
152 | Assert::assertFileNotEqualsCanonicalizing($expected, $this->actual, $message);
153 | return $this;
154 | }
155 |
156 | /**
157 | * Expect that the contents of one file is not equal to the contents of another file (ignoring case).
158 | *
159 | * @param $expected
160 | * @param string $message
161 | * @return self
162 | */
163 | public function toNotEqualIgnoringCase(string $expected, string $message = ''): self
164 | {
165 | Assert::assertFileNotEqualsIgnoringCase($expected, $this->actual, $message);
166 | return $this;
167 | }
168 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyArray.php:
--------------------------------------------------------------------------------
1 | actual, $message);
48 | return $this;
49 | }
50 |
51 | public function containsEquals($needle, string $message = ''): self
52 | {
53 | Assert::assertContainsEquals($needle, $this->actual, $message);
54 | return $this;
55 | }
56 |
57 | /**
58 | * Verifies that a haystack contains only values of a given type.
59 | *
60 | * @param string $type
61 | * @param bool|null $isNativeType
62 | * @param string $message
63 | * @return self
64 | */
65 | public function containsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
66 | {
67 | Assert::assertContainsOnly($type, $this->actual, $isNativeType, $message);
68 | return $this;
69 | }
70 |
71 | /**
72 | * Verifies that a haystack contains only instances of a given class name.
73 | *
74 | * @param string $className
75 | * @param string $message
76 | * @return self
77 | */
78 | public function containsOnlyInstancesOf(string $className, string $message = ''): self
79 | {
80 | Assert::assertContainsOnlyInstancesOf($className, $this->actual, $message);
81 | return $this;
82 | }
83 |
84 | /**
85 | * Verifies the number of elements of an array, Countable or Traversable.
86 | *
87 | * @param int $expectedCount
88 | * @param string $message
89 | * @return self
90 | */
91 | public function count(int $expectedCount, string $message = ''): self
92 | {
93 | Assert::assertCount($expectedCount, $this->actual, $message);
94 | return $this;
95 | }
96 |
97 | /**
98 | * Verifies that an array has a specified key.
99 | *
100 | * @param int|string $key
101 | * @param string $message
102 | * @return self
103 | */
104 | public function hasKey($key, string $message = ''): self
105 | {
106 | Assert::assertArrayHasKey($key, $this->actual, $message);
107 | return $this;
108 | }
109 |
110 | /**
111 | * Verifies that an array does not have a specified key.
112 | *
113 | * @param int|string $key
114 | * @param string $message
115 | * @return self
116 | */
117 | public function hasNotKey($key, string $message = ''): self
118 | {
119 | Assert::assertArrayNotHasKey($key, $this->actual, $message);
120 | return $this;
121 | }
122 |
123 | /**
124 | * Verifies that a haystack does not contain a needle.
125 | *
126 | * @param $needle
127 | * @param string $message
128 | * @return self
129 | */
130 | public function notContains($needle, string $message = ''): self
131 | {
132 | Assert::assertNotContains($needle, $this->actual, $message);
133 | return $this;
134 | }
135 |
136 | public function notContainsEquals($needle, string $message = ''): self
137 | {
138 | Assert::assertNotContainsEquals($needle, $this->actual, $message);
139 | return $this;
140 | }
141 |
142 | /**
143 | * Verifies that a haystack does not contain only values of a given type.
144 | *
145 | * @param string $type
146 | * @param bool|null $isNativeType
147 | * @param string $message
148 | * @return self
149 | */
150 | public function notContainsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
151 | {
152 | Assert::assertNotContainsOnly($type, $this->actual, $isNativeType, $message);
153 | return $this;
154 | }
155 |
156 | /**
157 | * Verifies the number of elements of an array, Countable or Traversable.
158 | *
159 | * @param int $expectedCount
160 | * @param string $message
161 | * @return self
162 | */
163 | public function notCount(int $expectedCount, string $message = ''): self
164 | {
165 | Assert::assertNotCount($expectedCount, $this->actual, $message);
166 | return $this;
167 | }
168 |
169 | /**
170 | * Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.
171 | *
172 | * @param Countable|iterable $expected
173 | * @param string $message
174 | * @return self
175 | */
176 | public function notSameSize($expected, string $message = ''): self
177 | {
178 | Assert::assertNotSameSize($expected, $this->actual, $message);
179 | return $this;
180 | }
181 |
182 | /**
183 | * Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is the same.
184 | *
185 | * @param Countable|iterable $expected
186 | * @param string $message
187 | * @return self
188 | */
189 | public function sameSize($expected, string $message = ''): self
190 | {
191 | Assert::assertSameSize($expected, $this->actual, $message);
192 | return $this;
193 | }
194 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectArray.php:
--------------------------------------------------------------------------------
1 | actual, $message);
48 | return $this;
49 | }
50 |
51 | public function notToContainEqual($needle, string $message = ''): self
52 | {
53 | Assert::assertNotContainsEquals($needle, $this->actual, $message);
54 | return $this;
55 | }
56 |
57 | /**
58 | * Expect that a haystack does not contain only values of a given type.
59 | *
60 | * @param string $type
61 | * @param bool|null $isNativeType
62 | * @param string $message
63 | * @return self
64 | */
65 | public function notToContainOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
66 | {
67 | Assert::assertNotContainsOnly($type, $this->actual, $isNativeType, $message);
68 | return $this;
69 | }
70 |
71 | /**
72 | * Expect the number of elements of an array, Countable or Traversable.
73 | *
74 | * @param int $expectedCount
75 | * @param string $message
76 | * @return self
77 | */
78 | public function notToHaveCount(int $expectedCount, string $message = ''): self
79 | {
80 | Assert::assertNotCount($expectedCount, $this->actual, $message);
81 | return $this;
82 | }
83 |
84 | /**
85 | * Expect that an array does not have a specified key.
86 | *
87 | * @param int|string $key
88 | * @param string $message
89 | * @return self
90 | */
91 | public function notToHaveKey($key, string $message = ''): self
92 | {
93 | Assert::assertArrayNotHasKey($key, $this->actual, $message);
94 | return $this;
95 | }
96 |
97 | /**
98 | * Expect that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.
99 | *
100 | * @param Countable|iterable $expected
101 | * @param string $message
102 | * @return self
103 | */
104 | public function notToHaveSameSizeAs($expected, string $message = ''): self
105 | {
106 | Assert::assertNotSameSize($expected, $this->actual, $message);
107 | return $this;
108 | }
109 |
110 | /**
111 | * Expect that a haystack contains a needle.
112 | *
113 | * @param $needle
114 | * @param string $message
115 | * @return self
116 | */
117 | public function toContain($needle, string $message = ''): self
118 | {
119 | Assert::assertContains($needle, $this->actual, $message);
120 | return $this;
121 | }
122 |
123 | public function toContainEqual($needle, string $message = ''): self
124 | {
125 | Assert::assertContainsEquals($needle, $this->actual, $message);
126 | return $this;
127 | }
128 |
129 | /**
130 | * Expect that a haystack contains only values of a given type.
131 | *
132 | * @param string $type
133 | * @param bool|null $isNativeType
134 | * @param string $message
135 | * @return self
136 | */
137 | public function toContainOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
138 | {
139 | Assert::assertContainsOnly($type, $this->actual, $isNativeType, $message);
140 | return $this;
141 | }
142 |
143 | /**
144 | * Expect that a haystack contains only instances of a given class name.
145 | *
146 | * @param string $className
147 | * @param string $message
148 | * @return self
149 | */
150 | public function toContainOnlyInstancesOf(string $className, string $message = ''): self
151 | {
152 | Assert::assertContainsOnlyInstancesOf($className, $this->actual, $message);
153 | return $this;
154 | }
155 |
156 | /**
157 | * Expect the number of elements of an array, Countable or Traversable.
158 | *
159 | * @param int $expectedCount
160 | * @param string $message
161 | * @return self
162 | */
163 | public function toHaveCount(int $expectedCount, string $message = ''): self
164 | {
165 | Assert::assertCount($expectedCount, $this->actual, $message);
166 | return $this;
167 | }
168 |
169 | /**
170 | * Expect that an array has a specified key.
171 | *
172 | * @param int|string $key
173 | * @param string $message
174 | * @return self
175 | */
176 | public function toHaveKey($key, string $message = ''): self
177 | {
178 | Assert::assertArrayHasKey($key, $this->actual, $message);
179 | return $this;
180 | }
181 |
182 | /**
183 | * Expect that the size of two arrays (or `Countable` or `Traversable` objects) is the same.
184 | *
185 | * @param Countable|iterable $expected
186 | * @param string $message
187 | * @return self
188 | */
189 | public function toHaveSameSizeAs($expected, string $message = ''): self
190 | {
191 | Assert::assertSameSize($expected, $this->actual, $message);
192 | return $this;
193 | }
194 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectString.php:
--------------------------------------------------------------------------------
1 | actual, $message);
20 | return $this;
21 | }
22 |
23 | public function notToContainStringIgnoringCase(string $needle, string $message = ''): self
24 | {
25 | Assert::assertStringNotContainsStringIgnoringCase($needle, $this->actual, $message);
26 | return $this;
27 | }
28 |
29 | /**
30 | * Expect that a string ends not with a given suffix.
31 | *
32 | * @param string $suffix
33 | * @param string $message
34 | * @return self
35 | */
36 | public function notToEndWith(string $suffix, string $message = ''): self
37 | {
38 | Assert::assertStringEndsNotWith($suffix, $this->actual, $message);
39 | return $this;
40 | }
41 |
42 | /**
43 | * Expect that the contents of a string is not equal to the contents of a file.
44 | *
45 | * @param string $expectedFile
46 | * @param string $message
47 | * @return self
48 | */
49 | public function notToEqualFile(string $expectedFile, string $message = ''): self
50 | {
51 | Assert::assertStringNotEqualsFile($expectedFile, $this->actual, $message);
52 | return $this;
53 | }
54 |
55 | /**
56 | * Expect that the contents of a string is not equal to the contents of a file (canonicalizing).
57 | *
58 | * @param string $expectedFile
59 | * @param string $message
60 | * @return self
61 | */
62 | public function notToEqualFileCanonicalizing(string $expectedFile, string $message = ''): self
63 | {
64 | Assert::assertStringNotEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
65 | return $this;
66 | }
67 |
68 | /**
69 | * Expect that the contents of a string is not equal to the contents of a file (ignoring case).
70 | *
71 | * @param string $expectedFile
72 | * @param string $message
73 | * @return self
74 | */
75 | public function notToEqualFileIgnoringCase(string $expectedFile, string $message = ''): self
76 | {
77 | Assert::assertStringNotEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
78 | return $this;
79 | }
80 |
81 | /**
82 | * Expect that a string does not match a given format string.
83 | *
84 | * @param $format
85 | * @param string $message
86 | * @return self
87 | */
88 | public function notToMatchFormat(string $format, string $message = ''): self
89 | {
90 | Assert::assertStringNotMatchesFormat($format, $this->actual, $message);
91 | return $this;
92 | }
93 |
94 | /**
95 | * Expect that a string does not match a given format string.
96 | *
97 | * @param string $formatFile
98 | * @param string $message
99 | * @return self
100 | */
101 | public function notToMatchFormatFile(string $formatFile, string $message = ''): self
102 | {
103 | Assert::assertStringNotMatchesFormatFile($formatFile, $this->actual, $message);
104 | return $this;
105 | }
106 |
107 | /**
108 | * Expect that a string does not match a given regular expression.
109 | *
110 | * @param string $pattern
111 | * @param string $message
112 | * @return self
113 | */
114 | public function notToMatchRegExp(string $pattern, string $message = ''): self
115 | {
116 | Assert::assertDoesNotMatchRegularExpression($pattern, $this->actual, $message);
117 | return $this;
118 | }
119 |
120 | /**
121 | * Expect that a string starts not with a given prefix.
122 | *
123 | * @param string $prefix
124 | * @param string $message
125 | * @return self
126 | */
127 | public function notToStartWith(string $prefix, string $message = ''): self
128 | {
129 | Assert::assertStringStartsNotWith($prefix, $this->actual, $message);
130 | return $this;
131 | }
132 |
133 | /**
134 | * Expect that a string is a valid JSON string.
135 | *
136 | * @param string $message
137 | * @return self
138 | */
139 | public function toBeJson(string $message = ''): self
140 | {
141 | Assert::assertJson($this->actual, $message);
142 | return $this;
143 | }
144 |
145 | public function toContainString(string $needle, string $message = ''): self
146 | {
147 | Assert::assertStringContainsString($needle, $this->actual, $message);
148 | return $this;
149 | }
150 |
151 | public function toContainStringIgnoringCase(string $needle, string $message = ''): self
152 | {
153 | Assert::assertStringContainsStringIgnoringCase($needle, $this->actual, $message);
154 | return $this;
155 | }
156 |
157 | /**
158 | * Expect that a string ends with a given suffix.
159 | *
160 | * @param string $suffix
161 | * @param string $message
162 | * @return self
163 | */
164 | public function toEndWith(string $suffix, string $message = ''): self
165 | {
166 | Assert::assertStringEndsWith($suffix, $this->actual, $message);
167 | return $this;
168 | }
169 |
170 | /**
171 | * Expect that the contents of a string is equal to the contents of a file.
172 | *
173 | * @param string $expectedFile
174 | * @param string $message
175 | * @return self
176 | */
177 | public function toEqualFile(string $expectedFile, string $message = ''): self
178 | {
179 | Assert::assertStringEqualsFile($expectedFile, $this->actual, $message);
180 | return $this;
181 | }
182 |
183 | /**
184 | * Expect that the contents of a string is equal to the contents of a file (canonicalizing).
185 | *
186 | * @param string $expectedFile
187 | * @param string $message
188 | * @return self
189 | */
190 | public function toEqualFileCanonicalizing(string $expectedFile, string $message = ''): self
191 | {
192 | Assert::assertStringEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
193 | return $this;
194 | }
195 |
196 | /**
197 | * Expect that the contents of a string is equal to the contents of a file (ignoring case).
198 | *
199 | * @param string $expectedFile
200 | * @param string $message
201 | * @return self
202 | */
203 | public function toEqualFileIgnoringCase(string $expectedFile, string $message = ''): self
204 | {
205 | Assert::assertStringEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
206 | return $this;
207 | }
208 |
209 | /**
210 | * Expect that a string matches a given format string.
211 | *
212 | * @param string $format
213 | * @param string $message
214 | * @return self
215 | */
216 | public function toMatchFormat(string $format, string $message = ''): self
217 | {
218 | Assert::assertStringMatchesFormat($format, $this->actual, $message);
219 | return $this;
220 | }
221 |
222 | /**
223 | * Expect that a string matches a given format file.
224 | *
225 | * @param string $formatFile
226 | * @param string $message
227 | * @return self
228 | */
229 | public function toMatchFormatFile(string $formatFile, string $message = ''): self
230 | {
231 | Assert::assertStringMatchesFormatFile($formatFile, $this->actual, $message);
232 | return $this;
233 | }
234 |
235 | /**
236 | * Expect that a string matches a given regular expression.
237 | *
238 | * @param string $pattern
239 | * @param string $message
240 | * @return self
241 | */
242 | public function toMatchRegExp(string $pattern, string $message = ''): self
243 | {
244 | Assert::assertMatchesRegularExpression($pattern, $this->actual, $message);
245 | return $this;
246 | }
247 |
248 | /**
249 | * Expect that a string starts with a given prefix.
250 | *
251 | * @param string $prefix
252 | * @param string $message
253 | * @return self
254 | */
255 | public function toStartWith(string $prefix, string $message = ''): self
256 | {
257 | Assert::assertStringStartsWith($prefix, $this->actual, $message);
258 | return $this;
259 | }
260 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyString.php:
--------------------------------------------------------------------------------
1 | actual, $message);
20 | return $this;
21 | }
22 |
23 | public function containsStringIgnoringCase(string $needle, string $message = ''): self
24 | {
25 | Assert::assertStringContainsStringIgnoringCase($needle, $this->actual, $message);
26 | return $this;
27 | }
28 |
29 | /**
30 | * Verifies that a string does not match a given regular expression.
31 | *
32 | * @param string $pattern
33 | * @param string $message
34 | * @return self
35 | */
36 | public function doesNotMatchRegExp(string $pattern, string $message = ''): self
37 | {
38 | Assert::assertDoesNotMatchRegularExpression($pattern, $this->actual, $message);
39 | return $this;
40 | }
41 |
42 | /**
43 | * Verifies that a string ends with a given suffix.
44 | *
45 | * @param string $suffix
46 | * @param string $message
47 | * @return self
48 | */
49 | public function endsWith(string $suffix, string $message = ''): self
50 | {
51 | Assert::assertStringEndsWith($suffix, $this->actual, $message);
52 | return $this;
53 | }
54 |
55 | /**
56 | * Verifies that the contents of a string is equal to the contents of a file.
57 | *
58 | * @param string $expectedFile
59 | * @param string $message
60 | * @return self
61 | */
62 | public function equalsFile(string $expectedFile, string $message = ''): self
63 | {
64 | Assert::assertStringEqualsFile($expectedFile, $this->actual, $message);
65 | return $this;
66 | }
67 |
68 | /**
69 | * Verifies that the contents of a string is equal to the contents of a file (canonicalizing).
70 | *
71 | * @param string $expectedFile
72 | * @param string $message
73 | * @return self
74 | */
75 | public function equalsFileCanonicalizing(string $expectedFile, string $message = ''): self
76 | {
77 | Assert::assertStringEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
78 | return $this;
79 | }
80 |
81 | /**
82 | * Verifies that the contents of a string is equal to the contents of a file (ignoring case).
83 | *
84 | * @param string $expectedFile
85 | * @param string $message
86 | * @return self
87 | */
88 | public function equalsFileIgnoringCase(string $expectedFile, string $message = ''): self
89 | {
90 | Assert::assertStringEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
91 | return $this;
92 | }
93 |
94 | /**
95 | * Verifies that a string is a valid JSON string.
96 | *
97 | * @param string $message
98 | * @return self
99 | */
100 | public function json(string $message = ''): self
101 | {
102 | Assert::assertJson($this->actual, $message);
103 | return $this;
104 | }
105 |
106 | /**
107 | * Verifies that a string matches a given format string.
108 | *
109 | * @param string $format
110 | * @param string $message
111 | * @return self
112 | */
113 | public function matchesFormat(string $format, string $message = ''): self
114 | {
115 | Assert::assertStringMatchesFormat($format, $this->actual, $message);
116 | return $this;
117 | }
118 |
119 | /**
120 | * Verifies that a string matches a given format file.
121 | *
122 | * @param string $formatFile
123 | * @param string $message
124 | * @return self
125 | */
126 | public function matchesFormatFile(string $formatFile, string $message = ''): self
127 | {
128 | Assert::assertStringMatchesFormatFile($formatFile, $this->actual, $message);
129 | return $this;
130 | }
131 |
132 | /**
133 | * Verifies that a string matches a given regular expression.
134 | *
135 | * @param string $pattern
136 | * @param string $message
137 | * @return self
138 | */
139 | public function matchesRegExp(string $pattern, string $message = ''): self
140 | {
141 | Assert::assertMatchesRegularExpression($pattern, $this->actual, $message);
142 | return $this;
143 | }
144 |
145 | public function notContainsString(string $needle, string $message = ''): self
146 | {
147 | Assert::assertStringNotContainsString($needle, $this->actual, $message);
148 | return $this;
149 | }
150 |
151 | public function notContainsStringIgnoringCase(string $needle, string $message = ''): self
152 | {
153 | Assert::assertStringNotContainsStringIgnoringCase($needle, $this->actual, $message);
154 | return $this;
155 | }
156 |
157 | /**
158 | * Verifies that a string ends not with a given suffix.
159 | *
160 | * @param string $suffix
161 | * @param string $message
162 | * @return self
163 | */
164 | public function notEndsWith(string $suffix, string $message = ''): self
165 | {
166 | Assert::assertStringEndsNotWith($suffix, $this->actual, $message);
167 | return $this;
168 | }
169 |
170 | /**
171 | * Verifies that the contents of a string is not equal to the contents of a file.
172 | *
173 | * @param string $expectedFile
174 | * @param string $message
175 | * @return self
176 | */
177 | public function notEqualsFile(string $expectedFile, string $message = ''): self
178 | {
179 | Assert::assertStringNotEqualsFile($expectedFile, $this->actual, $message);
180 | return $this;
181 | }
182 |
183 | /**
184 | * Verifies that the contents of a string is not equal to the contents of a file (canonicalizing).
185 | *
186 | * @param string $expectedFile
187 | * @param string $message
188 | * @return self
189 | */
190 | public function notEqualsFileCanonicalizing(string $expectedFile, string $message = ''): self
191 | {
192 | Assert::assertStringNotEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
193 | return $this;
194 | }
195 |
196 | /**
197 | * Verifies that the contents of a string is not equal to the contents of a file (ignoring case).
198 | *
199 | * @param string $expectedFile
200 | * @param string $message
201 | * @return self
202 | */
203 | public function notEqualsFileIgnoringCase(string $expectedFile, string $message = ''): self
204 | {
205 | Assert::assertStringNotEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
206 | return $this;
207 | }
208 |
209 | /**
210 | * Verifies that a string does not match a given format string.
211 | *
212 | * @param $format
213 | * @param string $message
214 | * @return self
215 | */
216 | public function notMatchesFormat(string $format, string $message = ''): self
217 | {
218 | Assert::assertStringNotMatchesFormat($format, $this->actual, $message);
219 | return $this;
220 | }
221 |
222 | /**
223 | * Verifies that a string does not match a given format string.
224 | *
225 | * @param string $formatFile
226 | * @param string $message
227 | * @return self
228 | */
229 | public function notMatchesFormatFile(string $formatFile, string $message = ''): self
230 | {
231 | Assert::assertStringNotMatchesFormatFile($formatFile, $this->actual, $message);
232 | return $this;
233 | }
234 |
235 | /**
236 | * Verifies that a string starts not with a given prefix.
237 | *
238 | * @param string $prefix
239 | * @param string $message
240 | * @return self
241 | */
242 | public function startsNotWith(string $prefix, string $message = ''): self
243 | {
244 | Assert::assertStringStartsNotWith($prefix, $this->actual, $message);
245 | return $this;
246 | }
247 |
248 | /**
249 | * Verifies that a string starts with a given prefix.
250 | *
251 | * @param string $prefix
252 | * @param string $message
253 | * @return self
254 | */
255 | public function startsWith(string $prefix, string $message = ''): self
256 | {
257 | Assert::assertStringStartsWith($prefix, $this->actual, $message);
258 | return $this;
259 | }
260 | }
--------------------------------------------------------------------------------
/tests/VerifyTest.php:
--------------------------------------------------------------------------------
1 | xml = new DOMDocument;
18 | $this->xml->loadXML('BazBaz');
19 | }
20 |
21 | public function testEquals(): void
22 | {
23 | verify(5)->equals(5);
24 | verify('hello')->equals('hello');
25 | verify(5)->equals(5, 'user have 5 posts');
26 | verify(3.251)->equalsWithDelta(3.25, 0.01);
27 | verify(3.251)->equalsWithDelta(3.25, 0.01, 'respects delta');
28 | verify(__FILE__)->fileEquals(__FILE__);
29 | }
30 |
31 | public function testNotEquals(): void
32 | {
33 | verify(3)->notEquals(5);
34 | verify(3.252)->notEqualsWithDelta(3.25, 0.001);
35 | verify(3.252)->notEqualsWithDelta(3.25, 0.001, 'respects delta');
36 | verify(__FILE__)->fileNotEquals(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'composer.json');
37 | }
38 |
39 | public function testContains(): void
40 | {
41 | verify([3, 2])->arrayContains(3);
42 | verify([3, 2])->arrayNotContains(5, 'user have 5 posts');
43 | }
44 |
45 | public function testGreaterLowerThan(): void
46 | {
47 | verify(7)->greaterThan(5);
48 | verify(7)->lessThan(10);
49 | verify(7)->lessThanOrEqual(7);
50 | verify(7)->lessThanOrEqual(8);
51 | verify(7)->greaterThanOrEqual(7);
52 | verify(7)->greaterThanOrEqual(5);
53 | }
54 |
55 | public function testTrueFalseNull(): void
56 | {
57 | verify(true)->true();
58 | verify(false)->false();
59 | verify(null)->null();
60 | verify(true)->notNull();
61 | verify(false)->false('something should be false');
62 | verify(true)->true('something should be true');
63 | }
64 |
65 | public function testEmptyNotEmpty(): void
66 | {
67 | verify(array('3', '5'))->notEmpty();
68 | verify(array())->empty();
69 | }
70 |
71 | public function testArrayHasKey(): void
72 | {
73 | $errors = ['title' => 'You should add title'];
74 | verify($errors)->arrayHasKey('title');
75 | verify($errors)->arrayHasNotKey('body');
76 | }
77 |
78 | public function testIsInstanceOf(): void
79 | {
80 | $testClass = new DateTime();
81 | verify($testClass)->instanceOf(DateTime::class);
82 | verify($testClass)->notInstanceOf(DateTimeZone::class);
83 | }
84 |
85 | public function testContainsOnly(): void
86 | {
87 | verify(['1', '2', '3'])->arrayContainsOnly('string');
88 | verify(['1', '2', 3])->arrayNotContainsOnly('string');
89 | }
90 |
91 | public function testContainsOnlyInstancesOf(): void
92 | {
93 | verify([new FakeClassForTesting(), new FakeClassForTesting(), new FakeClassForTesting()])
94 | ->arrayContainsOnlyInstancesOf('FakeClassForTesting');
95 | }
96 |
97 | public function testCount(): void
98 | {
99 | verify([1, 2, 3])->arrayCount(3);
100 | verify([1, 2, 3])->arrayNotCount(2);
101 | }
102 |
103 | public function testFileExists(): void
104 | {
105 | verify(__FILE__)->fileExists();
106 | verify('completelyrandomfilename.txt')->fileDoesNotExists();
107 | }
108 |
109 | public function testEqualsJsonFile(): void
110 | {
111 | verify(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'json-test-file.json')
112 | ->jsonFileEqualsJsonFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'equal-json-test-file.json');
113 | verify('{"some" : "data"}')->jsonStringEqualsJsonFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'equal-json-test-file.json');
114 | }
115 |
116 | public function testEqualsJsonString(): void
117 | {
118 | verify('{"some" : "data"}')->jsonStringEqualsJsonString('{"some" : "data"}');
119 | }
120 |
121 | public function testRegExp(): void
122 | {
123 | verify('somestring')->stringMatchesRegExp('/string/');
124 | }
125 |
126 | public function testMatchesFormat(): void
127 | {
128 | verify('somestring')->stringMatchesFormat('%s');
129 | verify('somestring')->stringNotMatchesFormat('%i');
130 | }
131 |
132 | public function testMatchesFormatFile(): void
133 | {
134 | verify('23')->stringMatchesFormatFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
135 | verify('asdfas')->stringNotMatchesFormatFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
136 | }
137 |
138 | public function testSame(): void
139 | {
140 | verify(1)->same(0+1);
141 | verify(1)->notSame(true);
142 | }
143 |
144 | public function testEndsWith(): void
145 | {
146 | verify('A completely not funny string')->stringEndsWith('ny string');
147 | verify('A completely not funny string')->stringNotEndsWith('A completely');
148 | }
149 |
150 | public function testEqualsFile(): void
151 | {
152 | verify('%i')->stringEqualsFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
153 | verify('Another string')->stringNotEqualsFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
154 | }
155 |
156 | public function testStartsWith(): void
157 | {
158 | verify('A completely not funny string')->stringStartsWith('A completely');
159 | verify('A completely not funny string')->stringStartsNotWith('string');
160 | }
161 |
162 | public function testEqualsXmlFile(): void
163 | {
164 | verify(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'xml-test-file.xml')
165 | ->xmlFileEqualsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'xml-test-file.xml');
166 | verify('BazBaz')
167 | ->xmlStringEqualsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'xml-test-file.xml');
168 | }
169 |
170 | public function testEqualsXmlString(): void
171 | {
172 | verify('BazBaz')
173 | ->xmlStringEqualsXmlString('BazBaz');
174 | }
175 |
176 | public function testStringContainsString(): void
177 | {
178 | verify('foo bar')->stringContainsString('o b');
179 | verify('foo bar')->stringNotContainsString('BAR');
180 | }
181 |
182 | public function testStringContainsStringIgnoringCase(): void
183 | {
184 | verify('foo bar')->stringContainsStringIgnoringCase('O b');
185 | verify('foo bar')->stringNotContainsStringIgnoringCase('baz');
186 | }
187 |
188 | public function testIsString(): void
189 | {
190 | verify('foo bar')->isString();
191 | verify(false)->isNotString();
192 | }
193 |
194 | public function testIsArray(): void
195 | {
196 | verify([1,2,3])->isArray();
197 | verify(false)->isNotArray();
198 | }
199 |
200 | public function testIsBool(): void
201 | {
202 | verify(false)->isBool();
203 | verify([1,2,3])->isNotBool();
204 | }
205 |
206 | public function testIsFloat(): void
207 | {
208 | verify(1.5)->isFloat();
209 | verify(1)->isNotFloat();
210 | }
211 |
212 | public function testIsInt(): void
213 | {
214 | verify(5)->isInt();
215 | verify(1.5)->isNotInt();
216 | }
217 |
218 | public function testIsNumeric(): void
219 | {
220 | verify('1.5')->isNumeric();
221 | verify('foo bar')->isNotNumeric();
222 | }
223 |
224 | public function testIsObject(): void
225 | {
226 | verify(new stdClass)->isObject();
227 | verify(false)->isNotObject();
228 | }
229 |
230 | public function testIsResource(): void
231 | {
232 | verify(fopen(__FILE__, 'r'))->isResource();
233 | verify(false)->isNotResource();
234 | }
235 |
236 | public function testIsScalar(): void
237 | {
238 | verify('foo bar')->isScalar();
239 | verify([1,2,3])->isNotScalar();
240 | }
241 |
242 | public function testIsCallable(): void
243 | {
244 | verify(function(): void {})->isCallable();
245 | verify(false)->isNotCallable();
246 | }
247 |
248 | public function testEqualsCanonicalizing(): void
249 | {
250 | verify([3, 2, 1])->equalsCanonicalizing([1, 2, 3]);
251 | }
252 |
253 | public function testNotEqualsCanonicalizing(): void
254 | {
255 | verify([3, 2, 1])->notEqualsCanonicalizing([2, 3, 0, 1]);
256 | }
257 |
258 | public function testEqualsIgnoringCase(): void
259 | {
260 | verify('foo')->equalsIgnoringCase('FOO');
261 | }
262 |
263 | public function testNotEqualsIgnoringCase(): void
264 | {
265 | verify('foo')->notEqualsIgnoringCase('BAR');
266 | }
267 |
268 | public function testEqualsWithDelta(): void
269 | {
270 | verify(1.01)->equalsWithDelta(1.0, 0.1);
271 | }
272 |
273 | public function testNotEqualsWithDelta(): void
274 | {
275 | verify(1.2)->notEqualsWithDelta(1.0, 0.1);
276 | }
277 |
278 | public function testThrows(): void
279 | {
280 | $func = function (): void {
281 | throw new Exception('foo');
282 | };
283 |
284 | verify($func)->callableThrows();
285 | verify($func)->callableThrows(Exception::class);
286 | verify($func)->callableThrows(Exception::class, 'foo');
287 | verify($func)->callableThrows(new Exception());
288 | verify($func)->callableThrows(new Exception('foo'));
289 |
290 | verify(function () use ($func): void {
291 | verify($func)->callableThrows(RuntimeException::class);
292 | })->callableThrows(ExpectationFailedException::class);
293 |
294 | verify(function (): void {
295 | verify(function (): void {})->callableThrows(Exception::class);
296 | })->callableThrows(new ExpectationFailedException("exception 'Exception' was not thrown as expected"));
297 | }
298 |
299 | public function testDoesNotThrow(): void
300 | {
301 | $func = function (): void {
302 | throw new Exception('foo');
303 | };
304 |
305 | verify(function (): void {})->callableDoesNotThrow();
306 | verify($func)->callableDoesNotThrow(RuntimeException::class);
307 | verify($func)->callableDoesNotThrow(RuntimeException::class, 'bar');
308 | verify($func)->callableDoesNotThrow(RuntimeException::class, 'foo');
309 | verify($func)->callableDoesNotThrow(new RuntimeException());
310 | verify($func)->callableDoesNotThrow(new RuntimeException('bar'));
311 | verify($func)->callableDoesNotThrow(new RuntimeException('foo'));
312 | verify($func)->callableDoesNotThrow(Exception::class, 'bar');
313 | verify($func)->callableDoesNotThrow(new Exception('bar'));
314 |
315 | verify(function () use ($func): void {
316 | verify($func)->callableDoesNotThrow();
317 | })->callableThrows(new ExpectationFailedException('exception was not expected to be thrown'));
318 |
319 | verify(function () use ($func): void {
320 | verify($func)->callableDoesNotThrow(Exception::class);
321 | })->callableThrows(new ExpectationFailedException("exception 'Exception' was not expected to be thrown"));
322 |
323 | verify(function () use ($func): void {
324 | verify($func)->callableDoesNotThrow(Exception::class, 'foo');
325 | })->callableThrows(new ExpectationFailedException("exception 'Exception' with message 'foo' was not expected to be thrown"));
326 | }
327 |
328 | public function testObjectHasProperty(): void
329 | {
330 | $object = new \Stdclass();
331 | $object->bar = 'baz';
332 |
333 | verify($object)->baseObjectHasProperty('bar');
334 |
335 | verify(function () use ($object): void {
336 | verify($object)->baseObjectHasProperty('foo', 'foobar');
337 | })->callableThrows(new ExpectationFailedException("foobar\nFailed asserting that object of class \"stdClass\" has property \"foo\"."));
338 | }
339 |
340 | public function testObjectNotHasProperty(): void
341 | {
342 | $object = new \Stdclass();
343 | $object->bar = 'baz';
344 |
345 | verify($object)->baseObjectNotHasProperty('foo');
346 |
347 | verify(function () use ($object): void {
348 | verify($object)->baseObjectNotHasProperty('bar', 'foobar');
349 | })->callableThrows(new ExpectationFailedException("foobar\nFailed asserting that object of class \"stdClass\" does not have property \"bar\"."));
350 | }
351 | }
352 |
353 |
354 | class FakeClassForTesting
355 | {
356 | static $staticProperty;
357 | }
358 |
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyAny.php:
--------------------------------------------------------------------------------
1 | actual)->contains($needle, $message);
14 | return $this;
15 | }
16 |
17 | public function arrayContainsEquals($needle, string $message = ''): self
18 | {
19 | Verify::Array($this->actual)->containsEquals($needle, $message);
20 | return $this;
21 | }
22 |
23 | public function arrayContainsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
24 | {
25 | Verify::Array($this->actual)->containsOnly($type, $isNativeType, $message);
26 | return $this;
27 | }
28 |
29 | public function arrayContainsOnlyInstancesOf(string $className, string $message = ''): self
30 | {
31 | Verify::Array($this->actual)->containsOnlyInstancesOf($className, $message);
32 | return $this;
33 | }
34 |
35 | public function arrayCount(int $expectedCount, string $message = ''): self
36 | {
37 | Verify::Array($this->actual)->count($expectedCount, $message);
38 | return $this;
39 | }
40 |
41 | public function arrayHasKey($key, string $message = ''): self
42 | {
43 | Verify::Array($this->actual)->hasKey($key, $message);
44 | return $this;
45 | }
46 |
47 | public function arrayHasNotKey($key, string $message = ''): self
48 | {
49 | Verify::Array($this->actual)->hasNotKey($key, $message);
50 | return $this;
51 | }
52 |
53 | public function arrayNotContains($needle, string $message = ''): self
54 | {
55 | Verify::Array($this->actual)->notContains($needle, $message);
56 | return $this;
57 | }
58 |
59 | public function arrayNotContainsEquals($needle, string $message = ''): self
60 | {
61 | Verify::Array($this->actual)->notContainsEquals($needle, $message);
62 | return $this;
63 | }
64 |
65 | public function arrayNotContainsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
66 | {
67 | Verify::Array($this->actual)->notContainsOnly($type, $isNativeType, $message);
68 | return $this;
69 | }
70 |
71 | public function arrayNotCount(int $expectedCount, string $message = ''): self
72 | {
73 | Verify::Array($this->actual)->notCount($expectedCount, $message);
74 | return $this;
75 | }
76 |
77 | public function arrayNotSameSize($expected, string $message = ''): self
78 | {
79 | Verify::Array($this->actual)->notSameSize($expected, $message);
80 | return $this;
81 | }
82 |
83 | public function arraySameSize($expected, string $message = ''): self
84 | {
85 | Verify::Array($this->actual)->sameSize($expected, $message);
86 | return $this;
87 | }
88 |
89 | public function baseObjectHasAttribute(string $attributeName, string $message = ''): self
90 | {
91 | Verify::BaseObject($this->actual)->hasAttribute($attributeName, $message);
92 | return $this;
93 | }
94 |
95 | public function baseObjectNotHasAttribute(string $attributeName, string $message = ''): self
96 | {
97 | Verify::BaseObject($this->actual)->notHasAttribute($attributeName, $message);
98 | return $this;
99 | }
100 |
101 | public function baseObjectHasProperty(string $propertyName, string $message = ''): self
102 | {
103 | Verify::BaseObject($this->actual)->hasProperty($propertyName, $message);
104 | return $this;
105 | }
106 |
107 | public function baseObjectNotHasProperty(string $propertyName, string $message = ''): self
108 | {
109 | Verify::BaseObject($this->actual)->notHasProperty($propertyName, $message);
110 | return $this;
111 | }
112 |
113 | public function callableThrows($throws = null, string $message = ''): self
114 | {
115 | Verify::Callable($this->actual)->throws($throws, $message);
116 | return $this;
117 | }
118 |
119 | public function callableDoesNotThrow($throws = null, string $message = ''): self
120 | {
121 | Verify::Callable($this->actual)->doesNotThrow($throws, $message);
122 | return $this;
123 | }
124 |
125 | public function classHasAttribute(string $attributeName, string $message = ''): self
126 | {
127 | Verify::Class($this->actual)->hasAttribute($attributeName, $message);
128 | return $this;
129 | }
130 |
131 | public function classHasStaticAttribute(string $attributeName, string $message = ''): self
132 | {
133 | Verify::Class($this->actual)->hasStaticAttribute($attributeName, $message);
134 | return $this;
135 | }
136 |
137 | public function classNotHasAttribute(string $attributeName, string $message = ''): self
138 | {
139 | Verify::Class($this->actual)->notHasAttribute($attributeName, $message);
140 | return $this;
141 | }
142 |
143 | public function classNotHasStaticAttribute(string $attributeName, string $message = ''): self
144 | {
145 | Verify::Class($this->actual)->notHasStaticAttribute($attributeName, $message);
146 | return $this;
147 | }
148 |
149 | public function directoryDoesNotExist(string $message = ''): self
150 | {
151 | Verify::Directory($this->actual)->doesNotExist($message);
152 | return $this;
153 | }
154 |
155 | public function directoryExists(string $message = ''): self
156 | {
157 | Verify::Directory($this->actual)->exists($message);
158 | return $this;
159 | }
160 |
161 | public function directoryIsNotReadable(string $message = ''): self
162 | {
163 | Verify::Directory($this->actual)->isNotReadable($message);
164 | return $this;
165 | }
166 |
167 | public function directoryIsNotWritable(string $message = ''): self
168 | {
169 | Verify::Directory($this->actual)->isNotWritable($message);
170 | return $this;
171 | }
172 |
173 | public function directoryIsReadable(string $message = ''): self
174 | {
175 | Verify::Directory($this->actual)->isReadable($message);
176 | return $this;
177 | }
178 |
179 | public function directoryIsWritable(string $message = ''): self
180 | {
181 | Verify::Directory($this->actual)->isWritable($message);
182 | return $this;
183 | }
184 |
185 | public function fileDoesNotExists(string $message = ''): self
186 | {
187 | Verify::File($this->actual)->doesNotExists($message);
188 | return $this;
189 | }
190 |
191 | public function fileEquals(string $expected, string $message = ''): self
192 | {
193 | Verify::File($this->actual)->equals($expected, $message);
194 | return $this;
195 | }
196 |
197 | public function fileEqualsCanonicalizing(string $expected, string $message = ''): self
198 | {
199 | Verify::File($this->actual)->equalsCanonicalizing($expected, $message);
200 | return $this;
201 | }
202 |
203 | public function fileEqualsIgnoringCase(string $expected, string $message = ''): self
204 | {
205 | Verify::File($this->actual)->equalsIgnoringCase($expected, $message);
206 | return $this;
207 | }
208 |
209 | public function fileExists(string $message = ''): self
210 | {
211 | Verify::File($this->actual)->exists($message);
212 | return $this;
213 | }
214 |
215 | public function fileIsNotReadable(string $message = ''): self
216 | {
217 | Verify::File($this->actual)->isNotReadable($message);
218 | return $this;
219 | }
220 |
221 | public function fileIsNotWritable(string $message = ''): self
222 | {
223 | Verify::File($this->actual)->isNotWritable($message);
224 | return $this;
225 | }
226 |
227 | public function fileIsReadable(string $message = ''): self
228 | {
229 | Verify::File($this->actual)->isReadable($message);
230 | return $this;
231 | }
232 |
233 | public function fileIsWritable(string $message = ''): self
234 | {
235 | Verify::File($this->actual)->isWritable($message);
236 | return $this;
237 | }
238 |
239 | public function fileNotEquals(string $expected, string $message = ''): self
240 | {
241 | Verify::File($this->actual)->notEquals($expected, $message);
242 | return $this;
243 | }
244 |
245 | public function fileNotEqualsCanonicalizing(string $expected, string $message = ''): self
246 | {
247 | Verify::File($this->actual)->notEqualsCanonicalizing($expected, $message);
248 | return $this;
249 | }
250 |
251 | public function fileNotEqualsIgnoringCase(string $expected, string $message = ''): self
252 | {
253 | Verify::File($this->actual)->notEqualsIgnoringCase($expected, $message);
254 | return $this;
255 | }
256 |
257 | public function jsonFileEqualsJsonFile(string $expectedFile, string $message = ''): self
258 | {
259 | Verify::JsonFile($this->actual)->equalsJsonFile($expectedFile, $message);
260 | return $this;
261 | }
262 |
263 | public function jsonFileNotEqualsJsonFile(string $expectedFile, string $message = ''): self
264 | {
265 | Verify::JsonFile($this->actual)->notEqualsJsonFile($expectedFile, $message);
266 | return $this;
267 | }
268 |
269 | public function jsonStringEqualsJsonFile(string $expectedFile, string $message = ''): self
270 | {
271 | Verify::JsonString($this->actual)->equalsJsonFile($expectedFile, $message);
272 | return $this;
273 | }
274 |
275 | public function jsonStringEqualsJsonString(string $expectedJson, string $message = ''): self
276 | {
277 | Verify::JsonString($this->actual)->equalsJsonString($expectedJson, $message);
278 | return $this;
279 | }
280 |
281 | public function jsonStringNotEqualsJsonFile(string $expectedFile, string $message = ''): self
282 | {
283 | Verify::JsonString($this->actual)->notEqualsJsonFile($expectedFile, $message);
284 | return $this;
285 | }
286 |
287 | public function jsonStringNotEqualsJsonString(string $expectedJson, string $message = ''): self
288 | {
289 | Verify::JsonString($this->actual)->notEqualsJsonString($expectedJson, $message);
290 | return $this;
291 | }
292 |
293 | public function stringContainsString(string $needle, string $message = ''): self
294 | {
295 | Verify::String($this->actual)->containsString($needle, $message);
296 | return $this;
297 | }
298 |
299 | public function stringContainsStringIgnoringCase($needle, string $message = ''): self
300 | {
301 | Verify::String($this->actual)->containsStringIgnoringCase($needle, $message);
302 | return $this;
303 | }
304 |
305 | public function stringDoesNotMatchRegExp(string $pattern, string $message = ''): self
306 | {
307 | Verify::String($this->actual)->doesNotMatchRegExp($pattern, $message);
308 | return $this;
309 | }
310 |
311 | public function stringEndsWith(string $suffix, string $message = ''): self
312 | {
313 | Verify::String($this->actual)->endsWith($suffix, $message);
314 | return $this;
315 | }
316 |
317 | public function stringEqualsFile(string $expectedFile, string $message = ''): self
318 | {
319 | Verify::String($this->actual)->equalsFile($expectedFile, $message);
320 | return $this;
321 | }
322 |
323 | public function stringEqualsFileCanonicalizing(string $expectedFile, string $message = ''): self
324 | {
325 | Verify::String($this->actual)->equalsFileCanonicalizing($expectedFile, $message);
326 | return $this;
327 | }
328 |
329 | public function stringEqualsFileIgnoringCase(string $expectedFile, string $message = ''): self
330 | {
331 | Verify::String($this->actual)->equalsFileIgnoringCase($expectedFile, $message);
332 | return $this;
333 | }
334 |
335 | public function stringJson(string $message = ''): self
336 | {
337 | Verify::String($this->actual)->json($message);
338 | return $this;
339 | }
340 |
341 | public function stringMatchesFormat(string $format, string $message = ''): self
342 | {
343 | Verify::String($this->actual)->matchesFormat($format, $message);
344 | return $this;
345 | }
346 |
347 | public function stringMatchesFormatFile(string $formatFile, string $message = ''): self
348 | {
349 | Verify::String($this->actual)->matchesFormatFile($formatFile, $message);
350 | return $this;
351 | }
352 |
353 | public function stringMatchesRegExp(string $pattern, string $message = ''): self
354 | {
355 | Verify::String($this->actual)->matchesRegExp($pattern, $message);
356 | return $this;
357 | }
358 |
359 | public function stringNotContainsString(string $needle, string $message = ''): self
360 | {
361 | Verify::String($this->actual)->notContainsString($needle, $message);
362 | return $this;
363 | }
364 |
365 | public function stringNotContainsStringIgnoringCase(string $needle, string $message = ''): self
366 | {
367 | Verify::String($this->actual)->notContainsStringIgnoringCase($needle, $message);
368 | return $this;
369 | }
370 |
371 | public function stringNotEndsWith(string $suffix, string $message = ''): self
372 | {
373 | Verify::String($this->actual)->notEndsWith($suffix, $message);
374 | return $this;
375 | }
376 |
377 | public function stringNotEqualsFile(string $expectedFile, string $message = ''): self
378 | {
379 | Verify::String($this->actual)->notEqualsFile($expectedFile, $message);
380 | return $this;
381 | }
382 |
383 | public function stringNotEqualsFileCanonicalizing(string $expectedFile, string $message = ''): self
384 | {
385 | Verify::String($this->actual)->notEqualsFileCanonicalizing($expectedFile, $message);
386 | return $this;
387 | }
388 |
389 | public function stringNotEqualsFileIgnoringCase(string $expectedFile, string $message = ''): self
390 | {
391 | Verify::String($this->actual)->notEqualsFileIgnoringCase($expectedFile, $message);
392 | return $this;
393 | }
394 |
395 | public function stringNotMatchesFormat($format, string $message = ''): self
396 | {
397 | Verify::String($this->actual)->notMatchesFormat($format, $message);
398 | return $this;
399 | }
400 |
401 | public function stringNotMatchesFormatFile(string $formatFile, string $message = ''): self
402 | {
403 | Verify::String($this->actual)->notMatchesFormatFile($formatFile, $message);
404 | return $this;
405 | }
406 |
407 | public function stringStartsNotWith(string $prefix, string $message = ''): self
408 | {
409 | Verify::String($this->actual)->startsNotWith($prefix, $message);
410 | return $this;
411 | }
412 |
413 | public function stringStartsWith(string $prefix, string $message = ''): self
414 | {
415 | Verify::String($this->actual)->startsWith($prefix, $message);
416 | return $this;
417 | }
418 |
419 | public function xmlFileEqualsXmlFile(string $expectedFile, string $message = ''): self
420 | {
421 | Verify::XmlFile($this->actual)->equalsXmlFile($expectedFile, $message);
422 | return $this;
423 | }
424 |
425 | public function xmlFileNotEqualsXmlFile(string $expectedFile, string $message = ''): self
426 | {
427 | Verify::XmlFile($this->actual)->notEqualsXmlFile($expectedFile, $message);
428 | return $this;
429 | }
430 |
431 | public function xmlStringEqualsXmlFile(string $expectedFile, string $message = ''): self
432 | {
433 | Verify::XmlString($this->actual)->equalsXmlFile($expectedFile, $message);
434 | return $this;
435 | }
436 |
437 | public function xmlStringEqualsXmlString($expectedXml, string $message = ''): self
438 | {
439 | Verify::XmlString($this->actual)->equalsXmlString($expectedXml, $message);
440 | return $this;
441 | }
442 |
443 | public function xmlStringNotEqualsXmlFile(string $expectedFile, string $message = ''): self
444 | {
445 | Verify::XmlString($this->actual)->notEqualsXmlFile($expectedFile, $message);
446 | return $this;
447 | }
448 |
449 | public function xmlStringNotEqualsXmlString($expectedXml, string $message = ''): self
450 | {
451 | Verify::XmlString($this->actual)->notEqualsXmlString($expectedXml, $message);
452 | return $this;
453 | }
454 | }
455 |
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectAny.php:
--------------------------------------------------------------------------------
1 | actual)->toContain($needle, $message);
14 | return $this;
15 | }
16 |
17 | public function arrayToContainEqual($needle, string $message = ''): self
18 | {
19 | Expect::Array($this->actual)->toContainEqual($needle, $message);
20 | return $this;
21 | }
22 |
23 | public function arrayToContainOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
24 | {
25 | Expect::Array($this->actual)->toContainOnly($type, $isNativeType, $message);
26 | return $this;
27 | }
28 |
29 | public function arrayToContainOnlyInstancesOf(string $className, string $message = ''): self
30 | {
31 | Expect::Array($this->actual)->toContainOnlyInstancesOf($className, $message);
32 | return $this;
33 | }
34 |
35 | public function arrayToHaveCount(int $expectedCount, string $message = ''): self
36 | {
37 | Expect::Array($this->actual)->toHaveCount($expectedCount, $message);
38 | return $this;
39 | }
40 |
41 | public function arrayToHaveKey($key, string $message = ''): self
42 | {
43 | Expect::Array($this->actual)->toHaveKey($key, $message);
44 | return $this;
45 | }
46 |
47 | public function arrayNotToHaveKey($key, string $message = ''): self
48 | {
49 | Expect::Array($this->actual)->notToHaveKey($key, $message);
50 | return $this;
51 | }
52 |
53 | public function arrayNotToContain($needle, string $message = ''): self
54 | {
55 | Expect::Array($this->actual)->notToContain($needle, $message);
56 | return $this;
57 | }
58 |
59 | public function arrayNotToContainEqual($needle, string $message = ''): self
60 | {
61 | Expect::Array($this->actual)->notToContainEqual($needle, $message);
62 | return $this;
63 | }
64 |
65 | public function arrayNotToContainOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
66 | {
67 | Expect::Array($this->actual)->notToContainOnly($type, $isNativeType, $message);
68 | return $this;
69 | }
70 |
71 | public function arrayNotToHaveCount(int $expectedCount, string $message = ''): self
72 | {
73 | Expect::Array($this->actual)->notToHaveCount($expectedCount, $message);
74 | return $this;
75 | }
76 |
77 | public function arrayNotToHaveSameSizeAs($expected, string $message = ''): self
78 | {
79 | Expect::Array($this->actual)->notToHaveSameSizeAs($expected, $message);
80 | return $this;
81 | }
82 |
83 | public function arrayToHaveSameSizeAs($expected, string $message = ''): self
84 | {
85 | Expect::Array($this->actual)->toHaveSameSizeAs($expected, $message);
86 | return $this;
87 | }
88 |
89 | public function baseObjectToHaveAttribute(string $attributeName, string $message = ''): self
90 | {
91 | Expect::BaseObject($this->actual)->toHaveAttribute($attributeName, $message);
92 | return $this;
93 | }
94 |
95 | public function baseObjectNotToHaveAttribute(string $attributeName, string $message = ''): self
96 | {
97 | Expect::BaseObject($this->actual)->notToHaveAttribute($attributeName, $message);
98 | return $this;
99 | }
100 |
101 | public function baseObjectToHaveProperty(string $propertyName, string $message = ''): self
102 | {
103 | Expect::BaseObject($this->actual)->toHaveProperty($propertyName, $message);
104 | return $this;
105 | }
106 |
107 | public function baseObjectNotToHaveProperty(string $propertyName, string $message = ''): self
108 | {
109 | Expect::BaseObject($this->actual)->notToHaveProperty($propertyName, $message);
110 | return $this;
111 | }
112 |
113 | public function callableToThrow($throws = null, string $message = ''): self
114 | {
115 | Expect::Callable($this->actual)->toThrow($throws, $message);
116 | return $this;
117 | }
118 |
119 | public function callableNotToThrow($throws = null, string $message = ''): self
120 | {
121 | Expect::Callable($this->actual)->notToThrow($throws, $message);
122 | return $this;
123 | }
124 |
125 | public function classToHaveAttribute(string $attributeName, string $message = ''): self
126 | {
127 | Expect::Class($this->actual)->toHaveAttribute($attributeName, $message);
128 | return $this;
129 | }
130 |
131 | public function classToHaveStaticAttribute(string $attributeName, string $message = ''): self
132 | {
133 | Expect::Class($this->actual)->toHaveStaticAttribute($attributeName, $message);
134 | return $this;
135 | }
136 |
137 | public function classNotToHaveAttribute(string $attributeName, string $message = ''): self
138 | {
139 | Expect::Class($this->actual)->notToHaveAttribute($attributeName, $message);
140 | return $this;
141 | }
142 |
143 | public function classNotToHaveStaticAttribute(string $attributeName, string $message = ''): self
144 | {
145 | Expect::Class($this->actual)->notToHaveStaticAttribute($attributeName, $message);
146 | return $this;
147 | }
148 |
149 | public function directoryNotToExist(string $message = ''): self
150 | {
151 | Expect::Directory($this->actual)->notToExist($message);
152 | return $this;
153 | }
154 |
155 | public function directoryToExist(string $message = ''): self
156 | {
157 | Expect::Directory($this->actual)->toExist($message);
158 | return $this;
159 | }
160 |
161 | public function directoryNotToBeReadable(string $message = ''): self
162 | {
163 | Expect::Directory($this->actual)->notToBeReadable($message);
164 | return $this;
165 | }
166 |
167 | public function directoryNotToBeWritable(string $message = ''): self
168 | {
169 | Expect::Directory($this->actual)->notToBeWritable($message);
170 | return $this;
171 | }
172 |
173 | public function directoryToBeReadable(string $message = ''): self
174 | {
175 | Expect::Directory($this->actual)->toBeReadable($message);
176 | return $this;
177 | }
178 |
179 | public function directoryToBeWritable(string $message = ''): self
180 | {
181 | Expect::Directory($this->actual)->toBeWritable($message);
182 | return $this;
183 | }
184 |
185 | public function fileNotToExist(string $message = ''): self
186 | {
187 | Expect::File($this->actual)->notToExist($message);
188 | return $this;
189 | }
190 |
191 | public function fileToBeEqual(string $expected, string $message = ''): self
192 | {
193 | Expect::File($this->actual)->toBeEqual($expected, $message);
194 | return $this;
195 | }
196 |
197 | public function fileToBeEqualCanonicalizing(string $expected, string $message = ''): self
198 | {
199 | Expect::File($this->actual)->toBeEqualCanonicalizing($expected, $message);
200 | return $this;
201 | }
202 |
203 | public function fileToBeEqualIgnoringCase(string $expected, string $message = ''): self
204 | {
205 | Expect::File($this->actual)->toBeEqualIgnoringCase($expected, $message);
206 | return $this;
207 | }
208 |
209 | public function fileToExist(string $message = ''): self
210 | {
211 | Expect::File($this->actual)->toExist($message);
212 | return $this;
213 | }
214 |
215 | public function fileNotToBeReadable(string $message = ''): self
216 | {
217 | Expect::File($this->actual)->notToBeReadable($message);
218 | return $this;
219 | }
220 |
221 | public function fileNotToBeWritable(string $message = ''): self
222 | {
223 | Expect::File($this->actual)->notToBeWritable($message);
224 | return $this;
225 | }
226 |
227 | public function fileToBeReadable(string $message = ''): self
228 | {
229 | Expect::File($this->actual)->toBeReadable($message);
230 | return $this;
231 | }
232 |
233 | public function fileToBeWritable(string $message = ''): self
234 | {
235 | Expect::File($this->actual)->toBeWritable($message);
236 | return $this;
237 | }
238 |
239 | public function fileToNotEqual(string $expected, string $message = ''): self
240 | {
241 | Expect::File($this->actual)->toNotEqual($expected, $message);
242 | return $this;
243 | }
244 |
245 | public function fileToNotEqualCanonicalizing(string $expected, string $message = ''): self
246 | {
247 | Expect::File($this->actual)->toNotEqualCanonicalizing($expected, $message);
248 | return $this;
249 | }
250 |
251 | public function fileToNotEqualIgnoringCase(string $expected, string $message = ''): self
252 | {
253 | Expect::File($this->actual)->toNotEqualIgnoringCase($expected, $message);
254 | return $this;
255 | }
256 |
257 | public function jsonFileToEqualJsonFile(string $expectedFile, string $message = ''): self
258 | {
259 | Expect::JsonFile($this->actual)->toEqualJsonFile($expectedFile, $message);
260 | return $this;
261 | }
262 |
263 | public function jsonFileNotToEqualJsonFile(string $expectedFile, string $message = ''): self
264 | {
265 | Expect::JsonFile($this->actual)->notToEqualJsonFile($expectedFile, $message);
266 | return $this;
267 | }
268 |
269 | public function jsonStringToEqualJsonFile(string $expectedFile, string $message = ''): self
270 | {
271 | Expect::JsonString($this->actual)->toEqualJsonFile($expectedFile, $message);
272 | return $this;
273 | }
274 |
275 | public function jsonStringToEqualJsonString(string $expectedJson, string $message = ''): self
276 | {
277 | Expect::JsonString($this->actual)->toEqualJsonString($expectedJson, $message);
278 | return $this;
279 | }
280 |
281 | public function jsonStringNotToEqualJsonFile(string $expectedFile, string $message = ''): self
282 | {
283 | Expect::JsonString($this->actual)->notToEqualJsonFile($expectedFile, $message);
284 | return $this;
285 | }
286 |
287 | public function jsonStringNotToEqualJsonString(string $expectedJson, string $message = ''): self
288 | {
289 | Expect::JsonString($this->actual)->notToEqualJsonString($expectedJson, $message);
290 | return $this;
291 | }
292 |
293 | public function stringToContainString(string $needle, string $message = ''): self
294 | {
295 | Expect::String($this->actual)->toContainString($needle, $message);
296 | return $this;
297 | }
298 |
299 | public function stringToContainStringIgnoringCase($needle, string $message = ''): self
300 | {
301 | Expect::String($this->actual)->toContainStringIgnoringCase($needle, $message);
302 | return $this;
303 | }
304 |
305 | public function stringNotToMatchRegExp(string $pattern, string $message = ''): self
306 | {
307 | Expect::String($this->actual)->notToMatchRegExp($pattern, $message);
308 | return $this;
309 | }
310 |
311 | public function stringToEndWith(string $suffix, string $message = ''): self
312 | {
313 | Expect::String($this->actual)->toEndWith($suffix, $message);
314 | return $this;
315 | }
316 |
317 | public function stringToEqualFile(string $expectedFile, string $message = ''): self
318 | {
319 | Expect::String($this->actual)->toEqualFile($expectedFile, $message);
320 | return $this;
321 | }
322 |
323 | public function stringToEqualFileCanonicalizing(string $expectedFile, string $message = ''): self
324 | {
325 | Expect::String($this->actual)->toEqualFileCanonicalizing($expectedFile, $message);
326 | return $this;
327 | }
328 |
329 | public function stringToEqualFileIgnoringCase(string $expectedFile, string $message = ''): self
330 | {
331 | Expect::String($this->actual)->toEqualFileIgnoringCase($expectedFile, $message);
332 | return $this;
333 | }
334 |
335 | public function stringToBeJson(string $message = ''): self
336 | {
337 | Expect::String($this->actual)->toBeJson($message);
338 | return $this;
339 | }
340 |
341 | public function stringToMatchFormat(string $format, string $message = ''): self
342 | {
343 | Expect::String($this->actual)->toMatchFormat($format, $message);
344 | return $this;
345 | }
346 |
347 | public function stringToMatchFormatFile(string $formatFile, string $message = ''): self
348 | {
349 | Expect::String($this->actual)->toMatchFormatFile($formatFile, $message);
350 | return $this;
351 | }
352 |
353 | public function stringToMatchRegExp(string $pattern, string $message = ''): self
354 | {
355 | Expect::String($this->actual)->toMatchRegExp($pattern, $message);
356 | return $this;
357 | }
358 |
359 | public function stringNotToContainString(string $needle, string $message = ''): self
360 | {
361 | Expect::String($this->actual)->notToContainString($needle, $message);
362 | return $this;
363 | }
364 |
365 | public function stringNotToContainStringIgnoringCase(string $needle, string $message = ''): self
366 | {
367 | Expect::String($this->actual)->notToContainStringIgnoringCase($needle, $message);
368 | return $this;
369 | }
370 |
371 | public function stringNotToEndWith(string $suffix, string $message = ''): self
372 | {
373 | Expect::String($this->actual)->notToEndWith($suffix, $message);
374 | return $this;
375 | }
376 |
377 | public function stringNotToEqualFile(string $expectedFile, string $message = ''): self
378 | {
379 | Expect::String($this->actual)->notToEqualFile($expectedFile, $message);
380 | return $this;
381 | }
382 |
383 | public function stringNotToEqualFileCanonicalizing(string $expectedFile, string $message = ''): self
384 | {
385 | Expect::String($this->actual)->notToEqualFileCanonicalizing($expectedFile, $message);
386 | return $this;
387 | }
388 |
389 | public function stringNotToEqualFileIgnoringCase(string $expectedFile, string $message = ''): self
390 | {
391 | Expect::String($this->actual)->notToEqualFileIgnoringCase($expectedFile, $message);
392 | return $this;
393 | }
394 |
395 | public function stringNotToMatchFormat($format, string $message = ''): self
396 | {
397 | Expect::String($this->actual)->notToMatchFormat($format, $message);
398 | return $this;
399 | }
400 |
401 | public function stringNotToMatchFormatFile(string $formatFile, string $message = ''): self
402 | {
403 | Expect::String($this->actual)->notToMatchFormatFile($formatFile, $message);
404 | return $this;
405 | }
406 |
407 | public function stringNotToStartWith(string $prefix, string $message = ''): self
408 | {
409 | Expect::String($this->actual)->notToStartWith($prefix, $message);
410 | return $this;
411 | }
412 |
413 | public function stringToStartWith(string $prefix, string $message = ''): self
414 | {
415 | Expect::String($this->actual)->toStartWith($prefix, $message);
416 | return $this;
417 | }
418 |
419 | public function xmlFileToEqualXmlFile(string $expectedFile, string $message = ''): self
420 | {
421 | Expect::XmlFile($this->actual)->toEqualXmlFile($expectedFile, $message);
422 | return $this;
423 | }
424 |
425 | public function xmlFileNotToEqualXmlFile(string $expectedFile, string $message = ''): self
426 | {
427 | Expect::XmlFile($this->actual)->notToEqualXmlFile($expectedFile, $message);
428 | return $this;
429 | }
430 |
431 | public function xmlStringToEqualXmlFile(string $expectedFile, string $message = ''): self
432 | {
433 | Expect::XmlString($this->actual)->toEqualXmlFile($expectedFile, $message);
434 | return $this;
435 | }
436 |
437 | public function xmlStringToEqualXmlString($expectedXml, string $message = ''): self
438 | {
439 | Expect::XmlString($this->actual)->toEqualXmlString($expectedXml, $message);
440 | return $this;
441 | }
442 |
443 | public function xmlStringNotToEqualXmlFile(string $expectedFile, string $message = ''): self
444 | {
445 | Expect::XmlString($this->actual)->notToEqualXmlFile($expectedFile, $message);
446 | return $this;
447 | }
448 |
449 | public function xmlStringNotToEqualXmlString($expectedXml, string $message = ''): self
450 | {
451 | Expect::XmlString($this->actual)->notToEqualXmlString($expectedXml, $message);
452 | return $this;
453 | }
454 | }
455 |
--------------------------------------------------------------------------------
/src/Codeception/Verify/Verifiers/VerifyMixed.php:
--------------------------------------------------------------------------------
1 | actual, $message);
31 | return $this;
32 | }
33 |
34 | /**
35 | * Verifies that two variables are equal.
36 | *
37 | * @param $expected
38 | * @param string $message
39 | * @return self
40 | */
41 | public function equals($expected, string $message = ''): self
42 | {
43 | Assert::assertEquals($expected, $this->actual, $message);
44 | return $this;
45 | }
46 |
47 | /**
48 | * Verifies that two variables are equal (canonicalizing).
49 | *
50 | * @param $expected
51 | * @param string $message
52 | * @return self
53 | */
54 | public function equalsCanonicalizing($expected, string $message = ''): self
55 | {
56 | Assert::assertEqualsCanonicalizing($expected, $this->actual, $message);
57 | return $this;
58 | }
59 |
60 | /**
61 | * Verifies that two variables are equal (ignoring case).
62 | *
63 | * @param $expected
64 | * @param string $message
65 | * @return self
66 | */
67 | public function equalsIgnoringCase($expected, string $message = ''): self
68 | {
69 | Assert::assertEqualsIgnoringCase($expected, $this->actual, $message);
70 | return $this;
71 | }
72 |
73 | /**
74 | * Verifies that two variables are equal (with delta).
75 | *
76 | * @param $expected
77 | * @param float $delta
78 | * @param string $message
79 | * @return self
80 | */
81 | public function equalsWithDelta($expected, float $delta, string $message = ''): self
82 | {
83 | Assert::assertEqualsWithDelta($expected, $this->actual, $delta, $message);
84 | return $this;
85 | }
86 |
87 | /**
88 | * Verifies that a condition is false.
89 | *
90 | * @param string $message
91 | * @return self
92 | */
93 | public function false(string $message = ''): self
94 | {
95 | Assert::assertFalse($this->actual, $message);
96 | return $this;
97 | }
98 |
99 | /**
100 | * Verifies that a variable is finite.
101 | *
102 | * @param string $message
103 | * @return self
104 | */
105 | public function finite(string $message = ''): self
106 | {
107 | Assert::assertFinite($this->actual, $message);
108 | return $this;
109 | }
110 |
111 | /**
112 | * Verifies that a value is greater than another value.
113 | *
114 | * @param $expected
115 | * @param string $message
116 | * @return self
117 | */
118 | public function greaterThan($expected, string $message = ''): self
119 | {
120 | Assert::assertGreaterThan($expected, $this->actual, $message);
121 | return $this;
122 | }
123 |
124 | /**
125 | * Verifies that a value is greater than or equal to another value.
126 | *
127 | * @param $expected
128 | * @param string $message
129 | * @return self
130 | */
131 | public function greaterThanOrEqual($expected, string $message = ''): self
132 | {
133 | Assert::assertGreaterThanOrEqual($expected, $this->actual, $message);
134 | return $this;
135 | }
136 |
137 | /**
138 | * Verifies that a variable is infinite.
139 | *
140 | * @param string $message
141 | * @return self
142 | */
143 | public function infinite(string $message = ''): self
144 | {
145 | Assert::assertInfinite($this->actual, $message);
146 | return $this;
147 | }
148 |
149 | /**
150 | * Verifies that a variable is of a given type.
151 | *
152 | * @param string $expected
153 | * @param string $message
154 | * @return self
155 | */
156 | public function instanceOf(string $expected, string $message = ''): self
157 | {
158 | Assert::assertInstanceOf($expected, $this->actual, $message);
159 | return $this;
160 | }
161 |
162 | /**
163 | * Verifies that a variable is of type array.
164 | *
165 | * @param string $message
166 | * @return self
167 | */
168 | public function isArray(string $message = ''): self
169 | {
170 | Assert::assertIsArray($this->actual, $message);
171 | return $this;
172 | }
173 |
174 | /**
175 | * Verifies that a variable is of type bool.
176 | *
177 | * @param string $message
178 | * @return self
179 | */
180 | public function isBool(string $message = ''): self
181 | {
182 | Assert::assertIsBool($this->actual, $message);
183 | return $this;
184 | }
185 |
186 | /**
187 | * Verifies that a variable is of type callable.
188 | *
189 | * @param string $message
190 | * @return self
191 | */
192 | public function isCallable(string $message = ''): self
193 | {
194 | Assert::assertIsCallable($this->actual, $message);
195 | return $this;
196 | }
197 |
198 | /**
199 | * Verifies that a variable is of type resource and is closed.
200 | *
201 | * @param string $message
202 | * @return self
203 | */
204 | public function isClosedResource(string $message = ''): self
205 | {
206 | Assert::assertIsClosedResource($this->actual, $message);
207 | return $this;
208 | }
209 |
210 | /**
211 | * Verifies that a variable is of type float.
212 | *
213 | * @param string $message
214 | * @return self
215 | */
216 | public function isFloat(string $message = ''): self
217 | {
218 | Assert::assertIsFloat($this->actual, $message);
219 | return $this;
220 | }
221 |
222 | /**
223 | * Verifies that a variable is of type int.
224 | *
225 | * @param string $message
226 | * @return self
227 | */
228 | public function isInt(string $message = ''): self
229 | {
230 | Assert::assertIsInt($this->actual, $message);
231 | return $this;
232 | }
233 |
234 | /**
235 | * Verifies that a variable is of type iterable.
236 | *
237 | * @param string $message
238 | * @return self
239 | */
240 | public function isIterable(string $message = ''): self
241 | {
242 | Assert::assertIsIterable($this->actual, $message);
243 | return $this;
244 | }
245 |
246 | /**
247 | * Verifies that a variable is not of type array.
248 | *
249 | * @param string $message
250 | * @return self
251 | */
252 | public function isNotArray(string $message = ''): self
253 | {
254 | Assert::assertIsNotArray($this->actual, $message);
255 | return $this;
256 | }
257 |
258 | /**
259 | * Verifies that a variable is not of type bool.
260 | *
261 | * @param string $message
262 | * @return self
263 | */
264 | public function isNotBool(string $message = ''): self
265 | {
266 | Assert::assertIsNotBool($this->actual, $message);
267 | return $this;
268 | }
269 |
270 | /**
271 | * Verifies that a variable is not of type callable.
272 | *
273 | * @param string $message
274 | * @return self
275 | */
276 | public function isNotCallable(string $message = ''): self
277 | {
278 | Assert::assertIsNotCallable($this->actual, $message);
279 | return $this;
280 | }
281 |
282 | /**
283 | * Verifies that a variable is not of type resource.
284 | *
285 | * @param string $message
286 | * @return self
287 | */
288 | public function isNotClosedResource(string $message = ''): self
289 | {
290 | Assert::assertIsNotClosedResource($this->actual, $message);
291 | return $this;
292 | }
293 |
294 | /**
295 | * Verifies that a variable is not of type float.
296 | *
297 | * @param string $message
298 | * @return self
299 | */
300 | public function isNotFloat(string $message = ''): self
301 | {
302 | Assert::assertIsNotFloat($this->actual, $message);
303 | return $this;
304 | }
305 |
306 | /**
307 | * Verifies that a variable is not of type int.
308 | *
309 | * @param string $message
310 | * @return self
311 | */
312 | public function isNotInt(string $message = ''): self
313 | {
314 | Assert::assertIsNotInt($this->actual, $message);
315 | return $this;
316 | }
317 |
318 | /**
319 | * Verifies that a variable is not of type iterable.
320 | *
321 | * @param string $message
322 | * @return self
323 | */
324 | public function isNotIterable(string $message = ''): self
325 | {
326 | Assert::assertIsNotIterable($this->actual, $message);
327 | return $this;
328 | }
329 |
330 | /**
331 | * Verifies that a variable is not of type numeric.
332 | *
333 | * @param string $message
334 | * @return self
335 | */
336 | public function isNotNumeric(string $message = ''): self
337 | {
338 | Assert::assertIsNotNumeric($this->actual, $message);
339 | return $this;
340 | }
341 |
342 | /**
343 | * Verifies that a variable is not of type object.
344 | *
345 | * @param string $message
346 | * @return self
347 | */
348 | public function isNotObject(string $message = ''): self
349 | {
350 | Assert::assertIsNotObject($this->actual, $message);
351 | return $this;
352 | }
353 |
354 | /**
355 | * Verifies that a variable is not of type resource.
356 | *
357 | * @param string $message
358 | * @return self
359 | */
360 | public function isNotResource(string $message = ''): self
361 | {
362 | Assert::assertIsNotResource($this->actual, $message);
363 | return $this;
364 | }
365 |
366 | /**
367 | * Verifies that a variable is not of type scalar.
368 | *
369 | * @param string $message
370 | * @return self
371 | */
372 | public function isNotScalar(string $message = ''): self
373 | {
374 | Assert::assertIsNotScalar($this->actual, $message);
375 | return $this;
376 | }
377 |
378 | /**
379 | * Verifies that a variable is not of type string.
380 | *
381 | * @param string $message
382 | * @return self
383 | */
384 | public function isNotString(string $message = ''): self
385 | {
386 | Assert::assertIsNotString($this->actual, $message);
387 | return $this;
388 | }
389 |
390 | /**
391 | * Verifies that a variable is of type numeric.
392 | *
393 | * @param string $message
394 | * @return self
395 | */
396 | public function isNumeric(string $message = ''): self
397 | {
398 | Assert::assertIsNumeric($this->actual, $message);
399 | return $this;
400 | }
401 |
402 | /**
403 | * Verifies that a variable is of type object.
404 | *
405 | * @param string $message
406 | * @return self
407 | */
408 | public function isObject(string $message = ''): self
409 | {
410 | Assert::assertIsObject($this->actual, $message);
411 | return $this;
412 | }
413 |
414 | /**
415 | * Verifies that a variable is of type resource.
416 | *
417 | * @param string $message
418 | * @return self
419 | */
420 | public function isResource(string $message = ''): self
421 | {
422 | Assert::assertIsResource($this->actual, $message);
423 | return $this;
424 | }
425 |
426 | /**
427 | * Verifies that a variable is of type scalar.
428 | *
429 | * @param string $message
430 | * @return self
431 | */
432 | public function isScalar(string $message = ''): self
433 | {
434 | Assert::assertIsScalar($this->actual, $message);
435 | return $this;
436 | }
437 |
438 | /**
439 | * Verifies that a variable is of type string.
440 | *
441 | * @param string $message
442 | * @return self
443 | */
444 | public function isString(string $message = ''): self
445 | {
446 | Assert::assertIsString($this->actual, $message);
447 | return $this;
448 | }
449 |
450 | /**
451 | * Verifies that a value is smaller than another value.
452 | *
453 | * @param $expected
454 | * @param string $message
455 | * @return self
456 | */
457 | public function lessThan($expected, string $message = ''): self
458 | {
459 | Assert::assertLessThan($expected, $this->actual, $message);
460 | return $this;
461 | }
462 |
463 | /**
464 | * Verifies that a value is smaller than or equal to another value.
465 | *
466 | * @param $expected
467 | * @param string $message
468 | * @return self
469 | */
470 | public function lessThanOrEqual($expected, string $message = ''): self
471 | {
472 | Assert::assertLessThanOrEqual($expected, $this->actual, $message);
473 | return $this;
474 | }
475 |
476 | /**
477 | * Verifies that a variable is nan.
478 | *
479 | * @param string $message
480 | * @return self
481 | */
482 | public function nan(string $message = ''): self
483 | {
484 | Assert::assertNan($this->actual, $message);
485 | return $this;
486 | }
487 |
488 | /**
489 | * Verifies that a variable is not empty.
490 | *
491 | * @param string $message
492 | * @return self
493 | */
494 | public function notEmpty(string $message = ''): self
495 | {
496 | Assert::assertNotEmpty($this->actual, $message);
497 | return $this;
498 | }
499 |
500 | /**
501 | * Verifies that two variables are not equal.
502 | *
503 | * @param $expected
504 | * @param string $message
505 | * @return self
506 | */
507 | public function notEquals($expected, string $message = ''): self
508 | {
509 | Assert::assertNotEquals($expected, $this->actual, $message);
510 | return $this;
511 | }
512 |
513 | /**
514 | * Verifies that two variables are not equal (canonicalizing).
515 | *
516 | * @param $expected
517 | * @param string $message
518 | * @return self
519 | */
520 | public function notEqualsCanonicalizing($expected, string $message = ''): self
521 | {
522 | Assert::assertNotEqualsCanonicalizing($expected, $this->actual, $message);
523 | return $this;
524 | }
525 |
526 | /**
527 | * Verifies that two variables are not equal (ignoring case).
528 | *
529 | * @param $expected
530 | * @param string $message
531 | * @return self
532 | */
533 | public function notEqualsIgnoringCase($expected, string $message = ''): self
534 | {
535 | Assert::assertNotEqualsIgnoringCase($expected, $this->actual, $message);
536 | return $this;
537 | }
538 |
539 | /**
540 | * Verifies that two variables are not equal (with delta).
541 | *
542 | * @param $expected
543 | * @param float $delta
544 | * @param string $message
545 | * @return self
546 | */
547 | public function notEqualsWithDelta($expected, float $delta, string $message = ''): self
548 | {
549 | Assert::assertNotEqualsWithDelta($expected, $this->actual, $delta, $message);
550 | return $this;
551 | }
552 |
553 | /**
554 | * Verifies that a condition is not false.
555 | *
556 | * @param string $message
557 | * @return self
558 | */
559 | public function notFalse(string $message = ''): self
560 | {
561 | Assert::assertNotFalse($this->actual, $message);
562 | return $this;
563 | }
564 |
565 | /**
566 | * Verifies that a variable is not of a given type.
567 | *
568 | * @param string $expected
569 | * @param string $message
570 | * @return self
571 | */
572 | public function notInstanceOf(string $expected, string $message = ''): self
573 | {
574 | Assert::assertNotInstanceOf($expected, $this->actual, $message);
575 | return $this;
576 | }
577 |
578 | /**
579 | * Verifies that a variable is not null.
580 | *
581 | * @param string $message
582 | * @return self
583 | */
584 | public function notNull(string $message = ''): self
585 | {
586 | Assert::assertNotNull($this->actual, $message);
587 | return $this;
588 | }
589 |
590 | /**
591 | * Verifies that two variables do not have the same type and value.
592 | *
593 | * @param $expected
594 | * @param string $message
595 | * @return self
596 | */
597 | public function notSame($expected, string $message = ''): self
598 | {
599 | Assert::assertNotSame($expected, $this->actual, $message);
600 | return $this;
601 | }
602 |
603 | /**
604 | * Verifies that a condition is not true.
605 | *
606 | * @param string $message
607 | * @return self
608 | */
609 | public function notTrue(string $message = ''): self
610 | {
611 | Assert::assertNotTrue($this->actual, $message);
612 | return $this;
613 | }
614 |
615 | /**
616 | * Verifies that a variable is null.
617 | *
618 | * @param string $message
619 | * @return self
620 | */
621 | public function null(string $message = ''): self
622 | {
623 | Assert::assertNull($this->actual, $message);
624 | return $this;
625 | }
626 |
627 | /**
628 | * Verifies that two variables have the same type and value.
629 | *
630 | * @param $expected
631 | * @param string $message
632 | * @return self
633 | */
634 | public function same($expected, string $message = ''): self
635 | {
636 | Assert::assertSame($expected, $this->actual, $message);
637 | return $this;
638 | }
639 |
640 | /**
641 | * Verifies that a condition is true.
642 | *
643 | * @param string $message
644 | * @return self
645 | */
646 | public function true(string $message = ''): self
647 | {
648 | Assert::assertTrue($this->actual, $message);
649 | return $this;
650 | }
651 | }
--------------------------------------------------------------------------------
/src/Codeception/Verify/Expectations/ExpectMixed.php:
--------------------------------------------------------------------------------
1 | actual, $message);
32 | return $this;
33 | }
34 |
35 | /**
36 | * Expect that a variable is not of type array.
37 | *
38 | * @param string $message
39 | * @return self
40 | */
41 | public function notToBeArray(string $message = ''): self
42 | {
43 | Assert::assertIsNotArray($this->actual, $message);
44 | return $this;
45 | }
46 |
47 | /**
48 | * Expect that a variable is not of type bool.
49 | *
50 | * @param string $message
51 | * @return self
52 | */
53 | public function notToBeBool(string $message = ''): self
54 | {
55 | Assert::assertIsNotBool($this->actual, $message);
56 | return $this;
57 | }
58 |
59 | /**
60 | * Expect that a variable is not of type callable.
61 | *
62 | * @param string $message
63 | * @return self
64 | */
65 | public function notToBeCallable(string $message = ''): self
66 | {
67 | Assert::assertIsNotCallable($this->actual, $message);
68 | return $this;
69 | }
70 |
71 | /**
72 | * Expect that a variable is not of type resource.
73 | *
74 | * @param string $message
75 | * @return self
76 | */
77 | public function notToBeClosedResource(string $message = ''): self
78 | {
79 | Assert::assertIsNotClosedResource($this->actual, $message);
80 | return $this;
81 | }
82 |
83 | /**
84 | * Expect that a variable is not empty.
85 | *
86 | * @param string $message
87 | * @return self
88 | */
89 | public function notToBeEmpty(string $message = ''): self
90 | {
91 | Assert::assertNotEmpty($this->actual, $message);
92 | return $this;
93 | }
94 |
95 | /**
96 | * Expect that a condition is not false.
97 | *
98 | * @param string $message
99 | * @return self
100 | */
101 | public function notToBeFalse(string $message = ''): self
102 | {
103 | Assert::assertNotFalse($this->actual, $message);
104 | return $this;
105 | }
106 |
107 | /**
108 | * Expect that a variable is not of type float.
109 | *
110 | * @param string $message
111 | * @return self
112 | */
113 | public function notToBeFloat(string $message = ''): self
114 | {
115 | Assert::assertIsNotFloat($this->actual, $message);
116 | return $this;
117 | }
118 |
119 | /**
120 | * Expect that a variable is not of a given type.
121 | *
122 | * @param string $expected
123 | * @param string $message
124 | * @return self
125 | */
126 | public function notToBeInstanceOf(string $expected, string $message = ''): self
127 | {
128 | Assert::assertNotInstanceOf($expected, $this->actual, $message);
129 | return $this;
130 | }
131 |
132 | /**
133 | * Expect that a variable is not of type int.
134 | *
135 | * @param string $message
136 | * @return self
137 | */
138 | public function notToBeInt(string $message = ''): self
139 | {
140 | Assert::assertIsNotInt($this->actual, $message);
141 | return $this;
142 | }
143 |
144 | /**
145 | * Expect that a variable is not of type iterable.
146 | *
147 | * @param string $message
148 | * @return self
149 | */
150 | public function notToBeIterable(string $message = ''): self
151 | {
152 | Assert::assertIsNotIterable($this->actual, $message);
153 | return $this;
154 | }
155 |
156 | /**
157 | * Expect that a variable is not null.
158 | *
159 | * @param string $message
160 | * @return self
161 | */
162 | public function notToBeNull(string $message = ''): self
163 | {
164 | Assert::assertNotNull($this->actual, $message);
165 | return $this;
166 | }
167 |
168 | /**
169 | * Expect that a variable is not of type numeric.
170 | *
171 | * @param string $message
172 | * @return self
173 | */
174 | public function notToBeNumeric(string $message = ''): self
175 | {
176 | Assert::assertIsNotNumeric($this->actual, $message);
177 | return $this;
178 | }
179 |
180 | /**
181 | * Expect that a variable is not of type object.
182 | *
183 | * @param string $message
184 | * @return self
185 | */
186 | public function notToBeObject(string $message = ''): self
187 | {
188 | Assert::assertIsNotObject($this->actual, $message);
189 | return $this;
190 | }
191 |
192 | /**
193 | * Expect that a variable is not of type resource.
194 | *
195 | * @param string $message
196 | * @return self
197 | */
198 | public function notToBeResource(string $message = ''): self
199 | {
200 | Assert::assertIsNotResource($this->actual, $message);
201 | return $this;
202 | }
203 |
204 | /**
205 | * Expect that a variable is not of type scalar.
206 | *
207 | * @param string $message
208 | * @return self
209 | */
210 | public function notToBeScalar(string $message = ''): self
211 | {
212 | Assert::assertIsNotScalar($this->actual, $message);
213 | return $this;
214 | }
215 |
216 | /**
217 | * Expect that a variable is not of type string.
218 | *
219 | * @param string $message
220 | * @return self
221 | */
222 | public function notToBeString(string $message = ''): self
223 | {
224 | Assert::assertIsNotString($this->actual, $message);
225 | return $this;
226 | }
227 |
228 | /**
229 | * Expect that a condition is not true.
230 | *
231 | * @param string $message
232 | * @return self
233 | */
234 | public function notToBeTrue(string $message = ''): self
235 | {
236 | Assert::assertNotTrue($this->actual, $message);
237 | return $this;
238 | }
239 |
240 | /**
241 | * Expect that two variables are not equal.
242 | *
243 | * @param $expected
244 | * @param string $message
245 | * @return self
246 | */
247 | public function notToEqual($expected, string $message = ''): self
248 | {
249 | Assert::assertNotEquals($expected, $this->actual, $message);
250 | return $this;
251 | }
252 |
253 | /**
254 | * Expect that two variables are not equal (canonicalizing).
255 | *
256 | * @param $expected
257 | * @param string $message
258 | * @return self
259 | */
260 | public function notToEqualCanonicalizing($expected, string $message = ''): self
261 | {
262 | Assert::assertNotEqualsCanonicalizing($expected, $this->actual, $message);
263 | return $this;
264 | }
265 |
266 | /**
267 | * Expect that two variables are not equal (ignoring case).
268 | *
269 | * @param $expected
270 | * @param string $message
271 | * @return self
272 | */
273 | public function notToEqualIgnoringCase($expected, string $message = ''): self
274 | {
275 | Assert::assertNotEqualsIgnoringCase($expected, $this->actual, $message);
276 | return $this;
277 | }
278 |
279 | /**
280 | * Expect that two variables are not equal (with delta).
281 | *
282 | * @param $expected
283 | * @param float $delta
284 | * @param string $message
285 | * @return self
286 | */
287 | public function notToEqualWithDelta($expected, float $delta, string $message = ''): self
288 | {
289 | Assert::assertNotEqualsWithDelta($expected, $this->actual, $delta, $message);
290 | return $this;
291 | }
292 |
293 | /**
294 | * Expect that two variables have the same type and value.
295 | *
296 | * @param $expected
297 | * @param string $message
298 | * @return self
299 | */
300 | public function toBe($expected, string $message = ''): self
301 | {
302 | Assert::assertSame($expected, $this->actual, $message);
303 | return $this;
304 | }
305 |
306 | /**
307 | * Expect that a variable is of type array.
308 | *
309 | * @param string $message
310 | * @return self
311 | */
312 | public function toBeArray(string $message = ''): self
313 | {
314 | Assert::assertIsArray($this->actual, $message);
315 | return $this;
316 | }
317 |
318 | /**
319 | * Expect that a variable is of type bool.
320 | *
321 | * @param string $message
322 | * @return self
323 | */
324 | public function toBeBool(string $message = ''): self
325 | {
326 | Assert::assertIsBool($this->actual, $message);
327 | return $this;
328 | }
329 |
330 | /**
331 | * Expect that a variable is of type callable.
332 | *
333 | * @param string $message
334 | * @return self
335 | */
336 | public function toBeCallable(string $message = ''): self
337 | {
338 | Assert::assertIsCallable($this->actual, $message);
339 | return $this;
340 | }
341 |
342 | /**
343 | * Expect that a variable is of type resource and is closed.
344 | *
345 | * @param string $message
346 | * @return self
347 | */
348 | public function toBeClosedResource(string $message = ''): self
349 | {
350 | Assert::assertIsClosedResource($this->actual, $message);
351 | return $this;
352 | }
353 |
354 | /**
355 | * Expect that a variable is empty.
356 | *
357 | * @param string $message
358 | * @return self
359 | */
360 | public function toBeEmpty(string $message = ''): self
361 | {
362 | Assert::assertEmpty($this->actual, $message);
363 | return $this;
364 | }
365 |
366 | /**
367 | * Expect that a condition is false.
368 | *
369 | * @param string $message
370 | * @return self
371 | */
372 | public function toBeFalse(string $message = ''): self
373 | {
374 | Assert::assertFalse($this->actual, $message);
375 | return $this;
376 | }
377 |
378 | /**
379 | * Expect that a variable is finite.
380 | *
381 | * @param string $message
382 | * @return self
383 | */
384 | public function toBeFinite(string $message = ''): self
385 | {
386 | Assert::assertFinite($this->actual, $message);
387 | return $this;
388 | }
389 |
390 | /**
391 | * Expect that a variable is of type float.
392 | *
393 | * @param string $message
394 | * @return self
395 | */
396 | public function toBeFloat(string $message = ''): self
397 | {
398 | Assert::assertIsFloat($this->actual, $message);
399 | return $this;
400 | }
401 |
402 | /**
403 | * Expect that a value is greater than another value.
404 | *
405 | * @param $expected
406 | * @param string $message
407 | * @return self
408 | */
409 | public function toBeGreaterThan($expected, string $message = ''): self
410 | {
411 | Assert::assertGreaterThan($expected, $this->actual, $message);
412 | return $this;
413 | }
414 |
415 | /**
416 | * Expect that a value is greater than or equal to another value.
417 | *
418 | * @param $expected
419 | * @param string $message
420 | * @return self
421 | */
422 | public function toBeGreaterThanOrEqualTo($expected, string $message = ''): self
423 | {
424 | Assert::assertGreaterThanOrEqual($expected, $this->actual, $message);
425 | return $this;
426 | }
427 |
428 | /**
429 | * Expect that a variable is infinite.
430 | *
431 | * @param string $message
432 | * @return self
433 | */
434 | public function toBeInfinite(string $message = ''): self
435 | {
436 | Assert::assertInfinite($this->actual, $message);
437 | return $this;
438 | }
439 |
440 | /**
441 | * Expect that a variable is of a given type.
442 | *
443 | * @param string $expected
444 | * @param string $message
445 | * @return self
446 | */
447 | public function toBeInstanceOf(string $expected, string $message = ''): self
448 | {
449 | Assert::assertInstanceOf($expected, $this->actual, $message);
450 | return $this;
451 | }
452 |
453 | /**
454 | * Expect that a variable is of type int.
455 | *
456 | * @param string $message
457 | * @return self
458 | */
459 | public function toBeInt(string $message = ''): self
460 | {
461 | Assert::assertIsInt($this->actual, $message);
462 | return $this;
463 | }
464 |
465 | /**
466 | * Expect that a variable is of type iterable.
467 | *
468 | * @param string $message
469 | * @return self
470 | */
471 | public function toBeIterable(string $message = ''): self
472 | {
473 | Assert::assertIsIterable($this->actual, $message);
474 | return $this;
475 | }
476 |
477 | /**
478 | * Expect that a value is smaller than another value.
479 | *
480 | * @param $expected
481 | * @param string $message
482 | * @return self
483 | */
484 | public function toBeLessThan($expected, string $message = ''): self
485 | {
486 | Assert::assertLessThan($expected, $this->actual, $message);
487 | return $this;
488 | }
489 |
490 | /**
491 | * Expect that a value is smaller than or equal to another value.
492 | *
493 | * @param $expected
494 | * @param string $message
495 | * @return self
496 | */
497 | public function toBeLessThanOrEqualTo($expected, string $message = ''): self
498 | {
499 | Assert::assertLessThanOrEqual($expected, $this->actual, $message);
500 | return $this;
501 | }
502 |
503 | /**
504 | * Expect that a variable is nan.
505 | *
506 | * @param string $message
507 | * @return self
508 | */
509 | public function toBeNan(string $message = ''): self
510 | {
511 | Assert::assertNan($this->actual, $message);
512 | return $this;
513 | }
514 |
515 | /**
516 | * Expect that a variable is null.
517 | *
518 | * @param string $message
519 | * @return self
520 | */
521 | public function toBeNull(string $message = ''): self
522 | {
523 | Assert::assertNull($this->actual, $message);
524 | return $this;
525 | }
526 |
527 | /**
528 | * Expect that a variable is of type numeric.
529 | *
530 | * @param string $message
531 | * @return self
532 | */
533 | public function toBeNumeric(string $message = ''): self
534 | {
535 | Assert::assertIsNumeric($this->actual, $message);
536 | return $this;
537 | }
538 |
539 | /**
540 | * Expect that a variable is of type object.
541 | *
542 | * @param string $message
543 | * @return self
544 | */
545 | public function toBeObject(string $message = ''): self
546 | {
547 | Assert::assertIsObject($this->actual, $message);
548 | return $this;
549 | }
550 |
551 | /**
552 | * Expect that a variable is of type resource.
553 | *
554 | * @param string $message
555 | * @return self
556 | */
557 | public function toBeResource(string $message = ''): self
558 | {
559 | Assert::assertIsResource($this->actual, $message);
560 | return $this;
561 | }
562 |
563 | /**
564 | * Expect that a variable is of type scalar.
565 | *
566 | * @param string $message
567 | * @return self
568 | */
569 | public function toBeScalar(string $message = ''): self
570 | {
571 | Assert::assertIsScalar($this->actual, $message);
572 | return $this;
573 | }
574 |
575 | /**
576 | * Expect that a variable is of type string.
577 | *
578 | * @param string $message
579 | * @return self
580 | */
581 | public function toBeString(string $message = ''): self
582 | {
583 | Assert::assertIsString($this->actual, $message);
584 | return $this;
585 | }
586 |
587 | /**
588 | * Expect that a condition is true.
589 | *
590 | * @param string $message
591 | * @return self
592 | */
593 | public function toBeTrue(string $message = ''): self
594 | {
595 | Assert::assertTrue($this->actual, $message);
596 | return $this;
597 | }
598 |
599 | /**
600 | * Expect that two variables are equal.
601 | *
602 | * @param $expected
603 | * @param string $message
604 | * @return self
605 | */
606 | public function toEqual($expected, string $message = ''): self
607 | {
608 | Assert::assertEquals($expected, $this->actual, $message);
609 | return $this;
610 | }
611 |
612 | /**
613 | * Expect that two variables are equal (canonicalizing).
614 | *
615 | * @param $expected
616 | * @param string $message
617 | * @return self
618 | */
619 | public function toEqualCanonicalizing($expected, string $message = ''): self
620 | {
621 | Assert::assertEqualsCanonicalizing($expected, $this->actual, $message);
622 | return $this;
623 | }
624 |
625 | /**
626 | * Expect that two variables are equal (ignoring case).
627 | *
628 | * @param $expected
629 | * @param string $message
630 | * @return self
631 | */
632 | public function toEqualIgnoringCase($expected, string $message = ''): self
633 | {
634 | Assert::assertEqualsIgnoringCase($expected, $this->actual, $message);
635 | return $this;
636 | }
637 |
638 | /**
639 | * Expect that two variables are equal (with delta).
640 | *
641 | * @param $expected
642 | * @param float $delta
643 | * @param string $message
644 | * @return self
645 | */
646 | public function toEqualWithDelta($expected, float $delta, string $message = ''): self
647 | {
648 | Assert::assertEqualsWithDelta($expected, $this->actual, $delta, $message);
649 | return $this;
650 | }
651 | }
--------------------------------------------------------------------------------