33
44BDD Assertions for [ PHPUnit] [ 1 ] or [ Codeception] [ 2 ]
55
6+ [ ![ Latest Stable Version] ( https://poser.pugx.org/codeception/verify/v/stable )] ( https://packagist.org/packages/codeception/verify )
7+ [ ![ Total Downloads] ( https://poser.pugx.org/codeception/verify/downloads )] ( https://packagist.org/packages/codeception/verify )
8+ [ ![ Build Status] ( https://travis-ci.org/Codeception/Verify.png?branch=master )] ( https://travis-ci.org/Codeception/Verify )
9+ [ ![ License] ( https://poser.pugx.org/codeception/specify/license )] ( https://packagist.org/packages/codeception/verify )
10+
611This is very tiny wrapper for PHPUnit assertions, that are aimed to make tests a bit more readable.
712With [ BDD] [ 3 ] assertions influenced by [ Chai] [ 4 ] , [ Jasmine] [ 5 ] , and [ RSpec] [ 6 ] your assertions would be a bit closer to natural language.
813
9- [ ![ Build Status] ( https://travis-ci.org/Codeception/Verify.png?branch=master )] ( https://travis-ci.org/Codeception/Verify )
10- [ ![ Latest Stable Version] ( https://poser.pugx.org/codeception/verify/v/stable )] ( https://packagist.org/packages/codeception/verify )
11- [ ![ Total Downloads] ( https://poser.pugx.org/codeception/verify/downloads )] ( https://packagist.org/packages/codeception/verify )
14+ ## Installation
15+
16+ * Requires PHP 7.1 or higher*
17+
18+ ```
19+ composer require codeception/verify --dev
20+ ```
21+
22+ ## Usage
23+
24+ Use in any test ` verify ` function instead of ` $this->assert* ` methods:
1225
1326``` php
1427$user = User::find(1);
@@ -29,8 +42,6 @@ verify('first user rate is 7', $rate)->equals(7);
2942verify($rate)->greaterThan(5);
3043verify($rate)->lessThan(10);
3144verify($rate)->lessOrEquals(7);
32- verify($rate)->lessOrEquals(8);
33- verify($rate)->greaterOrEquals(7);
3445verify($rate)->greaterOrEquals(5);
3546
3647// true / false / null
@@ -52,52 +63,21 @@ verify($callback)->throws(new Exception('message'));
5263
5364// does not throw
5465verify($callback)->doesNotThrow();
55- verify($callback)->doesNotThrow(Exception::class);
56- verify($callback)->doesNotThrow(Exception::class, 'exception message');
66+ verify($callback)->throws(Exception::class);
5767verify($callback)->doesNotThrow(new Exception());
58- verify($callback)->doesNotThrow(new Exception('exception message'));
59-
60- //Other methods:
61- * stringContainsString
62- * stringNotContainsString
63- * stringContainsStringIgnoringCase
64- * stringNotContainsStringIgnoringCase
65- * array
66- * bool
67- * float
68- * int
69- * numeric
70- * object
71- * resource
72- * string
73- * scalar
74- * callable
75- * notArray
76- * notBool
77- * notFloat
78- * notInt
79- * notNumeric
80- * notObject
81- * notResource
82- * notString
83- * notScalar
84- * notCallable
85- * equalsCanonicalizing
86- * notEqualsCanonicalizing
87- * equalsIgnoringCase
88- * notEqualsIgnoringCase
89- * equalsWithDelta
90- * notEqualsWithDelta
68+
69+ // and many more !
9170```
9271
72+ > ##### :page_facing_up : See Verifiers full list [ here.] [ 7 ]
73+
9374Shorthands for testing truth/fallacy:
9475
9576``` php
9677verify_that($user->isActivated());
9778verify_not($user->isBanned());
9879```
9980
100-
10181These two functions don't check for strict true/false matching, rather ` empty ` function is used.
10282` verify_that ` checks that result is not empty value, ` verify_not ` does the opposite.
10383
@@ -111,34 +91,6 @@ expect_that($user->isActive());
11191expect_not($user->isBanned());
11292```
11393
114- ## Installation
115-
116- ### Installing via Composer
117-
118- Install composer in a common location or in your project:
119-
120- ``` sh
121- curl -s http://getcomposer.org/installer | php
122- ```
123-
124- Create the ` composer.json ` file as follows:
125-
126- ``` json
127- "require-dev" : {
128- "codeception/verify" : " ^1.0"
129- }
130- ```
131-
132- Run the composer installer:
133-
134- ``` sh
135- php composer.phar install
136- ```
137-
138- ## Usage
139-
140- Use in any test ` verify ` function instead of ` $this->assert* ` methods.
141-
14294## Extending
14395
14496In order to add more assertions you can override ` Codeception\Verify ` class:
@@ -165,12 +117,14 @@ verify('it works')->success();
165117
166118## License
167119
168- Verify is open-sourced software licensed under the [ MIT] [ 7 ] License. © Codeception PHP Testing Framework
120+ Verify is open-sourced software licensed under the [ MIT] [ 8 ] License.
121+ © Codeception PHP Testing Framework
169122
170123[ 1 ] : https://phpunit.de/
171124[ 2 ] : http://codeception.com/
172125[ 3 ] : https://en.wikipedia.org/wiki/Behavior-driven_development
173126[ 4 ] : http://chaijs.com/
174127[ 5 ] : http://jasmine.github.io/
175128[ 6 ] : http://rspec.info/
176- [ 7 ] : https://github.com/Codeception/Verify/blob/master/LICENSE
129+ [ 7 ] : /docs/supported_verifiers.md
130+ [ 8 ] : /LICENSE
0 commit comments