1
|
|
|
<?php namespace GeneaLabs\LaravelCaffeine\Tests\Feature; |
2
|
|
|
|
3
|
|
|
use GeneaLabs\LaravelCaffeine\Tests\TestCase; |
4
|
|
|
|
5
|
|
|
class CaffeineTest extends TestCase |
6
|
|
|
{ |
7
|
|
|
public function testBootstrap3TestPageCanLoad() |
8
|
|
|
{ |
9
|
|
|
$dripRoute = config('genealabs-laravel-caffeine.route', 'genealabs/laravel-caffeine/drip'); |
10
|
|
|
$response = $this->get($dripRoute); |
11
|
|
|
|
12
|
|
|
$response->assertStatus(204); |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
public function testMiddlewareInjectsDripScript() |
16
|
|
|
{ |
17
|
|
|
$expectedResult = file_get_contents(__DIR__ . '/../Fixtures/expired_script.txt'); |
18
|
|
|
|
19
|
|
|
$response = $this->get(route('genealabs-laravel-caffeine.tests.form')); |
20
|
|
|
|
21
|
|
|
$response->assertSee($expectedResult); |
|
|
|
|
22
|
|
|
} |
23
|
|
|
|
24
|
|
View Code Duplication |
public function testSuccessfulDrip() |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
$dripRoute = config('genealabs-laravel-caffeine.route', 'genealabs/laravel-caffeine/drip'); |
27
|
|
|
$html = $this->get(route('genealabs-laravel-caffeine.tests.form')) |
28
|
|
|
->getContent(); |
29
|
|
|
$matches = []; |
30
|
|
|
preg_match('/<meta name="csrf-token" content="(.*?)">/', $html, $matches); |
31
|
|
|
$csrfToken = $matches[1]; |
32
|
|
|
|
33
|
|
|
$response = $this->get($dripRoute, [ |
34
|
|
|
'_token' => $csrfToken, |
35
|
|
|
]); |
36
|
|
|
|
37
|
|
|
$response->assertStatus(204); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
View Code Duplication |
public function testExpiredDrip() |
|
|
|
|
41
|
|
|
{ |
42
|
|
|
$dripRoute = config('genealabs-laravel-caffeine.dripInterval', 'genealabs/laravel-caffeine/drip'); |
43
|
|
|
$html = $this->get(route('genealabs-laravel-caffeine.tests.form')) |
44
|
|
|
->getContent(); |
45
|
|
|
$matches = []; |
46
|
|
|
preg_match('/<meta name="csrf-token" content="(.*?)">/', $html, $matches); |
47
|
|
|
$csrfToken = $matches[1]; |
48
|
|
|
|
49
|
|
|
app('session')->flush(); |
50
|
|
|
$response = $this->get($dripRoute, [ |
51
|
|
|
'_token' => $csrfToken, |
52
|
|
|
]); |
53
|
|
|
|
54
|
|
|
$response->assertStatus(404); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|