| Total Complexity | 4 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class ContainsAtLeastOneTest extends TestCase |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @test |
||
| 12 | */ |
||
| 13 | public function assertContainsAtLeastOne() |
||
| 14 | { |
||
| 15 | $allowed = ['anything', 'something']; |
||
| 16 | |||
| 17 | $constraint = new ContainsAtLeastOneConstraint($allowed); |
||
| 18 | |||
| 19 | $json = [ |
||
| 20 | 'anything' => 'ok', |
||
| 21 | 'another' => 'ok' |
||
| 22 | ]; |
||
| 23 | $this->assertTrue($constraint->evaluate($json, '', true)); |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @test |
||
| 28 | * @dataProvider assertContainsAtLeastOneFailedProvider |
||
| 29 | */ |
||
| 30 | public function assertContainsAtLeastOneFailed($json) |
||
| 31 | { |
||
| 32 | $allowed = ['anything', 'something']; |
||
| 33 | |||
| 34 | $constraint = new ContainsAtLeastOneConstraint($allowed); |
||
| 35 | |||
| 36 | $this->assertFalse($constraint->evaluate($json, '', true)); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function assertContainsAtLeastOneFailedProvider() |
||
| 40 | { |
||
| 41 | return [ |
||
| 42 | 'not an array' => [ |
||
| 43 | 'failed' |
||
| 44 | ], |
||
| 45 | 'no one expected member' => [ |
||
| 46 | [ |
||
| 47 | 'unexpected' => 'bad' |
||
| 48 | ] |
||
| 49 | ] |
||
| 50 | ]; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @test |
||
| 55 | */ |
||
| 56 | public function assertContainsAtLeastOneFailedAndThrowException() |
||
| 71 | } |
||
| 72 | } |
||
| 73 |