| Conditions | 4 |
| Paths | 1 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function register() |
||
| 13 | { |
||
| 14 | TestResponse::macro('assertMatchesHtmlSnapshot', function () { |
||
| 15 | $backtrace = collect(debug_backtrace()); |
||
| 16 | $index = $backtrace->search(function (array $call): bool { |
||
| 17 | return ($call['class'] ?? null) === TestResponse::class |
||
| 18 | && ($call['function'] ?? null) === '__call' |
||
| 19 | && ($call['args'][0] ?? null) === 'assertMatchesHtmlSnapshot'; |
||
| 20 | }); |
||
| 21 | $test = $backtrace->get($index+1); |
||
| 22 | |||
| 23 | if(!isset(class_uses($test['object'])[MatchesSnapshots::class])) { |
||
| 24 | throw new RuntimeException(sprintf('%s does not use %s', $test['class'], MatchesSnapshots::class)); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** @var TestResponse $response */ |
||
| 28 | $response = $this; |
||
| 29 | call_user_func([$test['object'], 'assertMatchesHtmlSnapshot'], $response->getContent()); |
||
| 30 | }); |
||
| 31 | } |
||
| 32 | } |
||
| 33 |