| Total Complexity | 6 |
| Total Lines | 84 |
| Duplicated Lines | 36.9 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php namespace GeneaLabs\LaravelCaffeine\Tests\Feature; |
||
| 5 | class CaffeineTest extends TestCase |
||
| 6 | { |
||
| 7 | public function testDripEndpoint() |
||
| 8 | { |
||
| 9 | $dripRoute = config('genealabs-laravel-caffeine.route', 'genealabs/laravel-caffeine/drip'); |
||
| 10 | |||
| 11 | $response = $this->get($dripRoute); |
||
| 12 | |||
| 13 | $response->assertStatus(204); |
||
| 14 | } |
||
| 15 | |||
| 16 | public function testMiddlewareInjectsDripScript() |
||
| 17 | { |
||
| 18 | $expectedResult = file_get_contents(__DIR__ . '/../Fixtures/expired_script.txt'); |
||
| 19 | |||
| 20 | $response = $this->get(route('genealabs-laravel-caffeine.tests.form')); |
||
| 21 | |||
| 22 | $response->assertSee($expectedResult); |
||
|
1 ignored issue
–
show
|
|||
| 23 | } |
||
| 24 | |||
| 25 | View Code Duplication | public function testSuccessfulDrip() |
|
|
1 ignored issue
–
show
|
|||
| 26 | { |
||
| 27 | $dripRoute = config('genealabs-laravel-caffeine.route', 'genealabs/laravel-caffeine/drip'); |
||
| 28 | $html = $this->get(route('genealabs-laravel-caffeine.tests.form')) |
||
| 29 | ->getContent(); |
||
| 30 | $matches = []; |
||
| 31 | preg_match('/<meta name="csrf-token" content="(.*?)">/', $html, $matches); |
||
| 32 | $csrfToken = $matches[1]; |
||
| 33 | |||
| 34 | $response = $this->get($dripRoute, [ |
||
| 35 | '_token' => $csrfToken, |
||
| 36 | ]); |
||
| 37 | |||
| 38 | $response->assertStatus(204); |
||
| 39 | } |
||
| 40 | |||
| 41 | View Code Duplication | public function testExpiredDrip() |
|
|
1 ignored issue
–
show
|
|||
| 42 | { |
||
| 43 | $dripRoute = config( |
||
| 44 | 'genealabs-laravel-caffeine.dripInterval', |
||
| 45 | 'genealabs/laravel-caffeine/drip' |
||
| 46 | ); |
||
| 47 | $html = $this->get(route('genealabs-laravel-caffeine.tests.form')) |
||
| 48 | ->getContent(); |
||
| 49 | $matches = []; |
||
| 50 | preg_match( |
||
| 51 | '/<meta name="csrf-token" content="(.*?)">/', |
||
| 52 | $html, |
||
| 53 | $matches |
||
| 54 | ); |
||
| 55 | $csrfToken = $matches[1]; |
||
| 56 | |||
| 57 | app('session')->flush(); |
||
| 58 | $response = $this->get($dripRoute, [ |
||
| 59 | '_token' => $csrfToken, |
||
| 60 | ]); |
||
| 61 | |||
| 62 | $response->assertStatus(404); |
||
| 63 | } |
||
| 64 | |||
| 65 | public function testDisabledCaffeination() |
||
| 82 | } |
||
| 83 | |||
| 84 | public function testNonStringReturnContent() |
||
| 85 | { |
||
| 86 | $response = $this->get(route('genealabs-laravel-caffeine.tests.null-response')); |
||
| 91 |