diff --git a/.gitignore b/.gitignore
index 87dc28f..ee17e23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
vendor
.idea
.phpunit.result.cache
+composer.lock
composer.phar
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 9b16d08..491c66e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,6 @@
language: php
php:
- - 7.1
- - 7.2
- 7.3
- 7.4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24e0e6b..8ab46de 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,14 @@
# Changelog
+## 2.0
+
+* Support for Chained Verifiers.
+* The Verify API is now fully based on the PHPUnit public API.
+* Improved IDE autocompletion depending on the type of data you want to verify
+* Simplified data validations.
+* Improved code quality, performance and maintainability.
+* See **BC** details in the UPGRADE.md file.
+
## 1.5
* Support for full PHPUnit API `(42 new verifiers!)`
diff --git a/README.md b/README.md
index 037bf2c..3631555 100644
--- a/README.md
+++ b/README.md
@@ -19,30 +19,36 @@ With [BDD][3] assertions influenced by [Chai][4], [Jasmine][5], and [RSpec][6] y
composer require codeception/verify --dev
```
+> :arrow_up: **Upgrade from 1.x by following [the upgrade guide.][9]**
+
+
## Usage
Use in any test `verify` function instead of `$this->assert*` methods:
```php
+use Codeception\Verify\Verify;
+
$user = User::find(1);
-// equal
+// equals
verify($user->getName())->equals('davert');
-verify("user have 5 posts", $user->getNumPosts())->equals(5);
-verify($user->getNumPosts())->notEquals(3);
+
+verify($user->getNumPosts())
+ ->equals(5, 'user have 5 posts')
+ ->notEquals(3);
// contains
-verify('first user is admin', $user->getRoles())->contains('admin');
-verify("first user is not banned", $user->getRoles())->notContains('banned');
+Verify::Array($user->getRoles())
+ ->contains('admin', 'first user is admin')
+ ->notContains('banned', 'first user is not banned');
-// greater / less
-$rate = $user->getRate();
-verify('first user rate is 7', $rate)->equals(7);
-verify($rate)->greaterThan(5);
-verify($rate)->lessThan(10);
-verify($rate)->lessOrEquals(7);
-verify($rate)->greaterOrEquals(5);
+// greater / less
+verify($user->getRate())
+ ->greaterThan(5)
+ ->lessThan(10)
+ ->equals(7, 'first user rate is 7');
// true / false / null
verify($user->isAdmin())->true();
@@ -51,68 +57,71 @@ verify($user->invitedBy)->null();
verify($user->getPosts())->notNull();
// empty
-verify($user->getComments())->isEmpty();
+verify($user->getComments())->empty();
verify($user->getRoles())->notEmpty();
// throws
-verify($callback)->throws();
-verify($callback)->throws(Exception::class);
-verify($callback)->throws(Exception::class, 'exception message');
-verify($callback)->throws(new Exception());
-verify($callback)->throws(new Exception('message'));
+Verify::Callable($callback)
+ ->throws()
+ ->throws(Exception::class)
+ ->throws(Exception::class, 'exception message')
+ ->throws(new Exception())
+ ->throws(new Exception('message'));
// does not throw
-verify($callback)->doesNotThrow();
-verify($callback)->throws(Exception::class);
-verify($callback)->doesNotThrow(new Exception());
+Verify::Callable($callback)
+ ->doesNotThrow()
+ ->throws(Exception::class)
+ ->doesNotThrow(new Exception());
// and many more !
```
-> ##### :page_facing_up: See Verifiers full list [here.][7]
-
-Shorthands for testing truth/fallacy:
-
-```php
-verify_that($user->isActivated());
-verify_not($user->isBanned());
-```
-
-These two functions don't check for strict true/false matching, rather `empty` function is used.
-`verify_that` checks that result is not empty value, `verify_not` does the opposite.
+> :page_facing_up: **See Verifiers full list [here.][7]**
## Alternative Syntax
-If you follow TDD/BDD you'd rather use `expect` instead of `verify`. Which are just an alias functions:
+If you follow TDD/BDD you'd rather use `expect` or `verify_that` instead of `verify`. Which are just an alias function:
```php
-expect("user have 5 posts", $user->getNumPosts())->equals(5);
-expect_that($user->isActive());
-expect_not($user->isBanned());
+expect($user->getNumPosts())->equals(5, 'user have 5 posts');
+
+verify_that($user->getRate())->equals(7, 'first user rate is 7');
```
## Extending
-In order to add more assertions you can override `Codeception\Verify` class:
+In order to add more assertions you can extend the abstract class `Verify`:
```php
-class MyVerify extends \Codeception\Verify {
+use Codeception\Verify\Verify;
+use PHPUnit\Framework\Assert;
+
+class MyVerify extends Verify {
+
+ //you can type $actual to only receive a specific data type
+
+ public function __construct($actual = null)
+ {
+ parent::__construct($actual);
+ }
- public function success()
+ public function success(string $message = '')
{
+ Assert::assertTrue(true, $message);
}
}
```
-Set the class name to `Codeception\Verify::$override` property to `verify` function use it:
+And use it!
```php
+$myVerify = new MyVerify;
-\Codeception\Verify::$override = MyVerify::class;
+$myVerify->success('it works!');
-// access overridden class
-verify('it works')->success();
+$myVerify::Mixed('this also')->notEquals('works');
```
## License
@@ -128,3 +137,4 @@ Verify is open-sourced software licensed under the [MIT][8] License.
[6]: http://rspec.info/
[7]: /docs/supported_verifiers.md
[8]: /LICENSE
+[9]: /UPGRADE.md
diff --git a/UPGRADE.md b/UPGRADE.md
new file mode 100644
index 0000000..31ae57a
--- /dev/null
+++ b/UPGRADE.md
@@ -0,0 +1,74 @@
+UPGRADE FROM 1.X TO 2.X
+=======================
+
+
+PHP version
+------
+
+ * Removed support for `PHP 7.1` & `PHP 7.2`.
+
+
+Verify function
+-------
+
+In version `2.x`, `verifiers` can be used as classes. Each verifier class handles a specific type of data.
+
+Thanks to this you can enjoy an autocompletion of your `IDE` much more intelligent than before...
+
+That is why **we remove some global functions** that have a less intuitive behavior.
+
+According to the above:
+
+ * `verify` no longer receives a `string $message` as a parameter, now each _**verifier**_ fulfills this function.
+ * `verify_not` was deleted. Use `verify()->empty` instead.
+ * `expect_that` and `expect_not` were deleted. Use `expect()->notEmpty` and `expect()->empty` instead.
+ * `expect_file` and `setIsFileExpectation` were deleted. Use `Verify::File()` instead.
+
+Verifiers
+-------
+
+| Verify 1.x | Verify 2.x |
+|-------------------------------------------------|-------------------------------------------------|
+| `verify()->array` | `verify()->isArray` |
+| `verify()->bool` | `verify()->isBool` |
+| `verify()->callable` | `verify()->isCallable` |
+| `verify()->float` | `verify()->isFloat` |
+| `verify()->greaterOrEquals` | `verify()->greaterThanOrEqual` |
+| `verify()->int` | `verify()->isInt` |
+| `verify()->isEmpty` | `verify()->empty` |
+| `verify()->isInstanceOf` | `verify()->instanceOf` |
+| `verify()->isNotInstanceOf` | `verify()->notInstanceOf` |
+| `verify()->lessOrEquals` | `verify()->lessThanOrEqual` |
+| `verify()->notArray` | `verify()->isNotArray` |
+| `verify()->notBool` | `verify()->isNotBool` |
+| `verify()->notCallable` | `verify()->isNotCallable` |
+| `verify()->notFloat` | `verify()->isNotFloat` |
+| `verify()->notInt` | `verify()->isNotInt` |
+| `verify()->notNumeric` | `verify()->isNotNumeric` |
+| `verify()->notObject` | `verify()->isNotObject` |
+| `verify()->notResource` | `verify()->isNotResource` |
+| `verify()->notScalar` | `verify()->isNotScalar` |
+| `verify()->notString` | `verify()->isNotString` |
+| `verify()->numeric` | `verify()->isNumeric` |
+| `verify()->object` | `verify()->isObject` |
+| `verify()->resource` | `verify()->isResource` |
+| `verify()->scalar` | `verify()->isScalar` |
+| `verify()->string` | `verify()->isString` |
+| `verify()->hasAttribute` | `Verify()->baseObjectHasAttribute` |
+| `verify()->notHasAttribute` | `Verify()->baseObjectNotHasAttribute` |
+| `verify()->throws` | `Verify()->callableThrows` |
+| `verify()->doesNotThrow` | `Verify()->callableDoesNotThrow` |
+| `verify()->hasStaticAttribute` | `Verify()->classHasStaticAttribute` |
+| `verify()->notHasStaticAttribute` | `Verify()->classNotHasStaticAttribute` |
+| `verify()->hasAttribute` | `Verify()->classHasAttribute` |
+| `verify()->notHasAttribute` | `Verify()->classNotHasAttribute` |
+| `verify()->notExists` | `Verify()->fileDoesNotExists` |
+| `verify()->regExp` | `Verify()->stringMatchesRegExp` |
+| `verify()->notRegExp` | `Verify()->stringDoesNotMatchRegExp` |
+| `verify()->notStartsWith` | `Verify()->stringNotStartsWith` |
+
+
+Extending
+-------
+
+ * `Codeception\Verify::$override` was removed, extend from abstract `Codeception\Verify\Verify` class instead.
diff --git a/composer.json b/composer.json
index d0e99a9..f1a2232 100644
--- a/composer.json
+++ b/composer.json
@@ -13,14 +13,15 @@
}
],
"require": {
- "php": ">= 7.1",
+ "php": "^7.3",
"ext-dom": "*",
- "phpunit/phpunit": ">= 7.0",
- "codeception/phpunit-wrapper": "^7.8.0 | ^8.1.2 | ^9.0.2"
+ "phpunit/phpunit": "^9.3"
},
"autoload": {
- "files": ["src/Codeception/function.php"],
- "psr-4":{
+ "files": [
+ "src/Codeception/bootstrap.php"
+ ],
+ "psr-4": {
"Codeception\\": "src\\Codeception"
}
}
diff --git a/docs/supported_verifiers.md b/docs/supported_verifiers.md
index bff0184..6ad05b4 100644
--- a/docs/supported_verifiers.md
+++ b/docs/supported_verifiers.md
@@ -1,5 +1,7 @@
## Verifiers List
+`verify()` supports all the verifiers listed here! :rocket:
+
### Array
```
contains
@@ -17,81 +19,113 @@ notSameSize
sameSize
```
+### BaseObject
+```
+hasAttribute
+notHasAttribute
+```
+
+### Callable
+```
+throws
+doesNotThrow
+```
+
+### Class
+```
+hasAttribute
+hasStaticAttribute
+notHasAttribute
+notHasStaticAttribute
+```
+
### Directory
```
-directoryDoesNotExist
-directoryExists
-directoryIsNotReadable
-directoryIsNotWritable
-directoryIsReadable
-directoryIsWritable
+doesNotExist
+exists
+isNotReadable
+isNotWritable
+isReadable
+isWritable
```
+
### File
```
-setIsFileExpectation
+doesNotExists
equals
-notEquals
+equalsCanonicalizing
+equalsIgnoringCase
exists
-notExists
+isNotReadable
+isNotWritable
+isReadable
+isWritable
+notEquals
+notEqualsCanonicalizing
+notEqualsIgnoringCase
+```
+
+### JsonFile
+```
equalsJsonFile
-equalsXmlFile
-fileEqualsCanonicalizing
-fileEqualsIgnoringCase
-fileIsNotReadable
-fileIsNotWritable
-fileIsReadable
-fileIsWritable
-fileNotEqualsCanonicalizing
-fileNotEqualsIgnoringCase
-jsonFileNotEqualsJsonFile
-jsonStringNotEqualsJsonFile
+notEqualsJsonFile
+```
+
+### JsonString
+```
+equalsJsonFile
+equalsJsonString
+notEqualsJsonFile
+notEqualsJsonString
```
### Mixed
```
-isEmpty
+empty
+equals
equalsCanonicalizing
equalsIgnoringCase
equalsWithDelta
false
finite
greaterThan
-greaterOrEquals
+greaterThanOrEqual
infinite
-isInstanceOf
-array
-bool
-callable
+instanceOf
+isArray
+isBool
+isCallable
isClosedResource
-float
-int
+isFloat
+isInt
isIterable
-notArray
-notBool
-notCallable
+isNotArray
+isNotBool
+isNotCallable
isNotClosedResource
-notFloat
-notInt
+isNotFloat
+isNotInt
isNotIterable
-notNumeric
-notObject
-notResource
-notScalar
-notString
-numeric
-object
-resource
-scalar
-string
+isNotNumeric
+isNotObject
+isNotResource
+isNotScalar
+isNotString
+isNumeric
+isObject
+isResource
+isScalar
+isString
lessThan
-lessOrEquals
+lessThanOrEqual
nan
notEmpty
+notEquals
notEqualsCanonicalizing
notEqualsIgnoringCase
notEqualsWithDelta
notFalse
-isNotInstanceOf
+notInstanceOf
notNull
notSame
notTrue
@@ -103,55 +137,39 @@ true
### String
```
-hasStaticAttribute
-notHasStaticAttribute
-json
-jsonStringNotEqualsJsonString
-notRegExp
-equalsJsonString
-regExp
-stringContainsString
-stringContainsStringIgnoringCase
-stringEqualsFileCanonicalizing
-stringEqualsFileIgnoringCase
-stringNotEqualsFileCanonicalizing
-stringNotEqualsFileIgnoringCase
-notEndsWith
+containsString
+containsStringIgnoringCase
+doesNotMatchRegExp
endsWith
equalsFile
+equalsFileCanonicalizing
+equalsFileIgnoringCase
+json
matchesFormat
matchesFormatFile
-stringNotContainsString
-stringNotContainsStringIgnoringCase
+matchesRegExp
+notContainsString
+notContainsStringIgnoringCase
+notEndsWith
+notEqualsFile
+notEqualsFileCanonicalizing
+notEqualsFileIgnoringCase
notMatchesFormat
notMatchesFormatFile
-notStartsWith
+startsNotWith
startsWith
-notEqualsFile
```
-### Union
-##### Object/String
-```
-hasAttribute
-notHasAttribute
-```
-##### File/Directory
+### XmlFile
```
-isNotReadable
-isNotWritable
-```
-
-### Throwable
-```
-throws
-doesNotThrow
+equalsXmlFile
+notEqualsXmlFile
```
-### Xml
+### XmlString
```
+equalsXmlFile
equalsXmlString
-xmlFileNotEqualsXmlFile
-xmlStringNotEqualsXmlFile
-xmlStringNotEqualsXmlString
+notEqualsXmlFile
+notEqualsXmlString
```
\ No newline at end of file
diff --git a/src/Codeception/Exception/InvalidVerifyException.php b/src/Codeception/Exception/InvalidVerifyException.php
index ba6112a..f04fd07 100644
--- a/src/Codeception/Exception/InvalidVerifyException.php
+++ b/src/Codeception/Exception/InvalidVerifyException.php
@@ -3,13 +3,15 @@
namespace Codeception\Exception;
use InvalidArgumentException;
+use function gettype;
+use function sprintf;
-class InvalidVerifyException extends InvalidArgumentException
+final class InvalidVerifyException extends InvalidArgumentException
{
public function __construct($verifyName, $actual)
{
$message = sprintf(
- "%s type can't be used with %s verify.",
+ "%s type cannot be used with %s verify.",
gettype($actual),
$verifyName
);
diff --git a/src/Codeception/Verify/Verifiers/VerifyAny.php b/src/Codeception/Verify/Verifiers/VerifyAny.php
new file mode 100644
index 0000000..f66b6cb
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyAny.php
@@ -0,0 +1,443 @@
+actual)->contains($needle, $message);
+ return $this;
+ }
+
+ public function arrayContainsEquals($needle, string $message = ''): self
+ {
+ self::Array($this->actual)->containsEquals($needle, $message);
+ return $this;
+ }
+
+ public function arrayContainsOnly($type, $isNativeType = null, string $message = ''): self
+ {
+ self::Array($this->actual)->containsOnly($type, $isNativeType, $message);
+ return $this;
+ }
+
+ public function arrayContainsOnlyInstancesOf($className, string $message = ''): self
+ {
+ self::Array($this->actual)->containsOnlyInstancesOf($className, $message);
+ return $this;
+ }
+
+ public function arrayCount($expectedCount, string $message = ''): self
+ {
+ self::Array($this->actual)->count($expectedCount, $message);
+ return $this;
+ }
+
+ public function arrayHasKey($key, string $message = ''): self
+ {
+ self::Array($this->actual)->hasKey($key, $message);
+ return $this;
+ }
+
+ public function arrayHasNotKey($key, string $message = ''): self
+ {
+ self::Array($this->actual)->hasNotKey($key, $message);
+ return $this;
+ }
+
+ public function arrayNotContains($needle, string $message = ''): self
+ {
+ self::Array($this->actual)->notContains($needle, $message);
+ return $this;
+ }
+
+ public function arrayNotContainsEquals($needle, string $message = ''): self
+ {
+ self::Array($this->actual)->notContainsEquals($needle, $message);
+ return $this;
+ }
+
+ public function arrayNotContainsOnly($type, $isNativeType = null, string $message = ''): self
+ {
+ self::Array($this->actual)->notContainsOnly($type, $isNativeType, $message);
+ return $this;
+ }
+
+ public function arrayNotCount($expectedCount, string $message = ''): self
+ {
+ self::Array($this->actual)->notCount($expectedCount, $message);
+ return $this;
+ }
+
+ public function arrayNotSameSize($expected, string $message = ''): self
+ {
+ self::Array($this->actual)->notSameSize($expected, $message);
+ return $this;
+ }
+
+ public function arraySameSize($expected, string $message = ''): self
+ {
+ self::Array($this->actual)->sameSize($expected, $message);
+ return $this;
+ }
+
+ public function baseObjectHasAttribute($attributeName, string $message = ''): self
+ {
+ self::BaseObject($this->actual)->hasAttribute($attributeName, $message);
+ return $this;
+ }
+
+ public function baseObjectNotHasAttribute($attributeName, string $message = ''): self
+ {
+ self::BaseObject($this->actual)->notHasAttribute($attributeName, $message);
+ return $this;
+ }
+
+ public function callableThrows($throws = null, string $message = ''): self
+ {
+ self::Callable($this->actual)->throws($throws, $message);
+ return $this;
+ }
+
+ public function callableDoesNotThrow($throws = null, string $message = ''): self
+ {
+ self::Callable($this->actual)->doesNotThrow($throws, $message);
+ return $this;
+ }
+
+ public function classHasAttribute($attributeName, string $message = ''): self
+ {
+ self::Class($this->actual)->hasAttribute($attributeName, $message);
+ return $this;
+ }
+
+ public function classHasStaticAttribute($attributeName, string $message = ''): self
+ {
+ self::Class($this->actual)->hasStaticAttribute($attributeName, $message);
+ return $this;
+ }
+
+ public function classNotHasAttribute($attributeName, string $message = ''): self
+ {
+ self::Class($this->actual)->notHasAttribute($attributeName, $message);
+ return $this;
+ }
+
+ public function classNotHasStaticAttribute($attributeName, string $message = ''): self
+ {
+ self::Class($this->actual)->notHasStaticAttribute($attributeName, $message);
+ return $this;
+ }
+
+ public function directoryDoesNotExist(string $message = ''): self
+ {
+ self::Directory($this->actual)->doesNotExist($message);
+ return $this;
+ }
+
+ public function directoryExists(string $message = ''): self
+ {
+ self::Directory($this->actual)->exists($message);
+ return $this;
+ }
+
+ public function directoryIsNotReadable(string $message = ''): self
+ {
+ self::Directory($this->actual)->isNotReadable($message);
+ return $this;
+ }
+
+ public function directoryIsNotWritable(string $message = ''): self
+ {
+ self::Directory($this->actual)->isNotWritable($message);
+ return $this;
+ }
+
+ public function directoryIsReadable(string $message = ''): self
+ {
+ self::Directory($this->actual)->isReadable($message);
+ return $this;
+ }
+
+ public function directoryIsWritable(string $message = ''): self
+ {
+ self::Directory($this->actual)->isWritable($message);
+ return $this;
+ }
+
+ public function fileDoesNotExists(string $message = ''): self
+ {
+ self::File($this->actual)->doesNotExists($message);
+ return $this;
+ }
+
+ public function fileEquals($expected, string $message = ''): self
+ {
+ self::File($this->actual)->equals($expected, $message);
+ return $this;
+ }
+
+ public function fileEqualsCanonicalizing($expected, string $message = ''): self
+ {
+ self::File($this->actual)->equalsCanonicalizing($expected, $message);
+ return $this;
+ }
+
+ public function fileEqualsIgnoringCase($expected, string $message = ''): self
+ {
+ self::File($this->actual)->equalsIgnoringCase($expected, $message);
+ return $this;
+ }
+
+ public function fileExists(string $message = ''): self
+ {
+ self::File($this->actual)->exists($message);
+ return $this;
+ }
+
+ public function fileIsNotReadable(string $message = ''): self
+ {
+ self::File($this->actual)->isNotReadable($message);
+ return $this;
+ }
+
+ public function fileIsNotWritable(string $message = ''): self
+ {
+ self::File($this->actual)->isNotWritable($message);
+ return $this;
+ }
+
+ public function fileIsReadable(string $message = ''): self
+ {
+ self::File($this->actual)->isReadable($message);
+ return $this;
+ }
+
+ public function fileIsWritable(string $message = ''): self
+ {
+ self::File($this->actual)->isWritable($message);
+ return $this;
+ }
+
+ public function fileNotEquals($expected, string $message = ''): self
+ {
+ self::File($this->actual)->notEquals($expected, $message);
+ return $this;
+ }
+
+ public function fileNotEqualsCanonicalizing($expected, string $message = ''): self
+ {
+ self::File($this->actual)->notEqualsCanonicalizing($expected, $message);
+ return $this;
+ }
+
+ public function fileNotEqualsIgnoringCase($expected, string $message = ''): self
+ {
+ self::File($this->actual)->notEqualsIgnoringCase($expected, $message);
+ return $this;
+ }
+
+ public function jsonFileEqualsJsonFile($expectedFile, string $message = ''): self
+ {
+ self::JsonFile($this->actual)->equalsJsonFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function jsonFileNotEqualsJsonFile($expectedFile, string $message = ''): self
+ {
+ self::JsonFile($this->actual)->notEqualsJsonFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function jsonStringEqualsJsonFile($expectedFile, string $message = ''): self
+ {
+ self::JsonString($this->actual)->equalsJsonFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function jsonStringEqualsJsonString($expectedJson, string $message = ''): self
+ {
+ self::JsonString($this->actual)->equalsJsonString($expectedJson, $message);
+ return $this;
+ }
+
+ public function jsonStringNotEqualsJsonFile($expectedFile, string $message = ''): self
+ {
+ self::JsonString($this->actual)->notEqualsJsonFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function jsonStringNotEqualsJsonString($expectedJson, string $message = ''): self
+ {
+ self::JsonString($this->actual)->notEqualsJsonString($expectedJson, $message);
+ return $this;
+ }
+
+ public function stringContainsString($needle, string $message = ''): self
+ {
+ self::String($this->actual)->containsString($needle, $message);
+ return $this;
+ }
+
+ public function stringContainsStringIgnoringCase($needle, string $message = ''): self
+ {
+ self::String($this->actual)->containsStringIgnoringCase($needle, $message);
+ return $this;
+ }
+
+ public function stringDoesNotMatchRegExp($pattern, string $message = ''): self
+ {
+ self::String($this->actual)->doesNotMatchRegExp($pattern, $message);
+ return $this;
+ }
+
+ public function stringEndsWith($suffix, string $message = ''): self
+ {
+ self::String($this->actual)->endsWith($suffix, $message);
+ return $this;
+ }
+
+ public function stringEqualsFile($expectedFile, string $message = ''): self
+ {
+ self::String($this->actual)->equalsFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function stringEqualsFileCanonicalizing($expectedFile, string $message = ''): self
+ {
+ self::String($this->actual)->equalsFileCanonicalizing($expectedFile, $message);
+ return $this;
+ }
+
+ public function stringEqualsFileIgnoringCase($expectedFile, string $message = ''): self
+ {
+ self::String($this->actual)->equalsFileIgnoringCase($expectedFile, $message);
+ return $this;
+ }
+
+ public function stringJson(string $message = ''): self
+ {
+ self::String($this->actual)->json($message);
+ return $this;
+ }
+
+ public function stringMatchesFormat($format, string $message = ''): self
+ {
+ self::String($this->actual)->matchesFormat($format, $message);
+ return $this;
+ }
+
+ public function stringMatchesFormatFile($formatFile, string $message = ''): self
+ {
+ self::String($this->actual)->matchesFormatFile($formatFile, $message);
+ return $this;
+ }
+
+ public function stringMatchesRegExp($pattern, string $message = ''): self
+ {
+ self::String($this->actual)->matchesRegExp($pattern, $message);
+ return $this;
+ }
+
+ public function stringNotContainsString($needle, string $message = ''): self
+ {
+ self::String($this->actual)->notContainsString($needle, $message);
+ return $this;
+ }
+
+ public function stringNotContainsStringIgnoringCase($needle, string $message = ''): self
+ {
+ self::String($this->actual)->notContainsStringIgnoringCase($needle, $message);
+ return $this;
+ }
+
+ public function stringNotEndsWith($suffix, string $message = ''): self
+ {
+ self::String($this->actual)->notEndsWith($suffix, $message);
+ return $this;
+ }
+
+ public function stringNotEqualsFile($expectedFile, string $message = ''): self
+ {
+ self::String($this->actual)->notEqualsFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function stringNotEqualsFileCanonicalizing($expectedFile, string $message = ''): self
+ {
+ self::String($this->actual)->notEqualsFileCanonicalizing($expectedFile, $message);
+ return $this;
+ }
+
+ public function stringNotEqualsFileIgnoringCase($expectedFile, string $message = ''): self
+ {
+ self::String($this->actual)->notEqualsFileIgnoringCase($expectedFile, $message);
+ return $this;
+ }
+
+ public function stringNotMatchesFormat($format, string $message = ''): self
+ {
+ self::String($this->actual)->notMatchesFormat($format, $message);
+ return $this;
+ }
+
+ public function stringNotMatchesFormatFile($formatFile, string $message = ''): self
+ {
+ self::String($this->actual)->notMatchesFormatFile($formatFile, $message);
+ return $this;
+ }
+
+ public function stringStartsNotWith($prefix, string $message = ''): self
+ {
+ self::String($this->actual)->startsNotWith($prefix, $message);
+ return $this;
+ }
+
+ public function stringStartsWith($prefix, string $message = ''): self
+ {
+ self::String($this->actual)->startsWith($prefix, $message);
+ return $this;
+ }
+
+ public function xmlFileEqualsXmlFile($expectedFile, string $message = ''): self
+ {
+ self::XmlFile($this->actual)->equalsXmlFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function xmlFileNotEqualsXmlFile($expectedFile, string $message = ''): self
+ {
+ self::XmlFile($this->actual)->notEqualsXmlFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function xmlStringEqualsXmlFile($expectedFile, string $message = ''): self
+ {
+ self::XmlString($this->actual)->equalsXmlFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function xmlStringEqualsXmlString($expectedXml, string $message = ''): self
+ {
+ self::XmlString($this->actual)->equalsXmlString($expectedXml, $message);
+ return $this;
+ }
+
+ public function xmlStringNotEqualsXmlFile($expectedFile, string $message = ''): self
+ {
+ self::XmlString($this->actual)->notEqualsXmlFile($expectedFile, $message);
+ return $this;
+ }
+
+ public function xmlStringNotEqualsXmlString($expectedXml, string $message = ''): self
+ {
+ self::XmlString($this->actual)->notEqualsXmlString($expectedXml, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyArray.php b/src/Codeception/Verify/Verifiers/VerifyArray.php
new file mode 100644
index 0000000..245116d
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyArray.php
@@ -0,0 +1,191 @@
+actual, $message);
+ return $this;
+ }
+
+ public function containsEquals($needle, string $message = ''): self
+ {
+ Assert::assertContainsEquals($needle, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a haystack contains only values of a given type.
+ *
+ * @param string $type
+ * @param bool|null $isNativeType
+ * @param string $message
+ * @return self
+ */
+ public function containsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
+ {
+ Assert::assertContainsOnly($type, $this->actual, $isNativeType, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a haystack contains only instances of a given class name.
+ *
+ * @param string $className
+ * @param string $message
+ * @return self
+ */
+ public function containsOnlyInstancesOf(string $className, string $message = ''): self
+ {
+ Assert::assertContainsOnlyInstancesOf($className, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies the number of elements of an array, Countable or Traversable.
+ *
+ * @param int $expectedCount
+ * @param string $message
+ * @return self
+ */
+ public function count(int $expectedCount, string $message = ''): self
+ {
+ Assert::assertCount($expectedCount, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that an array has a specified key.
+ *
+ * @param int|string $key
+ * @param string $message
+ * @return self
+ */
+ public function hasKey($key, string $message = ''): self
+ {
+ Assert::assertArrayHasKey($key, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that an array does not have a specified key.
+ *
+ * @param int|string $key
+ * @param string $message
+ * @return self
+ */
+ public function hasNotKey($key, string $message = ''): self
+ {
+ Assert::assertArrayNotHasKey($key, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a haystack does not contain a needle.
+ *
+ * @param $needle
+ * @param string $message
+ * @return self
+ */
+ public function notContains($needle, string $message = ''): self
+ {
+ Assert::assertNotContains($needle, $this->actual, $message);
+ return $this;
+ }
+
+ public function notContainsEquals($needle, $message = ''): self
+ {
+ Assert::assertNotContainsEquals($needle, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a haystack does not contain only values of a given type.
+ *
+ * @param string $type
+ * @param bool|null $isNativeType
+ * @param string $message
+ * @return self
+ */
+ public function notContainsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
+ {
+ Assert::assertNotContainsOnly($type, $this->actual, $isNativeType, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies the number of elements of an array, Countable or Traversable.
+ *
+ * @param int $expectedCount
+ * @param string $message
+ * @return self
+ */
+ public function notCount(int $expectedCount, string $message = ''): self
+ {
+ Assert::assertNotCount($expectedCount, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.
+ *
+ * @param Countable|iterable $expected
+ * @param string $message
+ * @return self
+ */
+ public function notSameSize($expected, string $message = ''): self
+ {
+ Assert::assertNotSameSize($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is the same.
+ *
+ * @param Countable|iterable $expected
+ * @param string $message
+ * @return self
+ */
+ public function sameSize($expected, string $message = ''): self
+ {
+ Assert::assertSameSize($expected, $this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyArrayTrait.php b/src/Codeception/Verify/Verifiers/VerifyArrayTrait.php
deleted file mode 100644
index 83d5d64..0000000
--- a/src/Codeception/Verify/Verifiers/VerifyArrayTrait.php
+++ /dev/null
@@ -1,185 +0,0 @@
-actual)) {
- TestCase::assertContains($needle, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- public function containsEquals($needle)
- {
- if(is_iterable($this->actual)) {
- TestCase::assertContainsEquals($needle, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a haystack contains only values of a given type.
- *
- * @param string $type
- * @param bool|null $isNativeType
- */
- public function containsOnly(string $type, $isNativeType = null)
- {
- if(is_iterable($this->actual)) {
- TestCase::assertContainsOnly($type, $this->actual, $isNativeType, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a haystack contains only instances of a given class name.
- *
- * @param string $className
- */
- public function containsOnlyInstancesOf(string $className)
- {
- if(is_iterable($this->actual)) {
- TestCase::assertContainsOnlyInstancesOf($className, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies the number of elements of an array, Countable or Traversable.
- *
- * @param int $expectedCount
- */
- public function count(int $expectedCount)
- {
- if(is_iterable($this->actual) || $this->actual instanceof Countable) {
- TestCase::assertCount($expectedCount, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that an array has a specified key.
- *
- * @param int|string $key
- */
- public function hasKey($key)
- {
- if (is_array($this->actual) || $this->actual instanceof ArrayAccess) {
- TestCase::assertArrayHasKey($key, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that an array does not have a specified key.
- *
- * @param int|string $key
- */
- public function hasNotKey($key)
- {
- if (is_array($this->actual) || $this->actual instanceof ArrayAccess) {
- TestCase::assertArrayNotHasKey($key, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a haystack does not contain a needle.
- *
- * @param $needle
- */
- public function notContains($needle)
- {
- if (is_iterable($this->actual)) {
- TestCase::assertNotContains($needle, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- public function notContainsEquals($needle)
- {
- if (is_iterable($this->actual)) {
- TestCase::assertNotContainsEquals($needle, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a haystack does not contain only values of a given type.
- *
- * @param string $type
- * @param bool|null $isNativeType
- */
- public function notContainsOnly(string $type, $isNativeType = null)
- {
- if(is_iterable($this->actual)) {
- TestCase::assertNotContainsOnly($type, $this->actual, $isNativeType, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies the number of elements of an array, Countable or Traversable.
- *
- * @param int $expectedCount
- */
- public function notCount(int $expectedCount)
- {
- if(is_iterable($this->actual) || $this->actual instanceof Countable) {
- TestCase::assertNotCount($expectedCount, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.
- *
- * @param Countable|iterable $expected
- */
- public function notSameSize($expected)
- {
- if(is_iterable($this->actual) || $this->actual instanceof Countable) {
- TestCase::assertNotSameSize($expected, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is the same.
- *
- * @param Countable|iterable $expected
- */
- public function sameSize($expected)
- {
- if(is_iterable($this->actual) || $this->actual instanceof Countable) {
- TestCase::assertSameSize($expected, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyBaseObject.php b/src/Codeception/Verify/Verifiers/VerifyBaseObject.php
new file mode 100644
index 0000000..ea7e41b
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyBaseObject.php
@@ -0,0 +1,47 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that an object does not have a specified attribute.
+ *
+ * @param string $attributeName
+ * @param string $message
+ * @return self
+ */
+ public function notHasAttribute(string $attributeName, string $message = ''): self
+ {
+ Assert::assertObjectNotHasAttribute($attributeName, $this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyCallable.php b/src/Codeception/Verify/Verifiers/VerifyCallable.php
new file mode 100644
index 0000000..4fa8861
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyCallable.php
@@ -0,0 +1,92 @@
+getMessage();
+ $throws = get_class($throws);
+ }
+
+ try {
+ call_user_func($this->actual);
+ } catch (Throwable $exception) {
+ if (!$throws) {
+ return $this; // it throws
+ }
+
+ $actualThrows = get_class($exception);
+ $actualMessage = $exception->getMessage();
+
+ Assert::assertSame($throws, $actualThrows, sprintf('exception \'%s\' was expected, but \'%s\' was thrown', $throws, $actualThrows));
+
+ if ($message) {
+ Assert::assertSame($message, $actualMessage, sprintf('exception message \'%s\' was expected, but \'%s\' was received', $message, $actualMessage));
+ }
+ }
+
+ if (!isset($exception)) {
+ throw new ExpectationFailedException(sprintf('exception \'%s\' was not thrown as expected', $throws));
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Exception|string|null $throws
+ * @param string|false $message
+ * @return $this
+ */
+ public function doesNotThrow($throws = null, $message = false): self
+ {
+ if ($throws instanceof Exception) {
+ $message = $throws->getMessage();
+ $throws = get_class($throws);
+ }
+
+ try {
+ call_user_func($this->actual);
+ } catch (Throwable $exception) {
+ if (!$throws) {
+ throw new ExpectationFailedException('exception was not expected to be thrown');
+ }
+
+ $actualThrows = get_class($exception);
+ $actualMessage = $exception->getMessage();
+
+ if ($throws !== $actualThrows) {
+ return $this;
+ }
+
+ if (!$message) {
+ throw new ExpectationFailedException(sprintf('exception \'%s\' was not expected to be thrown', $throws));
+ }
+
+ if ($message === $actualMessage) {
+ throw new ExpectationFailedException(sprintf('exception \'%s\' with message \'%s\' was not expected to be thrown', $throws, $message));
+ }
+ }
+
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyClass.php b/src/Codeception/Verify/Verifiers/VerifyClass.php
new file mode 100644
index 0000000..c498d81
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyClass.php
@@ -0,0 +1,73 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a class has a specified static attribute.
+ *
+ * @param string $attributeName
+ * @param string $message
+ * @return self
+ */
+ public function hasStaticAttribute(string $attributeName, string $message = ''): self
+ {
+ Assert::assertClassHasStaticAttribute($attributeName, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a class does not have a specified attribute.
+ *
+ * @param string $attributeName
+ * @param string $message
+ * @return self
+ */
+ public function notHasAttribute(string $attributeName, string $message = ''): self
+ {
+ Assert::assertClassNotHasAttribute($attributeName, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a class does not have a specified static attribute.
+ *
+ * @param string $attributeName
+ * @param string $message
+ * @return self
+ */
+ public function notHasStaticAttribute(string $attributeName, string $message = ''): self
+ {
+ Assert::assertClassNotHasStaticAttribute($attributeName, $this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyDataTrait.php b/src/Codeception/Verify/Verifiers/VerifyDataTrait.php
new file mode 100644
index 0000000..8f16573
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyDataTrait.php
@@ -0,0 +1,56 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a file/dir exists and is not writable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotWritable(string $message = ''): self
+ {
+ Assert::assertIsNotWritable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a file/dir is readable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isReadable(string $message = ''): self
+ {
+ Assert::assertIsReadable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a file/dir exists and is writable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isWritable(string $message = ''): self
+ {
+ Assert::assertIsWritable($this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyDirectory.php b/src/Codeception/Verify/Verifiers/VerifyDirectory.php
new file mode 100644
index 0000000..ea800b1
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyDirectory.php
@@ -0,0 +1,91 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a directory exists.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function exists(string $message = ''): self
+ {
+ Assert::assertDirectoryExists($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a directory exists and is not readable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotReadable(string $message = ''): self
+ {
+ Assert::assertDirectoryIsNotReadable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a directory exists and is not writable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotWritable(string $message = ''): self
+ {
+ Assert::assertDirectoryIsNotWritable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a directory exists and is readable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isReadable(string $message = ''): self
+ {
+ Assert::assertDirectoryIsReadable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a directory exists and is writable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isWritable(string $message = ''): self
+ {
+ Assert::assertDirectoryIsWritable($this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyDirectoryTrait.php b/src/Codeception/Verify/Verifiers/VerifyDirectoryTrait.php
deleted file mode 100644
index 697bc0f..0000000
--- a/src/Codeception/Verify/Verifiers/VerifyDirectoryTrait.php
+++ /dev/null
@@ -1,81 +0,0 @@
-actual)) {
- TestCase::assertDirectoryDoesNotExist($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a directory exists.
- */
- public function directoryExists()
- {
- if(is_string($this->actual)) {
- TestCase::assertDirectoryExists($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a directory exists and is not readable.
- */
- public function directoryIsNotReadable()
- {
- if(is_string($this->actual)) {
- TestCase::assertDirectoryIsNotReadable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a directory exists and is not writable.
- */
- public function directoryIsNotWritable()
- {
- if(is_string($this->actual)) {
- TestCase::assertDirectoryIsNotWritable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a directory exists and is readable.
- */
- public function directoryIsReadable()
- {
- if(is_string($this->actual)) {
- TestCase::assertDirectoryIsReadable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a directory exists and is writable.
- */
- public function directoryIsWritable()
- {
- if(is_string($this->actual)) {
- TestCase::assertDirectoryIsWritable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyFile.php b/src/Codeception/Verify/Verifiers/VerifyFile.php
new file mode 100644
index 0000000..9732367
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyFile.php
@@ -0,0 +1,164 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of one file is equal to the contents of another file.
+ *
+ * @param string $expected
+ * @param string $message
+ * @return self
+ */
+ public function equals(string $expected, string $message = ''): self
+ {
+ Assert::assertFileEquals($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of one file is equal to the contents of another file (canonicalizing).
+ *
+ * @param string $expected
+ * @param string $message
+ * @return self
+ */
+ public function equalsCanonicalizing(string $expected, string $message = ''): self
+ {
+ Assert::assertFileEqualsCanonicalizing($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of one file is equal to the contents of another file (ignoring case).
+ *
+ * @param string $expected
+ * @param string $message
+ * @return self
+ */
+ public function equalsIgnoringCase(string $expected, string $message = ''): self
+ {
+ Assert::assertFileEqualsIgnoringCase($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a file exists.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function exists(string $message = ''): self
+ {
+ Assert::assertFileExists($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a file exists and is not readable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotReadable(string $message = ''): self
+ {
+ Assert::assertFileIsNotReadable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a file exists and is not writable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotWritable(string $message = ''): self
+ {
+ Assert::assertFileIsNotWritable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a file exists and is readable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isReadable(string $message = ''): self
+ {
+ Assert::assertFileIsReadable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a file exists and is writable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isWritable(string $message = ''): self
+ {
+ Assert::assertFileIsWritable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of one file is not equal to the contents of another file.
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function notEquals(string $expected, string $message = ''): self
+ {
+ Assert::assertFileNotEquals($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of one file is not equal to the contents of another file (canonicalizing).
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsCanonicalizing(string $expected, string $message = ''): self
+ {
+ Assert::assertFileNotEqualsCanonicalizing($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of one file is not equal to the contents of another file (ignoring case).
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsIgnoringCase(string $expected, string $message = ''): self
+ {
+ Assert::assertFileNotEqualsIgnoringCase($expected, $this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyFileTrait.php b/src/Codeception/Verify/Verifiers/VerifyFileTrait.php
deleted file mode 100644
index ec9f710..0000000
--- a/src/Codeception/Verify/Verifiers/VerifyFileTrait.php
+++ /dev/null
@@ -1,204 +0,0 @@
-isFileExpectation = $isFileExpectation;
- }
-
- public function equals($expected, $delta = 0)
- {
- if ( ! $this->isFileExpectation ) {
- TestCase::assertEqualsWithDelta($expected, $this->actual, $delta, $this->message);
- } else {
- TestCase::assertFileEquals($expected, $this->actual, $this->message);
- }
- // TestCase::assertEquals($expected, $actual, $message);
- }
-
- public function notEquals($expected, $delta = 0)
- {
- if ( ! $this->isFileExpectation ) {
- TestCase::assertNotEqualsWithDelta($expected, $this->actual, $delta, $this->message);
- } else {
- TestCase::assertFileNotEquals($expected, $this->actual, $this->message);
- }
- // TestCase::assertNotEquals($expected, $actual, $message);
- }
-
- public function exists()
- {
- if (!$this->isFileExpectation ) {
- throw new Exception('exists() expectation should be called with expect_file()');
- }
- TestCase::assertFileExists($this->actual, $this->message);
- }
-
- public function notExists()
- {
- if (!$this->isFileExpectation ) {
- throw new Exception('notExists() expectation should be called with expect_file()');
- }
- TestCase::assertFileNotExists($this->actual, $this->message);
- }
-
- public function equalsJsonFile($file)
- {
- if (!$this->isFileExpectation ) {
- TestCase::assertJsonStringEqualsJsonFile($file, $this->actual, $this->message);
- } else {
- TestCase::assertJsonFileEqualsJsonFile($file, $this->actual, $this->message);
- }
- }
-
- public function equalsXmlFile($file)
- {
- if (!$this->isFileExpectation ) {
- TestCase::assertXmlStringEqualsXmlFile($file, $this->actual, $this->message);
- } else {
- TestCase::assertXmlFileEqualsXmlFile($file, $this->actual, $this->message);
- }
- }
-
- /**
- * Verifies that the contents of one file is equal to the contents of another file (canonicalizing).
- *
- * @param $expected
- */
- public function fileEqualsCanonicalizing($expected)
- {
- if (is_string($this->actual)) {
- TestCase::assertFileEqualsCanonicalizing($expected, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the contents of one file is equal to the contents of another file (ignoring case).
- *
- * @param $expected
- */
- public function fileEqualsIgnoringCase($expected)
- {
- if (is_string($this->actual)) {
- TestCase::assertFileEqualsIgnoringCase($expected, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a file exists and is not readable.
- */
- public function fileIsNotReadable()
- {
- if (is_string($this->actual)) {
- TestCase::assertFileIsNotReadable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a file exists and is not writable.
- */
- public function fileIsNotWritable()
- {
- if (is_string($this->actual)) {
- TestCase::assertFileIsNotWritable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a file exists and is readable.
- */
- public function fileIsReadable()
- {
- if (is_string($this->actual)) {
- TestCase::assertFileIsReadable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a file exists and is writable.
- */
- public function fileIsWritable()
- {
- if (is_string($this->actual)) {
- TestCase::assertFileIsWritable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the contents of one file is not equal to the contents of another file (canonicalizing).
- *
- * @param $expected
- */
- public function fileNotEqualsCanonicalizing($expected)
- {
- if (is_string($this->actual)) {
- TestCase::assertFileNotEqualsCanonicalizing($expected, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the contents of one file is not equal to the contents of another file (ignoring case).
- *
- * @param $expected
- */
- public function fileNotEqualsIgnoringCase($expected)
- {
- if (is_string($this->actual)) {
- TestCase::assertFileNotEqualsIgnoringCase($expected, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that two JSON files are not equal.
- *
- * @param string $expectedFile
- */
- public function jsonFileNotEqualsJsonFile(string $expectedFile)
- {
- if (is_string($this->actual)) {
- TestCase::assertJsonFileNotEqualsJsonFile($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the generated JSON encoded object and the content of the given file are not equal.
- *
- * @param string $expectedFile
- */
- public function jsonStringNotEqualsJsonFile(string $expectedFile)
- {
- if (is_string($this->actual)) {
- TestCase::assertJsonStringNotEqualsJsonFile($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyJsonFile.php b/src/Codeception/Verify/Verifiers/VerifyJsonFile.php
new file mode 100644
index 0000000..3fb515c
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyJsonFile.php
@@ -0,0 +1,40 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two JSON files are not equal.
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsJsonFile(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertJsonFileNotEqualsJsonFile($expectedFile, $this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyJsonString.php b/src/Codeception/Verify/Verifiers/VerifyJsonString.php
new file mode 100644
index 0000000..936b376
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyJsonString.php
@@ -0,0 +1,66 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two given JSON encoded objects or arrays are equal.
+ *
+ * @param string $expectedJson
+ * @param string $message
+ * @return self
+ */
+ public function equalsJsonString(string $expectedJson, string $message = ''): self
+ {
+ Assert::assertJsonStringEqualsJsonString($expectedJson, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the generated JSON encoded object and the content of the given file are not equal.
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsJsonFile(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertJsonStringNotEqualsJsonFile($expectedFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two given JSON encoded objects or arrays are not equal.
+ *
+ * @param string $expectedJson
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsJsonString(string $expectedJson, string $message = ''): self
+ {
+ Assert::assertJsonStringNotEqualsJsonString($expectedJson, $this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyMixed.php b/src/Codeception/Verify/Verifiers/VerifyMixed.php
new file mode 100644
index 0000000..37e3ba6
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyMixed.php
@@ -0,0 +1,672 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables are equal.
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function equals($expected, string $message = ''): self
+ {
+ Assert::assertEquals($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables are equal (canonicalizing).
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function equalsCanonicalizing($expected, string $message = ''): self
+ {
+ Assert::assertEqualsCanonicalizing($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables are equal (ignoring case).
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function equalsIgnoringCase($expected, string $message = ''): self
+ {
+ Assert::assertEqualsIgnoringCase($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables are equal (with delta).
+ *
+ * @param $expected
+ * @param float $delta
+ * @param string $message
+ * @return self
+ */
+ public function equalsWithDelta($expected, float $delta, string $message = ''): self
+ {
+ Assert::assertEqualsWithDelta($expected, $this->actual, $delta, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a condition is false.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function false(string $message = ''): self
+ {
+ Assert::assertFalse($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is finite.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function finite(string $message = ''): self
+ {
+ Assert::assertFinite($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a value is greater than another value.
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function greaterThan($expected, string $message = ''): self
+ {
+ Assert::assertGreaterThan($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a value is greater than or equal to another value.
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function greaterThanOrEqual($expected, string $message = ''): self
+ {
+ Assert::assertGreaterThanOrEqual($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is infinite.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function infinite(string $message = ''): self
+ {
+ Assert::assertInfinite($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of a given type.
+ *
+ * @param string $expected
+ * @param string $message
+ * @return self
+ */
+ public function instanceOf(string $expected, string $message = ''): self
+ {
+ Assert::assertInstanceOf($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type array.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isArray(string $message = ''): self
+ {
+ Assert::assertIsArray($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type bool.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isBool(string $message = ''): self
+ {
+ Assert::assertIsBool($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type callable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isCallable(string $message = ''): self
+ {
+ Assert::assertIsCallable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type resource and is closed.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isClosedResource(string $message = ''): self
+ {
+ Assert::assertIsClosedResource($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type float.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isFloat(string $message = ''): self
+ {
+ Assert::assertIsFloat($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type int.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isInt(string $message = ''): self
+ {
+ Assert::assertIsInt($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type iterable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isIterable(string $message = ''): self
+ {
+ Assert::assertIsIterable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type array.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotArray(string $message = ''): self
+ {
+ Assert::assertIsNotArray($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type bool.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotBool(string $message = ''): self
+ {
+ Assert::assertIsNotBool($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type callable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotCallable(string $message = ''): self
+ {
+ Assert::assertIsNotCallable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type resource.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotClosedResource(string $message = ''): self
+ {
+ Assert::assertIsNotClosedResource($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type float.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotFloat(string $message = ''): self
+ {
+ Assert::assertIsNotFloat($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type int.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotInt(string $message = ''): self
+ {
+ Assert::assertIsNotInt($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type iterable.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotIterable(string $message = ''): self
+ {
+ Assert::assertIsNotIterable($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type numeric.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotNumeric(string $message = ''): self
+ {
+ Assert::assertIsNotNumeric($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type object.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotObject(string $message = ''): self
+ {
+ Assert::assertIsNotObject($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type resource.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotResource(string $message = ''): self
+ {
+ Assert::assertIsNotResource($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type scalar.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotScalar(string $message = ''): self
+ {
+ Assert::assertIsNotScalar($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of type string.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNotString(string $message = ''): self
+ {
+ Assert::assertIsNotString($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type numeric.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isNumeric(string $message = ''): self
+ {
+ Assert::assertIsNumeric($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type object.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isObject(string $message = ''): self
+ {
+ Assert::assertIsObject($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type resource.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isResource(string $message = ''): self
+ {
+ Assert::assertIsResource($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type scalar.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isScalar(string $message = ''): self
+ {
+ Assert::assertIsScalar($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is of type string.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function isString(string $message = ''): self
+ {
+ Assert::assertIsString($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a value is smaller than another value.
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function lessThan($expected, string $message = ''): self
+ {
+ Assert::assertLessThan($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a value is smaller than or equal to another value.
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function lessThanOrEqual($expected, string $message = ''): self
+ {
+ Assert::assertLessThanOrEqual($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is nan.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function nan(string $message = ''): self
+ {
+ Assert::assertNan($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not empty.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function notEmpty(string $message = ''): self
+ {
+ Assert::assertNotEmpty($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables are not equal.
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function notEquals($expected, string $message = ''): self
+ {
+ Assert::assertNotEquals($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables are not equal (canonicalizing).
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsCanonicalizing($expected, string $message = ''): self
+ {
+ Assert::assertNotEqualsCanonicalizing($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables are not equal (ignoring case).
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsIgnoringCase($expected, string $message = ''): self
+ {
+ Assert::assertNotEqualsIgnoringCase($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables are not equal (with delta).
+ *
+ * @param $expected
+ * @param float $delta
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsWithDelta($expected, float $delta, string $message = ''): self
+ {
+ Assert::assertNotEqualsWithDelta($expected, $this->actual, $delta, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a condition is not false.
+ *
+ * @param $condition
+ * @param string $message
+ * @return self
+ */
+ public function notFalse($condition, string $message = ''): self
+ {
+ Assert::assertNotFalse($condition, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not of a given type.
+ *
+ * @param string $expected
+ * @param string $message
+ * @return self
+ */
+ public function notInstanceOf(string $expected, string $message = ''): self
+ {
+ Assert::assertNotInstanceOf($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is not null.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function notNull(string $message = ''): self
+ {
+ Assert::assertNotNull($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables do not have the same type and value.
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function notSame($expected, string $message = ''): self
+ {
+ Assert::assertNotSame($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a condition is not true.
+ *
+ * @param $condition
+ * @param string $message
+ * @return self
+ */
+ public function notTrue($condition, string $message = ''): self
+ {
+ Assert::assertNotTrue($condition, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a variable is null.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function null(string $message = ''): self
+ {
+ Assert::assertNull($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two variables have the same type and value.
+ *
+ * @param $expected
+ * @param string $message
+ * @return self
+ */
+ public function same($expected, string $message = ''): self
+ {
+ Assert::assertSame($expected, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Evaluates a PHPUnit\Framework\Constraint matcher object.
+ *
+ * @param $value
+ * @param string $message
+ * @return self
+ */
+ public function that($value, string $message = ''): self
+ {
+ if ($this->actual instanceof Constraint) {
+ Assert::assertThat($value, $this->actual, $message);
+ return $this;
+ }
+ throw new InvalidVerifyException(
+ basename(__CLASS__).'->'.__FUNCTION__.'()',
+ $this->actual
+ );
+ }
+
+ /**
+ * Verifies that a condition is true.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function true(string $message = ''): self
+ {
+ Assert::assertTrue($this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyMixedTrait.php b/src/Codeception/Verify/Verifiers/VerifyMixedTrait.php
deleted file mode 100644
index f07e503..0000000
--- a/src/Codeception/Verify/Verifiers/VerifyMixedTrait.php
+++ /dev/null
@@ -1,450 +0,0 @@
-actual, $this->message);
- }
-
- /**
- * Verifies that two variables are equal (canonicalizing).
- *
- * @param $expected
- */
- public function equalsCanonicalizing($expected)
- {
- TestCase::assertEqualsCanonicalizing($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that two variables are equal (ignoring case).
- *
- * @param $expected
- */
- public function equalsIgnoringCase($expected)
- {
- TestCase::assertEqualsIgnoringCase($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that two variables are equal (with delta).
- *
- * @param $expected
- * @param float $delta
- */
- public function equalsWithDelta($expected, float $delta)
- {
- TestCase::assertEqualsWithDelta($expected, $this->actual, $delta, $this->message);
- }
-
- /**
- * Verifies that a condition is false.
- */
- public function false()
- {
- TestCase::assertFalse($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is finite.
- */
- public function finite()
- {
- TestCase::assertFinite($this->actual, $this->message);
- }
-
- /**
- * Verifies that a value is greater than another value.
- *
- * @param $expected
- */
- public function greaterThan($expected)
- {
- TestCase::assertGreaterThan($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that a value is greater than or equal to another value.
- *
- * @param $expected
- */
- public function greaterOrEquals($expected)
- {
- TestCase::assertGreaterThanOrEqual($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is infinite.
- */
- public function infinite()
- {
- TestCase::assertInfinite($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of a given type.
- *
- * @param string $expected
- */
- public function isInstanceOf(string $expected)
- {
- TestCase::assertInstanceOf($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type array.
- */
- public function array()
- {
- TestCase::assertIsArray($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type bool.
- */
- public function bool()
- {
- TestCase::assertIsBool($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type callable.
- */
- public function callable()
- {
- TestCase::assertIsCallable($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type resource and is closed.
- */
- public function isClosedResource()
- {
- TestCase::assertIsClosedResource($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type float.
- */
- public function float()
- {
- TestCase::assertIsFloat($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type int.
- */
- public function int()
- {
- TestCase::assertIsInt($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type iterable.
- */
- public function isIterable()
- {
- TestCase::assertIsIterable($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type array.
- */
- public function notArray()
- {
- TestCase::assertIsNotArray($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type bool.
- */
- public function notBool()
- {
- TestCase::assertIsNotBool($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type callable.
- */
- public function notCallable()
- {
- TestCase::assertIsNotCallable($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type resource.
- */
- public function isNotClosedResource()
- {
- TestCase::assertIsNotClosedResource($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type float.
- */
- public function notFloat()
- {
- TestCase::assertIsNotFloat($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type int.
- */
- public function notInt()
- {
- TestCase::assertIsNotInt($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type iterable.
- */
- public function isNotIterable()
- {
- TestCase::assertIsNotIterable($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type numeric.
- */
- public function notNumeric()
- {
- TestCase::assertIsNotNumeric($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type object.
- */
- public function notObject()
- {
- TestCase::assertIsNotObject($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type resource.
- */
- public function notResource()
- {
- TestCase::assertIsNotResource($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type scalar.
- */
- public function notScalar()
- {
- TestCase::assertIsNotScalar($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not of type string.
- */
- public function notString()
- {
- TestCase::assertIsNotString($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type numeric.
- */
- public function numeric()
- {
- TestCase::assertIsNumeric($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type object.
- */
- public function object()
- {
- TestCase::assertIsObject($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type resource.
- */
- public function resource()
- {
- TestCase::assertIsResource($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type scalar.
- */
- public function scalar()
- {
- TestCase::assertIsScalar($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is of type string.
- */
- public function string()
- {
- TestCase::assertIsString($this->actual, $this->message);
- }
-
- /**
- * Verifies that a value is smaller than another value.
- *
- * @param $expected
- */
- public function lessThan($expected)
- {
- TestCase::assertLessThan($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that a value is smaller than or equal to another value.
- *
- * @param $expected
- */
- public function lessOrEquals($expected)
- {
- TestCase::assertLessThanOrEqual($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is nan.
- */
- public function nan()
- {
- TestCase::assertNan($this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not empty.
- */
- public function notEmpty()
- {
- TestCase::assertNotEmpty($this->actual, $this->message);
- }
-
- /**
- * Verifies that two variables are not equal (canonicalizing).
- *
- * @param $expected
- */
- public function notEqualsCanonicalizing($expected)
- {
- TestCase::assertNotEqualsCanonicalizing($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that two variables are not equal (ignoring case).
- *
- * @param $expected
- */
- public function notEqualsIgnoringCase($expected)
- {
- TestCase::assertNotEqualsIgnoringCase($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that two variables are not equal (with delta).
- *
- * @param $expected
- * @param float $delta
- */
- public function notEqualsWithDelta($expected, float $delta)
- {
- TestCase::assertNotEqualsWithDelta($expected, $this->actual, $delta, $this->message);
- }
-
- /**
- * Verifies that a condition is not false.
- *
- * @param $condition
- */
- public function notFalse($condition)
- {
- TestCase::assertNotFalse($condition, $this->message);
- }
-
- /**
- * Verifies that a variable is not of a given type.
- *
- * @param string $expected
- */
- public function isNotInstanceOf(string $expected)
- {
- TestCase::assertNotInstanceOf($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that a variable is not null.
- */
- public function notNull()
- {
- TestCase::assertNotNull($this->actual, $this->message);
- }
-
- /**
- * Verifies that two variables do not have the same type and value.
- *
- * @param $expected
- */
- public function notSame($expected)
- {
- TestCase::assertNotSame($expected, $this->actual, $this->message);
- }
-
- /**
- * Verifies that a condition is not true.
- *
- * @param $condition
- */
- public function notTrue($condition)
- {
- TestCase::assertNotTrue($condition, $this->message);
- }
-
- /**
- * Verifies that a variable is null.
- */
- public function null()
- {
- TestCase::assertNull($this->actual, $this->message);
- }
-
- /**
- * Verifies that two variables have the same type and value.
- *
- * @param $expected
- */
- public function same($expected)
- {
- TestCase::assertSame($expected, $this->actual, $this->message);
- }
-
- /**
- * Evaluates a PHPUnit\Framework\Constraint matcher object.
- *
- * @param $value
- */
- public function that($value)
- {
- if ($this->actual instanceof Constraint) {
- TestCase::assertThat($value, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a condition is true.
- */
- public function true()
- {
- TestCase::assertTrue($this->actual, $this->message);
- }
-}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyString.php b/src/Codeception/Verify/Verifiers/VerifyString.php
new file mode 100644
index 0000000..373a1b8
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyString.php
@@ -0,0 +1,258 @@
+actual, $message);
+ return $this;
+ }
+
+ public function containsStringIgnoringCase($needle, string $message = ''): self
+ {
+ Assert::assertStringContainsStringIgnoringCase($needle, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string does not match a given regular expression.
+ *
+ * @param string $pattern
+ * @param string $message
+ * @return self
+ */
+ public function doesNotMatchRegExp(string $pattern, string $message = ''): self
+ {
+ Assert::assertDoesNotMatchRegularExpression($pattern, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string ends with a given suffix.
+ *
+ * @param string $suffix
+ * @param string $message
+ * @return self
+ */
+ public function endsWith(string $suffix, string $message = ''): self
+ {
+ Assert::assertStringEndsWith($suffix, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of a string is equal to the contents of a file.
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function equalsFile(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertStringEqualsFile($expectedFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of a string is equal to the contents of a file (canonicalizing).
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function equalsFileCanonicalizing(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertStringEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of a string is equal to the contents of a file (ignoring case).
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function equalsFileIgnoringCase(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertStringEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string is a valid JSON string.
+ *
+ * @param string $message
+ * @return self
+ */
+ public function json(string $message = ''): self
+ {
+ Assert::assertJson($this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string matches a given format string.
+ *
+ * @param string $format
+ * @param string $message
+ * @return self
+ */
+ public function matchesFormat(string $format, string $message = ''): self
+ {
+ Assert::assertStringMatchesFormat($format, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string matches a given format file.
+ *
+ * @param string $formatFile
+ * @param string $message
+ * @return self
+ */
+ public function matchesFormatFile(string $formatFile, string $message = ''): self
+ {
+ Assert::assertStringMatchesFormatFile($formatFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string matches a given regular expression.
+ *
+ * @param string $pattern
+ * @param string $message
+ * @return self
+ */
+ public function matchesRegExp(string $pattern, string $message = ''): self
+ {
+ Assert::assertMatchesRegularExpression($pattern, $this->actual, $message);
+ return $this;
+ }
+
+ public function notContainsString(string $needle, string $message = ''): self
+ {
+ Assert::assertStringNotContainsString($needle, $this->actual, $message);
+ return $this;
+ }
+
+ public function notContainsStringIgnoringCase(string $needle, string $message = ''): self
+ {
+ Assert::assertStringNotContainsStringIgnoringCase($needle, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string ends not with a given suffix.
+ *
+ * @param string $suffix
+ * @param string $message
+ * @return self
+ */
+ public function notEndsWith(string $suffix, string $message = ''): self
+ {
+ Assert::assertStringEndsNotWith($suffix, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of a string is not equal to the contents of a file.
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsFile(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertStringNotEqualsFile($expectedFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of a string is not equal to the contents of a file (canonicalizing).
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsFileCanonicalizing(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertStringNotEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that the contents of a string is not equal to the contents of a file (ignoring case).
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsFileIgnoringCase(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertStringNotEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string does not match a given format string.
+ *
+ * @param $format
+ * @param string $message
+ * @return self
+ */
+ public function notMatchesFormat($format, string $message = ''): self
+ {
+ Assert::assertStringNotMatchesFormat($format, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string does not match a given format string.
+ *
+ * @param string $formatFile
+ * @param string $message
+ * @return self
+ */
+ public function notMatchesFormatFile(string $formatFile, string $message = ''): self
+ {
+ Assert::assertStringNotMatchesFormatFile($formatFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string starts not with a given prefix.
+ *
+ * @param string $prefix
+ * @param string $message
+ * @return self
+ */
+ public function startsNotWith(string $prefix, string $message = ''): self
+ {
+ Assert::assertStringStartsNotWith($prefix, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that a string starts with a given prefix.
+ *
+ * @param string $prefix
+ * @param string $message
+ * @return self
+ */
+ public function startsWith(string $prefix, string $message = ''): self
+ {
+ Assert::assertStringStartsWith($prefix, $this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyStringTrait.php b/src/Codeception/Verify/Verifiers/VerifyStringTrait.php
deleted file mode 100644
index c0705ac..0000000
--- a/src/Codeception/Verify/Verifiers/VerifyStringTrait.php
+++ /dev/null
@@ -1,338 +0,0 @@
-actual)) {
- TestCase::assertClassHasStaticAttribute($attributeName, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a class does not have a specified static attribute.
- *
- * @param string $attributeName
- */
- public function notHasStaticAttribute(string $attributeName)
- {
- if (is_string($this->actual)) {
- TestCase::assertClassNotHasStaticAttribute($attributeName, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a string is a valid JSON string.
- */
- public function json()
- {
- if (is_string($this->actual)) {
- TestCase::assertJson($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that two given JSON encoded objects or arrays are not equal.
- *
- * @param string $expectedJson
- */
- public function jsonStringNotEqualsJsonString(string $expectedJson)
- {
- TestCase::assertJsonStringNotEqualsJsonString($expectedJson, $this->actual, $this->message);
- }
-
- /**
- * Verifies that a string does not match a given regular expression.
- *
- * @param string $pattern
- */
- public function notRegExp(string $pattern)
- {
- if (is_string($this->actual)) {
- TestCase::assertNotRegExp($pattern, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that two given JSON encoded objects or arrays are equal.
- *
- * @param $string
- */
- public function equalsJsonString($string)
- {
- if (is_string($this->actual)) {
- TestCase::assertJsonStringEqualsJsonString($string, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a string matches a given regular expression.
- *
- * @param string $pattern
- */
- public function regExp(string $pattern)
- {
- if (is_string($this->actual)) {
- TestCase::assertRegExp($pattern, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
-
- /**
- * @param string $needle
- */
- public function stringContainsString(string $needle)
- {
- if (is_string($this->actual)) {
- TestCase::assertStringContainsString($needle, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- public function stringContainsStringIgnoringCase($needle)
- {
- if (is_string($this->actual)) {
- TestCase::assertStringContainsStringIgnoringCase($needle, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the contents of a string is equal to the contents of a file (canonicalizing).
- *
- * @param string $expectedFile
- */
- public function stringEqualsFileCanonicalizing(string $expectedFile)
- {
- if (is_string($this->actual)) {
- TestCase::assertStringEqualsFileCanonicalizing($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the contents of a string is equal to the contents of a file (ignoring case).
- *
- * @param string $expectedFile
- */
- public function stringEqualsFileIgnoringCase(string $expectedFile)
- {
- if (is_string($this->actual)) {
- TestCase::assertStringEqualsFileIgnoringCase($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a string ends not with a given suffix.
- *
- * @param string $suffix
- */
- public function notEndsWith(string $suffix)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringEndsNotWith($suffix, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a string ends with a given suffix.
- *
- * @param string $suffix
- */
- public function endsWith(string $suffix)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringEndsWith($suffix, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the contents of a string is equal to the contents of a file.
- *
- * @param string $expectedFile
- */
- public function equalsFile(string $expectedFile)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringEqualsFile($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a string matches a given format string.
- *
- * @param string $format
- */
- public function matchesFormat(string $format)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringMatchesFormat($format, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a string matches a given format file.
- *
- * @param string $formatFile
- */
- public function matchesFormatFile(string $formatFile)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringMatchesFormatFile($formatFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * @param string $needle
- */
- public function stringNotContainsString(string $needle)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringNotContainsString($needle, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * @param string $needle
- */
- public function stringNotContainsStringIgnoringCase(string $needle)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringNotContainsStringIgnoringCase($needle, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the contents of a string is not equal to the contents of a file (canonicalizing).
- *
- * @param string $expectedFile
- */
- public function stringNotEqualsFileCanonicalizing(string $expectedFile)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringNotEqualsFileCanonicalizing($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the contents of a string is not equal to the contents of a file (ignoring case).
- *
- * @param string $expectedFile
- */
- public function stringNotEqualsFileIgnoringCase(string $expectedFile)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringNotEqualsFileIgnoringCase($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- public function notMatchesFormat($format)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringNotMatchesFormat($format, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a string does not match a given format string.
- *
- * @param string $formatFile
- */
- public function notMatchesFormatFile(string $formatFile)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringNotMatchesFormatFile($formatFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a string starts not with a given prefix.
- *
- * @param string $prefix
- */
- public function notStartsWith(string $prefix)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringStartsNotWith($prefix, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a string starts with a given prefix.
- *
- * @param string $prefix
- */
- public function startsWith(string $prefix)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringStartsWith($prefix, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that the contents of a string is not equal to the contents of a file.
- *
- * @param string $expectedFile
- */
- public function notEqualsFile(string $expectedFile)
- {
- if(is_string($this->actual)) {
- TestCase::assertStringNotEqualsFile($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyThrowableTrait.php b/src/Codeception/Verify/Verifiers/VerifyThrowableTrait.php
deleted file mode 100644
index 648de62..0000000
--- a/src/Codeception/Verify/Verifiers/VerifyThrowableTrait.php
+++ /dev/null
@@ -1,74 +0,0 @@
-getMessage();
- $throws = get_class($throws);
- }
-
- try {
- call_user_func($this->actual);
- } catch (Throwable $e) {
- if (!$throws) {
- return; // it throws
- }
-
- $actualThrows = get_class($e);
- $actualMessage = $e->getMessage();
-
- TestCase::assertSame($throws, $actualThrows, "exception '$throws' was expected, but '$actualThrows' was thrown");
-
- if ($message) {
- TestCase::assertSame($message, $actualMessage, "exception message '$message' was expected, but '$actualMessage' was received");
- }
- }
-
- if (!isset($e)) {
- throw new ExpectationFailedException("exception '$throws' was not thrown as expected");
- }
- }
-
- public function doesNotThrow($throws = null, $message = false)
- {
- if ($throws instanceof Exception) {
- $message = $throws->getMessage();
- $throws = get_class($throws);
- }
-
- try {
- call_user_func($this->actual);
- } catch (Throwable $e) {
- if (!$throws) {
- throw new ExpectationFailedException("exception was not expected to be thrown");
- }
-
- $actualThrows = get_class($e);
- $actualMessage = $e->getMessage();
-
- if ($throws !== $actualThrows) {
- return;
- }
-
- if (!$message) {
- throw new ExpectationFailedException("exception '$throws' was not expected to be thrown");
- } elseif ($message === $actualMessage) {
- throw new ExpectationFailedException("exception '$throws' with message '$message' was not expected to be thrown");
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyUnionTrait.php b/src/Codeception/Verify/Verifiers/VerifyUnionTrait.php
deleted file mode 100644
index 484d996..0000000
--- a/src/Codeception/Verify/Verifiers/VerifyUnionTrait.php
+++ /dev/null
@@ -1,91 +0,0 @@
-actual)) {
- TestCase::assertObjectHasAttribute($attributeName, $this->actual, $this->message);
- return;
- } elseif (is_string($this->actual)) {
- TestCase::assertClassHasAttribute($attributeName, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a class does not have a specified attribute.
- *
- * @param string $attributeName
- */
- public function notHasAttribute(string $attributeName)
- {
- if (is_string($this->actual)) {
- TestCase::assertClassNotHasAttribute($attributeName, $this->actual, $this->message);
- return;
- } elseif (is_object($this->actual)) {
- TestCase::assertObjectNotHasAttribute($attributeName, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a file/dir exists and is not readable.
- */
- public function isNotReadable()
- {
- if (is_string($this->actual)) {
- TestCase::assertIsNotReadable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a file/dir exists and is not writable.
- */
- public function isNotWritable()
- {
- if (is_string($this->actual)) {
- TestCase::assertIsNotWritable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that a file/dir is readable.
- */
- public function isReadable()
- {
- if (is_string($this->actual)) {
- TestCase::assertIsReadable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Asserts that a file/dir exists and is writable.
- */
- public function isWritable()
- {
- if (is_string($this->actual)) {
- TestCase::assertIsWritable($this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyXmlFile.php b/src/Codeception/Verify/Verifiers/VerifyXmlFile.php
new file mode 100644
index 0000000..2201e73
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyXmlFile.php
@@ -0,0 +1,40 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two XML files are not equal.
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsXmlFile(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertXmlFileNotEqualsXmlFile($expectedFile, $this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyXmlString.php b/src/Codeception/Verify/Verifiers/VerifyXmlString.php
new file mode 100644
index 0000000..a87b72c
--- /dev/null
+++ b/src/Codeception/Verify/Verifiers/VerifyXmlString.php
@@ -0,0 +1,79 @@
+actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two XML documents are equal.
+ *
+ * @param DOMDocument|string $expectedXml
+ * @param string $message
+ * @return self
+ */
+ public function equalsXmlString($expectedXml, string $message = ''): self
+ {
+ Assert::assertXmlStringEqualsXmlString($expectedXml, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two XML documents are not equal.
+ *
+ * @param string $expectedFile
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsXmlFile(string $expectedFile, string $message = ''): self
+ {
+ Assert::assertXmlStringNotEqualsXmlFile($expectedFile, $this->actual, $message);
+ return $this;
+ }
+
+ /**
+ * Verifies that two XML documents are not equal.
+ *
+ * @param DOMDocument|string $expectedXml
+ * @param string $message
+ * @return self
+ */
+ public function notEqualsXmlString($expectedXml, string $message = ''): self
+ {
+ Assert::assertXmlStringNotEqualsXmlString($expectedXml, $this->actual, $message);
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verifiers/VerifyXmlTrait.php b/src/Codeception/Verify/Verifiers/VerifyXmlTrait.php
deleted file mode 100644
index f95c2c9..0000000
--- a/src/Codeception/Verify/Verifiers/VerifyXmlTrait.php
+++ /dev/null
@@ -1,66 +0,0 @@
-actual) || $this->actual instanceof DOMDocument) {
- TestCase::assertXmlStringEqualsXmlString($expectedXml, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that two XML files are not equal.
- *
- * @param string $expectedFile
- */
- public function xmlFileNotEqualsXmlFile(string $expectedFile)
- {
- if (is_file($this->actual)) {
- TestCase::assertXmlFileNotEqualsXmlFile($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that two XML documents are not equal.
- *
- * @param string $expectedFile
- */
- public function xmlStringNotEqualsXmlFile(string $expectedFile)
- {
- if (is_string($this->actual) || $this->actual instanceof DOMDocument) {
- TestCase::assertXmlStringNotEqualsXmlFile($expectedFile, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-
- /**
- * Verifies that two XML documents are not equal.
- *
- * @param DOMDocument|string $expectedXml
- */
- public function xmlStringNotEqualsXmlString($expectedXml)
- {
- if (is_string($this->actual) || $this->actual instanceof DOMDocument) {
- TestCase::assertXmlStringNotEqualsXmlString($expectedXml, $this->actual, $this->message);
- return;
- }
- throw new InvalidVerifyException(__FUNCTION__, $this->actual);
- }
-}
\ No newline at end of file
diff --git a/src/Codeception/Verify/Verify.php b/src/Codeception/Verify/Verify.php
index 726c545..ac1c6f3 100644
--- a/src/Codeception/Verify/Verify.php
+++ b/src/Codeception/Verify/Verify.php
@@ -2,45 +2,110 @@
namespace Codeception\Verify;
-use Codeception\Verify\Verifiers\VerifyArrayTrait;
-use Codeception\Verify\Verifiers\VerifyDirectoryTrait;
-use Codeception\Verify\Verifiers\VerifyFileTrait;
-use Codeception\Verify\Verifiers\VerifyMixedTrait;
-use Codeception\Verify\Verifiers\VerifyStringTrait;
-use Codeception\Verify\Verifiers\VerifyThrowableTrait;
-use Codeception\Verify\Verifiers\VerifyUnionTrait;
-use Codeception\Verify\Verifiers\VerifyXmlTrait;
-
-class Verify
-{
- use
- VerifyArrayTrait,
- VerifyDirectoryTrait,
- VerifyFileTrait,
- VerifyMixedTrait,
- VerifyStringTrait,
- VerifyThrowableTrait,
- VerifyUnionTrait,
- VerifyXmlTrait
- ;
-
- public static $override = false;
+use ArrayAccess;
+use Codeception\Verify\Verifiers\VerifyArray;
+use Codeception\Verify\Verifiers\VerifyCallable;
+use Codeception\Verify\Verifiers\VerifyClass;
+use Codeception\Verify\Verifiers\VerifyDirectory;
+use Codeception\Verify\Verifiers\VerifyFile;
+use Codeception\Verify\Verifiers\VerifyJsonFile;
+use Codeception\Verify\Verifiers\VerifyJsonString;
+use Codeception\Verify\Verifiers\VerifyMixed;
+use Codeception\Verify\Verifiers\VerifyBaseObject;
+use Codeception\Verify\Verifiers\VerifyString;
+use Codeception\Verify\Verifiers\VerifyXmlFile;
+use Codeception\Verify\Verifiers\VerifyXmlString;
+use Countable;
+abstract class Verify
+{
+ /** @var mixed */
protected $actual = null;
- protected $message = '';
- protected $isFileExpectation = false;
- public function __construct($message)
+ /**
+ * Verify constructor
+ *
+ * @param mixed $actual
+ */
+ protected function __construct($actual)
+ {
+ $this->actual = $actual;
+ }
+
+ /**
+ * @param mixed $actual
+ * @return self
+ */
+ public function __invoke($actual): self
+ {
+ return $this($actual);
+ }
+
+ public static function File(string $filename): VerifyFile
+ {
+ return new VerifyFile($filename);
+ }
+
+ public static function JsonFile(string $filename): VerifyJsonFile
+ {
+ return new VerifyJsonFile($filename);
+ }
+
+ public static function JsonString(string $json): VerifyJsonString
+ {
+ return new VerifyJsonString($json);
+ }
+
+ public static function XmlFile(string $filename): VerifyXmlFile
{
- $messageGiven = (func_num_args() == 2);
+ return new VerifyXmlFile($filename);
+ }
- if (!$messageGiven) {
- $this->actual = $message;
- return;
- }
+ public static function XmlString(string $xml): VerifyXmlString
+ {
+ return new VerifyXmlString($xml);
+ }
- $actual = func_get_args();
- $this->actual = $actual[1];
- $this->message = $message;
+ public static function BaseObject(object $object): VerifyBaseObject
+ {
+ return new VerifyBaseObject($object);
+ }
+
+ public static function Class(string $className): VerifyClass
+ {
+ return new VerifyClass($className);
+ }
+
+ public static function Directory(string $directory): VerifyDirectory
+ {
+ return new VerifyDirectory($directory);
+ }
+
+ /**
+ * @param array|ArrayAccess|Countable|iterable $array
+ * @return VerifyArray
+ */
+ public static function Array($array): VerifyArray
+ {
+ return new VerifyArray($array);
+ }
+
+ public static function String(string $string): VerifyString
+ {
+ return new VerifyString($string);
+ }
+
+ public static function Callable(callable $callable): VerifyCallable
+ {
+ return new VerifyCallable($callable);
+ }
+
+ /**
+ * @param mixed $actual
+ * @return VerifyMixed
+ */
+ public static function Mixed($actual): VerifyMixed
+ {
+ return new VerifyMixed($actual);
}
-}
+}
\ No newline at end of file
diff --git a/src/Codeception/bootstrap.php b/src/Codeception/bootstrap.php
new file mode 100644
index 0000000..80626a7
--- /dev/null
+++ b/src/Codeception/bootstrap.php
@@ -0,0 +1,38 @@
+notEmpty();
- }
-
- function verify_not($fallacy) {
- verify($fallacy)->isEmpty();
- }
-}
-
-if (!function_exists('expect')) {
-
- /**
- * @return Verify
- */
- function expect() {
- return call_user_func_array('verify', func_get_args());
- }
-
- function expect_that($truth) {
- expect($truth)->notEmpty();
- }
-
- function expect_not($fallacy) {
- expect($fallacy)->isEmpty();
- }
-
-}
-
-if (!function_exists('verify_file')) {
-
- /**
- * @return Verify
- */
- function verify_file() {
- $verify = call_user_func_array('verify', func_get_args());
- $verify->setIsFileExpectation(true);
- return $verify;
- }
-}
-
-if (!function_exists('expect_file')) {
- /**
- * @return Verify
- */
- function expect_file() {
- return call_user_func_array('verify_file', func_get_args());
- }
-}
diff --git a/tests/InheritanceTest.php b/tests/InheritanceTest.php
new file mode 100644
index 0000000..476b863
--- /dev/null
+++ b/tests/InheritanceTest.php
@@ -0,0 +1,37 @@
+success();
+
+ $myVerify::Mixed('this also')->notEquals('works');
+
+ verify(new MyVerify())->instanceOf(Verify::class);
+ }
+}
+
+
+final class MyVerify extends Verify
+{
+ public function __construct($actual = null)
+ {
+ parent::__construct($actual);
+ }
+
+ public function success(string $message = '')
+ {
+ Assert::assertTrue(true, $message);
+ }
+}
\ No newline at end of file
diff --git a/tests/OverrideTest.php b/tests/OverrideTest.php
deleted file mode 100644
index 32ad823..0000000
--- a/tests/OverrideTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-assertInstanceOf(MyVerify::class, verify(null));
- }
-
-}
-
-class MyVerify extends Verify {
-
-}
\ No newline at end of file
diff --git a/tests/VerifyTest.php b/tests/VerifyTest.php
index 509e9a1..68f4cf7 100644
--- a/tests/VerifyTest.php
+++ b/tests/VerifyTest.php
@@ -1,359 +1,342 @@
-xml = new DomDocument;
+ $this->xml = new DOMDocument;
$this->xml->loadXML('BazBaz');
}
- public function testEquals()
+ public function testEquals(): void
{
verify(5)->equals(5);
- verify("hello")->equals("hello");
- verify("user have 5 posts", 5)->equals(5);
- verify(3.251)->equals(3.25, 0.01);
- verify("respects delta", 3.251)->equals(3.25, 0.01);
- verify_file(__FILE__)->equals(__FILE__);
+ verify('hello')->equals('hello');
+ verify(5)->equals(5, 'user have 5 posts');
+ verify(3.251)->equalsWithDelta(3.25, 0.01);
+ verify(3.251)->equalsWithDelta(3.25, 0.01, 'respects delta');
+ verify(__FILE__)->fileEquals(__FILE__);
}
- public function testNotEquals()
+ public function testNotEquals(): void
{
verify(3)->notEquals(5);
- verify(3.252)->notEquals(3.25, 0.001);
- verify("respects delta", 3.252, 0.001);
- verify_file(__FILE__)->notEquals(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'composer.json');
+ verify(3.252)->notEqualsWithDelta(3.25, 0.001);
+ verify(3.252)->notEqualsWithDelta(3.25, 0.001, 'respects delta');
+ verify(__FILE__)->fileNotEquals(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'composer.json');
}
- public function testContains()
+ public function testContains(): void
{
- verify(array(3, 2))->contains(3);
- verify("user have 5 posts", array(3, 2))->notContains(5);
+ verify([3, 2])->arrayContains(3);
+ verify([3, 2])->arrayNotContains(5, 'user have 5 posts');
}
- public function testGreaterLowerThan()
+ public function testGreaterLowerThan(): void
{
verify(7)->greaterThan(5);
verify(7)->lessThan(10);
- verify(7)->lessOrEquals(7);
- verify(7)->lessOrEquals(8);
- verify(7)->greaterOrEquals(7);
- verify(7)->greaterOrEquals(5);
+ verify(7)->lessThanOrEqual(7);
+ verify(7)->lessThanOrEqual(8);
+ verify(7)->greaterThanOrEqual(7);
+ verify(7)->greaterThanOrEqual(5);
}
- public function testTrueFalseNull()
+ public function testTrueFalseNull(): void
{
verify(true)->true();
verify(false)->false();
verify(null)->null();
verify(true)->notNull();
- verify('something should be false', false)->false();
- verify('something should be true', true)->true();
+ verify(false)->false('something should be false');
+ verify(true)->true('something should be true');
}
- public function testEmptyNotEmpty()
+ public function testEmptyNotEmpty(): void
{
verify(array('3', '5'))->notEmpty();
- verify(array())->isEmpty();
- }
-
- public function testVerifyThat()
- {
- verify_that(12);
- verify_that('hello world');
- verify_that(array('hello'));
- }
-
- public function testVerifyNot()
- {
- verify_not(false);
- verify_not(null);
- verify_not(array());
- }
-
- public function testExpectFunctions()
- {
- expect(12)->equals(12);
- expect_that(true);
- expect_not(false);
+ verify(array())->empty();
}
- public function testArrayHasKey()
+ public function testArrayHasKey(): void
{
- $errors = array('title' => 'You should add title');
- expect($errors)->hasKey('title');
- expect($errors)->hasNotKey('body');
+ $errors = ['title' => 'You should add title'];
+ verify($errors)->arrayHasKey('title');
+ verify($errors)->arrayHasNotKey('body');
}
- public function testIsInstanceOf()
+ public function testIsInstanceOf(): void
{
$testClass = new DateTime();
- expect($testClass)->isInstanceOf('DateTime');
- expect($testClass)->isNotInstanceOf('DateTimeZone');
+ verify($testClass)->instanceOf('DateTime');
+ verify($testClass)->notInstanceOf('DateTimeZone');
}
- public function testHasAttribute()
+ public function testHasAttribute(): void
{
- expect('Exception')->hasAttribute('message');
- expect('Exception')->notHasAttribute('fakeproperty');
+ verify('Exception')->classHasAttribute('message');
+ verify('Exception')->classNotHasAttribute('fakeproperty');
- $testObject = (object) array('existingAttribute' => true);
- expect($testObject)->hasAttribute('existingAttribute');
- expect($testObject)->notHasAttribute('fakeproperty');
+ $testObject = (object) ['existingAttribute' => true];
+ verify($testObject)->baseObjectHasAttribute('existingAttribute');
+ verify($testObject)->baseObjectNotHasAttribute('fakeproperty');
}
- public function testHasStaticAttribute()
+ public function testHasStaticAttribute(): void
{
- expect('FakeClassForTesting')->hasStaticAttribute('staticProperty');
- expect('FakeClassForTesting')->notHasStaticAttribute('fakeProperty');
+ verify('FakeClassForTesting')->classHasStaticAttribute('staticProperty');
+ verify('FakeClassForTesting')->classNotHasStaticAttribute('fakeProperty');
}
- public function testContainsOnly()
+ public function testContainsOnly(): void
{
- expect(array('1', '2', '3'))->containsOnly('string');
- expect(array('1', '2', 3))->notContainsOnly('string');
+ verify(['1', '2', '3'])->arrayContainsOnly('string');
+ verify(['1', '2', 3])->arrayNotContainsOnly('string');
}
- public function testContainsOnlyInstancesOf()
+ public function testContainsOnlyInstancesOf(): void
{
- expect(array(new FakeClassForTesting(), new FakeClassForTesting(), new FakeClassForTesting()))
- ->containsOnlyInstancesOf('FakeClassForTesting');
+ verify([new FakeClassForTesting(), new FakeClassForTesting(), new FakeClassForTesting()])
+ ->arrayContainsOnlyInstancesOf('FakeClassForTesting');
}
- public function testCount()
+ public function testCount(): void
{
- expect(array(1,2,3))->count(3);
- expect(array(1,2,3))->notCount(2);
+ verify([1, 2, 3])->arrayCount(3);
+ verify([1, 2, 3])->arrayNotCount(2);
}
- public function testFileExists()
+ public function testFileExists(): void
{
- expect_file(__FILE__)->exists();
- expect_file('completelyrandomfilename.txt')->notExists();
+ verify(__FILE__)->fileExists();
+ verify('completelyrandomfilename.txt')->fileDoesNotExists();
}
- public function testEqualsJsonFile()
+ public function testEqualsJsonFile(): void
{
- expect_file(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'json-test-file.json')
- ->equalsJsonFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'equal-json-test-file.json');
- expect('{"some" : "data"}')->equalsJsonFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'equal-json-test-file.json');
+ verify(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'json-test-file.json')
+ ->jsonFileEqualsJsonFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'equal-json-test-file.json');
+ verify('{"some" : "data"}')->jsonStringEqualsJsonFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'equal-json-test-file.json');
}
- public function testEqualsJsonString()
+ public function testEqualsJsonString(): void
{
- expect('{"some" : "data"}')->equalsJsonString('{"some" : "data"}');
+ verify('{"some" : "data"}')->jsonStringEqualsJsonString('{"some" : "data"}');
}
- public function testRegExp()
+ public function testRegExp(): void
{
- expect('somestring')->regExp('/string/');
+ verify('somestring')->stringMatchesRegExp('/string/');
}
- public function testMatchesFormat()
+ public function testMatchesFormat(): void
{
- expect('somestring')->matchesFormat('%s');
- expect('somestring')->notMatchesFormat('%i');
+ verify('somestring')->stringMatchesFormat('%s');
+ verify('somestring')->stringNotMatchesFormat('%i');
}
- public function testMatchesFormatFile()
+ public function testMatchesFormatFile(): void
{
- expect('23')->matchesFormatFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
- expect('asdfas')->notMatchesFormatFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
+ verify('23')->stringMatchesFormatFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
+ verify('asdfas')->stringNotMatchesFormatFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
}
- public function testSame()
+ public function testSame(): void
{
- expect(1)->same(0+1);
- expect(1)->notSame(true);
+ verify(1)->same(0+1);
+ verify(1)->notSame(true);
}
- public function testEndsWith()
+ public function testEndsWith(): void
{
- expect('A completely not funny string')->endsWith('ny string');
- expect('A completely not funny string')->notEndsWith('A completely');
+ verify('A completely not funny string')->stringEndsWith('ny string');
+ verify('A completely not funny string')->stringNotEndsWith('A completely');
}
- public function testEqualsFile()
+ public function testEqualsFile(): void
{
- expect('%i')->equalsFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
- expect('Another string')->notEqualsFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
+ verify('%i')->stringEqualsFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
+ verify('Another string')->stringNotEqualsFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'format-file.txt');
}
- public function testStartsWith()
+ public function testStartsWith(): void
{
- expect('A completely not funny string')->startsWith('A completely');
- expect('A completely not funny string')->notStartsWith('string');
+ verify('A completely not funny string')->stringStartsWith('A completely');
+ verify('A completely not funny string')->stringStartsNotWith('string');
}
- public function testEqualsXmlFile()
+ public function testEqualsXmlFile(): void
{
- expect_file(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'xml-test-file.xml')
- ->equalsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'xml-test-file.xml');
- expect('BazBaz')
- ->equalsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'xml-test-file.xml');
+ verify(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'xml-test-file.xml')
+ ->xmlFileEqualsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'xml-test-file.xml');
+ verify('BazBaz')
+ ->xmlStringEqualsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'xml-test-file.xml');
}
- public function testEqualsXmlString()
+ public function testEqualsXmlString(): void
{
- expect('BazBaz')
- ->equalsXmlString('BazBaz');
+ verify('BazBaz')
+ ->xmlStringEqualsXmlString('BazBaz');
}
- public function testStringContainsString()
+ public function testStringContainsString(): void
{
verify('foo bar')->stringContainsString('o b');
verify('foo bar')->stringNotContainsString('BAR');
}
- public function testStringContainsStringIgnoringCase()
+ public function testStringContainsStringIgnoringCase(): void
{
verify('foo bar')->stringContainsStringIgnoringCase('O b');
verify('foo bar')->stringNotContainsStringIgnoringCase('baz');
}
- public function testIsString()
+ public function testIsString(): void
{
- verify('foo bar')->string();
- verify(false)->notString();
+ verify('foo bar')->isString();
+ verify(false)->isNotString();
}
- public function testIsArray()
+ public function testIsArray(): void
{
- verify([1,2,3])->array();
- verify(false)->notArray();
+ verify([1,2,3])->isArray();
+ verify(false)->isNotArray();
}
- public function testIsBool()
+ public function testIsBool(): void
{
- verify(false)->bool();
- verify([1,2,3])->notBool();
+ verify(false)->isBool();
+ verify([1,2,3])->isNotBool();
}
- public function testIsFloat()
+ public function testIsFloat(): void
{
- verify(1.5)->float();
- verify(1)->notFloat();
+ verify(1.5)->isFloat();
+ verify(1)->isNotFloat();
}
- public function testIsInt()
+ public function testIsInt(): void
{
- verify(5)->int();
- verify(1.5)->notInt();
+ verify(5)->isInt();
+ verify(1.5)->isNotInt();
}
- public function testIsNumeric()
+ public function testIsNumeric(): void
{
- verify('1.5')->numeric();
- verify('foo bar')->notNumeric();
+ verify('1.5')->isNumeric();
+ verify('foo bar')->isNotNumeric();
}
- public function testIsObject()
+ public function testIsObject(): void
{
- verify(new stdClass)->object();
- verify(false)->notObject();
+ verify(new stdClass)->isObject();
+ verify(false)->isNotObject();
}
- public function testIsResource()
+ public function testIsResource(): void
{
- verify(fopen(__FILE__, 'r'))->resource();
- verify(false)->notResource();
+ verify(fopen(__FILE__, 'r'))->isResource();
+ verify(false)->isNotResource();
}
- public function testIsScalar()
+ public function testIsScalar(): void
{
- verify('foo bar')->scalar();
- verify([1,2,3])->notScalar();
+ verify('foo bar')->isScalar();
+ verify([1,2,3])->isNotScalar();
}
- public function testIsCallable()
+ public function testIsCallable(): void
{
- verify(function() {})->callable();
- verify(false)->notCallable();
+ verify(function(): void {})->isCallable();
+ verify(false)->isNotCallable();
}
- public function testEqualsCanonicalizing()
+ public function testEqualsCanonicalizing(): void
{
verify([3, 2, 1])->equalsCanonicalizing([1, 2, 3]);
}
- public function testNotEqualsCanonicalizing()
+ public function testNotEqualsCanonicalizing(): void
{
verify([3, 2, 1])->notEqualsCanonicalizing([2, 3, 0, 1]);
}
- public function testEqualsIgnoringCase()
+ public function testEqualsIgnoringCase(): void
{
verify('foo')->equalsIgnoringCase('FOO');
}
- public function testNotEqualsIgnoringCase()
+ public function testNotEqualsIgnoringCase(): void
{
verify('foo')->notEqualsIgnoringCase('BAR');
}
- public function testEqualsWithDelta()
+ public function testEqualsWithDelta(): void
{
verify(1.01)->equalsWithDelta(1.0, 0.1);
}
- public function testNotEqualsWithDelta()
+ public function testNotEqualsWithDelta(): void
{
verify(1.2)->notEqualsWithDelta(1.0, 0.1);
}
- public function testThrows()
+ public function testThrows(): void
{
- $func = function () {
+ $func = function (): void {
throw new Exception('foo');
};
- verify($func)->throws();
- verify($func)->throws(Exception::class);
- verify($func)->throws(Exception::class, 'foo');
- verify($func)->throws(new Exception());
- verify($func)->throws(new Exception('foo'));
+ verify($func)->callableThrows();
+ verify($func)->callableThrows(Exception::class);
+ verify($func)->callableThrows(Exception::class, 'foo');
+ verify($func)->callableThrows(new Exception());
+ verify($func)->callableThrows(new Exception('foo'));
- verify(function () use ($func) {
- verify($func)->throws(RuntimeException::class);
- })->throws(\PHPUnit\Framework\ExpectationFailedException::class);
+ verify(function () use ($func): void {
+ verify($func)->callableThrows(RuntimeException::class);
+ })->callableThrows(ExpectationFailedException::class);
- verify(function () {
- verify(function () {})->throws(Exception::class);
- })->throws(new \PHPUnit\Framework\ExpectationFailedException("exception 'Exception' was not thrown as expected"));
+ verify(function (): void {
+ verify(function (): void {})->callableThrows(Exception::class);
+ })->callableThrows(new ExpectationFailedException("exception 'Exception' was not thrown as expected"));
}
- public function testDoesNotThrow()
+ public function testDoesNotThrow(): void
{
- $func = function () {
+ $func = function (): void {
throw new Exception('foo');
};
- verify(function () {})->doesNotThrow();
- verify($func)->doesNotThrow(RuntimeException::class);
- verify($func)->doesNotThrow(RuntimeException::class, 'bar');
- verify($func)->doesNotThrow(RuntimeException::class, 'foo');
- verify($func)->doesNotThrow(new RuntimeException());
- verify($func)->doesNotThrow(new RuntimeException('bar'));
- verify($func)->doesNotThrow(new RuntimeException('foo'));
- verify($func)->doesNotThrow(Exception::class, 'bar');
- verify($func)->doesNotThrow(new Exception('bar'));
-
- verify(function () use ($func) {
- verify($func)->doesNotThrow();
- })->throws(new \PHPUnit\Framework\ExpectationFailedException("exception was not expected to be thrown"));
-
- verify(function () use ($func) {
- verify($func)->doesNotThrow(Exception::class);
- })->throws(new \PHPUnit\Framework\ExpectationFailedException("exception 'Exception' was not expected to be thrown"));
-
- verify(function () use ($func) {
- verify($func)->doesNotThrow(Exception::class, 'foo');
- })->throws(new \PHPUnit\Framework\ExpectationFailedException("exception 'Exception' with message 'foo' was not expected to be thrown"));
+ verify(function (): void {})->callableDoesNotThrow();
+ verify($func)->callableDoesNotThrow(RuntimeException::class);
+ verify($func)->callableDoesNotThrow(RuntimeException::class, 'bar');
+ verify($func)->callableDoesNotThrow(RuntimeException::class, 'foo');
+ verify($func)->callableDoesNotThrow(new RuntimeException());
+ verify($func)->callableDoesNotThrow(new RuntimeException('bar'));
+ verify($func)->callableDoesNotThrow(new RuntimeException('foo'));
+ verify($func)->callableDoesNotThrow(Exception::class, 'bar');
+ verify($func)->callableDoesNotThrow(new Exception('bar'));
+
+ verify(function () use ($func): void {
+ verify($func)->callableDoesNotThrow();
+ })->callableThrows(new ExpectationFailedException('exception was not expected to be thrown'));
+
+ verify(function () use ($func): void {
+ verify($func)->callableDoesNotThrow(Exception::class);
+ })->callableThrows(new ExpectationFailedException("exception 'Exception' was not expected to be thrown"));
+
+ verify(function () use ($func): void {
+ verify($func)->callableDoesNotThrow(Exception::class, 'foo');
+ })->callableThrows(new ExpectationFailedException("exception 'Exception' with message 'foo' was not expected to be thrown"));
}
}