X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Frest%2Ftests%2Fsrc%2FFunctional%2FResourceTestBase.php;fp=web%2Fcore%2Fmodules%2Frest%2Ftests%2Fsrc%2FFunctional%2FResourceTestBase.php;h=d7ca1e34f3d5826f0a9fa6288e2212053597d4cc;hp=8283bef260010b79991644347312b690023e3af7;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/rest/tests/src/Functional/ResourceTestBase.php b/web/core/modules/rest/tests/src/Functional/ResourceTestBase.php index 8283bef26..d7ca1e34f 100644 --- a/web/core/modules/rest/tests/src/Functional/ResourceTestBase.php +++ b/web/core/modules/rest/tests/src/Functional/ResourceTestBase.php @@ -144,12 +144,12 @@ abstract class ResourceTestBase extends BrowserTestBase { * @param string[] $authentication * The allowed authentication providers for this resource. */ - protected function provisionResource($formats = [], $authentication = []) { + protected function provisionResource($formats = [], $authentication = [], array $methods = ['GET', 'POST', 'PATCH', 'DELETE']) { $this->resourceConfigStorage->create([ 'id' => static::$resourceConfigId, 'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY, 'configuration' => [ - 'methods' => ['GET', 'POST', 'PATCH', 'DELETE'], + 'methods' => $methods, 'formats' => $formats, 'authentication' => $authentication, ], @@ -348,7 +348,7 @@ abstract class ResourceTestBase extends BrowserTestBase { $request_options[RequestOptions::HTTP_ERRORS] = FALSE; $request_options[RequestOptions::ALLOW_REDIRECTS] = FALSE; $request_options = $this->decorateWithXdebugCookie($request_options); - $client = $this->getSession()->getDriver()->getClient()->getClient(); + $client = $this->getHttpClient(); return $client->request($method, $url->setAbsolute(TRUE)->toString(), $request_options); } @@ -481,4 +481,25 @@ abstract class ResourceTestBase extends BrowserTestBase { return $request_options; } + /** + * Recursively sorts an array by key. + * + * @param array $array + * An array to sort. + * + * @return array + * The sorted array. + */ + protected static function recursiveKSort(array &$array) { + // First, sort the main array. + ksort($array); + + // Then check for child arrays. + foreach ($array as $key => &$value) { + if (is_array($value)) { + static::recursiveKSort($value); + } + } + } + }