diff --git a/tests/Feature/CaffeineTest.php b/tests/Feature/CaffeineTest.php index 27d27b1..404addc 100644 --- a/tests/Feature/CaffeineTest.php +++ b/tests/Feature/CaffeineTest.php @@ -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('//', $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('//', $html, $matches); + $csrfToken = $matches[1]; + + app('session')->flush(); + $response = $this->get($dripRoute, [ + '_token' => $csrfToken, + ]); + + $response->assertStatus(404); + } }