Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EuCookieConsent.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private static function getCookie(string $cookieName)
*/
public static function getPopup($forced = false)
{
if(!$forced && !empty($_COOKIE[config('eu-cookie-consent.cookie_name')])){
if(!$forced && !empty(request()->cookie(config('eu-cookie-consent.cookie_name')))){
return '';
}

Expand Down
14 changes: 13 additions & 1 deletion tests/EuCookieConsentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,23 @@ public function getPopup_returns_html_if_cookie_is_not_set()
}

/** @test */
public function getPopup_returns_empty_string_if_cookie_is_not_set()
public function getHTML_returns_empty_string_if_cookie_is_not_set()
{
$html = EuCookieConsent::getHTML('header');
$this->assertEmpty($html);
}

/**
* @test
*/
public function getPopup_returns_empty_string_if_cookie_is_set()
{
$response = $this->call('POST', '/saveTheCookie', ['session'=>'1', 'xsrf-token'=>'1'], ['laravel_eu_cookie_consent'=>json_encode(['session'=>'1', 'xsrf-token'=>'1'])]);
$response->assertCookie('laravel_eu_cookie_consent', '{"session":"1","xsrf-token":"1"}', false);

$response = EuCookieConsent::getPopup();
$this->assertEquals('', $response);
}


}