You are here

protected function SchemataBrowserTestBase::getDereferencedSchema in Schemata 8

Retrieve the schema by URL and dereference for use.

Dereferencing a schema processes references to external schema documents and prepares it to be used as a validation authority.

This will static cache the schema so the same schema resource will not be retrieved and processed more than once per test run.

@todo Evaluate PSR-16 cache support built into Dereferencer.

Parameters

string $url: Absolute URL to a JSON Schema resource.

Return value

object Dereferenced schema object.

See also

http://json-reference.thephpleague.com/caching

1 call to SchemataBrowserTestBase::getDereferencedSchema()
ValidateSchemaTest::validateSchemaAsJsonSchema in tests/src/Functional/ValidateSchemaTest.php
Confirm a schema is inherently valid as a JSON Schema.

File

tests/src/Functional/SchemataBrowserTestBase.php, line 124

Class

SchemataBrowserTestBase
Sets up functional testing for Schemata.

Namespace

Drupal\Tests\schemata\Functional

Code

protected function getDereferencedSchema($url) {
  if (empty($this->schemaCache[$url])) {
    $dereferencer = Dereferencer::draft4();

    // By definition of the JSON Schema spec, schemas use this key to refer
    // to the schema to which they conform.
    $this->schemaCache[$url] = $dereferencer
      ->dereference($url);
  }
  return $this->schemaCache[$url];
}