diff --git a/core/modules/system/src/Tests/Session/SessionAuthenticationTest.php b/core/modules/system/src/Tests/Session/SessionAuthenticationTest.php index a2a49e5..dcee4f8 100644 --- a/core/modules/system/src/Tests/Session/SessionAuthenticationTest.php +++ b/core/modules/system/src/Tests/Session/SessionAuthenticationTest.php @@ -125,13 +125,23 @@ public function testBasicAuthNoSession() { // sustaining the session. $this->basicAuthGet($no_cookie_url, $this->user->getUsername(), $this->user->pass_raw); $this->assertResponse(200, 'The user is successfully authenticated using basic authentication.'); - $this->assertNull($this->cookies, 'No cookie is set on a route protected with basic authentication.'); + $this->assertEqual($this->getSetCookieCount(), 0, 'No cookie is set on a route protected with basic authentication.'); // On the other hand, authenticating using Cookie sets a cookie. $edit = ['name' => $this->user->getUsername(), 'pass' => $this->user->pass_raw]; $this->drupalPostForm($cookie_url, $edit, t('Log in')); $this->assertResponse(200, 'The user is successfully authenticated using cookie authentication.'); - $this->assertNotNull($this->cookies, 'A cookie is set on a route protected with cookie authentication.'); + $this->assertEqual($this->getSetCookieCount(), 1, 'A cookie is set on a route protected with cookie authentication.'); + } + + /** + * Returns the number of cookies that were set in the last request. + * + * @return int + * The number of cookies that were set. + */ + protected function getSetCookieCount() { + return count(preg_grep('/^Set-Cookie: ([^=]+)=(.+)/', $this->headers)); } }