Skip to content

Commit

Permalink
Add drip functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebronner committed Dec 10, 2017
1 parent 3411ce4 commit 5440693
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/Feature/CaffeineTest.php
Expand Up @@ -20,4 +20,37 @@ public function testMiddlewareInjectsDripScript()

$response->assertSee($expectedResult);
}

public function testSuccessfulDrip()
{
$dripRoute = config('genealabs-laravel-caffeine.route', 'genealabs/laravel-caffeine/drip');
$html = $this->get(route('genealabs-laravel-caffeine.tests.form'))
->getContent();
$matches = [];
preg_match('/<meta name="csrf-token" content="(.*?)">/', $html, $matches);
$csrfToken = $matches[1];

$response = $this->get($dripRoute, [
'_token' => $csrfToken,
]);

$response->assertStatus(204);
}

public function testExpiredDrip()
{
$dripRoute = config('genealabs-laravel-caffeine.dripInterval', 'genealabs/laravel-caffeine/drip');
$html = $this->get(route('genealabs-laravel-caffeine.tests.form'))
->getContent();
$matches = [];
preg_match('/<meta name="csrf-token" content="(.*?)">/', $html, $matches);
$csrfToken = $matches[1];

app('session')->flush();
$response = $this->get($dripRoute, [
'_token' => $csrfToken,
]);

$response->assertStatus(404);
}
}

0 comments on commit 5440693

Please sign in to comment.