@@ -8,9 +8,10 @@ BDD style code blocks for PHPUnit / Codeception
88Specify allows you to write your tests in more readable BDD style, the same way you might have experienced with [ Jasmine] ( https://jasmine.github.io/ ) .
99Inspired by MiniTest of Ruby now you combine BDD and classical TDD style in one test.
1010
11- ### BDD Example
11+ ### Basic Example
1212
13- Specify supports ` describe-it ` BDD syntax inside PHPUnit
13+ Traditionally Specify used ` $this->specify ` function for all descriptions.
14+ That works too!
1415
1516``` php
1617<?php
@@ -28,35 +29,29 @@ class UserTest extends PHPUnit\Framework\TestCase {
2829
2930 public function testValidation()
3031 {
31- $this->describe("user", function() {
32- $this->it("should have a name", function() {
33- $this->user->username = null;
34- $this->assertFalse($this->user->validate(['username']));
35- });
36-
37- $this->it("should not have long name", function() {
38- $this->user->username = 'toolooooongnaaaaaaameeee';
39- $this->assertFalse($this->user->validate(['username']));
40- });
41-
42- // use `$this->>should` as shortcut
43- $this->should("be ok with valid name", function() {
44- $this->user->username = 'davert';
45- $this->assertTrue($this->user->validate(['username']));
46- });
47-
48- // empty codeblocks are marked as Incomplete tests
49- $this->it("should be ok with valid name");
50- });
32+ $this->assertInstanceOf('Model', $this->user);
33+
34+ $this->specify("username is required", function() {
35+ $this->user->username = null;
36+ $this->assertFalse($this->user->validate(['username']));
37+ });
5138
39+ $this->specify("username is too long", function() {
40+ $this->user->username = 'toolooooongnaaaaaaameeee',
41+ $this->assertFalse($this->user->validate(['username']));
42+ });
43+
44+ $this->specify("username is ok", function() {
45+ $this->user->username = 'davert',
46+ $this->assertTrue($this->user->validate(['username']));
47+ });
5248 }
5349}
5450```
5551
56- ### Basic Example
52+ ### BDD Example
5753
58- Traditionally Specify used ` $this->specify ` function for all descriptions.
59- That works too!
54+ Specify supports ` describe-it ` BDD syntax inside PHPUnit
6055
6156``` php
6257<?php
@@ -74,29 +69,35 @@ class UserTest extends PHPUnit\Framework\TestCase {
7469
7570 public function testValidation()
7671 {
77- $this->assertInstanceOf('Model', $this->user);
78-
79- $this->specify("username is required", function() {
80- $this->user->username = null;
81- $this->assertFalse($this->user->validate(['username']));
82- });
83-
84- $this->specify("username is too long", function() {
85- $this->user->username = 'toolooooongnaaaaaaameeee',
86- $this->assertFalse($this->user->validate(['username']));
87- });
72+ $this->describe("user", function() {
73+ $this->it("should have a name", function() {
74+ $this->user->username = null;
75+ $this->assertFalse($this->user->validate(['username']));
76+ });
77+
78+ $this->it("should not have long name", function() {
79+ $this->user->username = 'toolooooongnaaaaaaameeee';
80+ $this->assertFalse($this->user->validate(['username']));
81+ });
82+
83+ // use `$this->>should` as shortcut
84+ $this->should("be ok with valid name", function() {
85+ $this->user->username = 'davert';
86+ $this->assertTrue($this->user->validate(['username']));
87+ });
88+
89+ // empty codeblocks are marked as Incomplete tests
90+ $this->it("should be ok with valid name");
91+ });
8892
89- $this->specify("username is ok", function() {
90- $this->user->username = 'davert',
91- $this->assertTrue($this->user->validate(['username']));
92- });
9393 }
9494}
9595```
9696
97+
9798### Specify + Verify Example
9899
99- Use [ Codeception/Verify] (https://github.com/Codeception/Verify for simpler assertions:
100+ Use [ Codeception/Verify] ( https://github.com/Codeception/Verify ) for simpler assertions:
100101
101102``` php
102103<?php
0 commit comments