Skip to content

Commit b57ab38

Browse files
committed
added more examples
1 parent 9806cad commit b57ab38

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* **Removed configuration** section
77
* **Only properties marked with `@specify` annotation are cloned** in specify blocks.
88
* **Removed throws** parameter in specify blocks
9-
* Added `Codeception\Specify\ResultPrinter` to fix printing progress of specify blcoks.
9+
* Added `Codeception\Specify\ResultPrinter` to fix printing progress of specify blocks.
1010

1111
### Upgrade Plan
1212

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,27 @@ class UserTest extends PHPUnit\Framework\TestCase {
9494
}
9595
```
9696

97+
### Specify + Verify Example
98+
99+
Use [Codeception/Verify](https://github.com/Codeception/Verify for simpler assertions:
100+
101+
```php
102+
<?php
103+
$this->specify("username is required", function() {
104+
$this->user->username = null;
105+
expect_not($this->user->validate(['username']));
106+
});
107+
108+
$this->specify("username is too long", function() {
109+
$this->user->username = 'toolooooongnaaaaaaameeee';
110+
expect_not($this->user->validate(['username']));
111+
});
112+
113+
$this->specify("username is ok", function() {
114+
$this->user->username = 'davert';
115+
expect_that($this->user->validate(['username']));
116+
});
117+
```
97118

98119
## Purpose
99120

@@ -215,7 +236,7 @@ public function someData()
215236

216237
## Before/After
217238

218-
There are also before and after callbacks, which act as setUp/tearDown but only for specify.
239+
There are also before and after callbacks, which act as setUp/tearDown but for specify.
219240

220241
```php
221242
<?php
@@ -250,11 +271,18 @@ Install with Composer:
250271
"require-dev": {
251272
"codeception/specify": "*",
252273
"codeception/verify": "*"
253-
254274
}
255275
```
256276
Include `Codeception\Specify` trait into `PHPUnit\Framework\TestCase`.
257277

278+
For PHPUnit add `Codeception\Specify\ResultPrinter` printer into `phpunit.xml`
279+
280+
281+
```xml
282+
<phpunit colors="true" printerClass="Codeception\Specify\ResultPrinter">
283+
</phpunit>
284+
```
285+
258286
## Recommended
259287

260288
* Use [Codeception/AssertThrows](https://github.com/Codeception/AssertThrows) for exception assertions

0 commit comments

Comments
 (0)