From b57f550d121b3842d87289f35bf09f8d0305ae08 Mon Sep 17 00:00:00 2001 From: catch Date: Fri, 28 Jun 2019 09:54:33 +0100 Subject: [PATCH] Issue #3031466 by mondrake, Wim Leers: EntityResourceTestBase::assert406Response uses a wrong assertion and results in false positives (and fails for PHPUnit 7) --- .../Functional/EntityResource/EntityResourceTestBase.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index e090e2c0bd25..d4b111cf48f2 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -1538,8 +1538,13 @@ abstract class EntityResourceTestBase extends ResourceTestBase { else { // This is the desired response. $this->assertSame(406, $response->getStatusCode()); - $this->stringContains('?_format=' . static::$format . '>; rel="alternate"; type="' . static::$mimeType . '"', $response->getHeader('Link')); - $this->stringContains('?_format=foobar>; rel="alternate"', $response->getHeader('Link')); + $actual_link_header = $response->getHeader('Link'); + if ($actual_link_header) { + $this->assertTrue(is_array($actual_link_header)); + $expected_type = explode(';', static::$mimeType)[0]; + $this->assertContains('?_format=' . static::$format . '>; rel="alternate"; type="' . $expected_type . '"', $actual_link_header[0]); + $this->assertContains('?_format=foobar>; rel="alternate"', $actual_link_header[0]); + } } }