1 | <?php |
||
9 | class LazyAssertionTest extends \PHPUnit_Framework_TestCase |
||
10 | { |
||
11 | /** |
||
12 | * @test |
||
13 | */ |
||
14 | public function it_collects_errors_until_assertall() |
||
|
|||
15 | { |
||
16 | $this->setExpectedException('Assert\LazyAssertionException', <<<EXC |
||
17 | The following 3 assertions failed: |
||
18 | 1) foo: Value "10" expected to be string, type integer given. |
||
19 | 2) bar: Value "<NULL>" is empty, but non empty value was expected. |
||
20 | 3) baz: Value "string" is not an array. |
||
21 | |||
22 | EXC |
||
23 | ); |
||
24 | |||
25 | Assert::lazy() |
||
26 | ->that(10, 'foo')->string() |
||
27 | ->that(null, 'bar')->notEmpty() |
||
28 | ->that('string', 'baz')->isArray() |
||
29 | ->verifyNow(); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @test |
||
34 | */ |
||
35 | public function it_skips_assertions_of_current_chain_after_failure() |
||
36 | { |
||
37 | $this->setExpectedException('Assert\LazyAssertionException', <<<EXC |
||
38 | The following 1 assertions failed: |
||
39 | 1) foo: Value "<NULL>" is empty, but non empty value was expected. |
||
40 | |||
41 | EXC |
||
42 | ); |
||
43 | |||
44 | Assert::lazy() |
||
45 | ->that(null, 'foo')->notEmpty()->string() |
||
46 | ->verifyNow(); |
||
47 | } |
||
48 | |||
49 | public function testLazyAssertionExceptionCanReturnAllErrors() |
||
67 | |||
68 | public function testVerifyNowReturnsTrueIfAssertionsPass() |
||
69 | { |
||
76 | |||
77 | public function testRestOfChainNotSkippedWhenTryAllUsed() |
||
92 | |||
93 | public function testCallsToThatFollowingTryAllSkipAssertionsAfterFailure() |
||
107 | |||
108 | public function testCallsToThatWithTryAllWithMultipleAssertionsAllGetReported() |
||
124 | |||
125 | public function testCallsToTryAllOnLazyAlwaysReportAllGetReported() |
||
141 | |||
142 | public function testThatLazyAssertionThrowsCustomExceptionWhenSet() |
||
153 | |||
154 | /** |
||
155 | * @dataProvider provideDataToTestThatSetExceptionClassWillNotAcceptInvalidExceptionClasses |
||
156 | * @param mixed $exceptionClass |
||
157 | */ |
||
158 | public function testThatSetExceptionClassWillNotAcceptInvalidExceptionClasses($exceptionClass) |
||
165 | |||
166 | /** |
||
167 | * @return array |
||
168 | */ |
||
169 | public function provideDataToTestThatSetExceptionClassWillNotAcceptInvalidExceptionClasses() |
||
180 | } |
||
181 |