3 use Drupal\Core\TypedData\TypedDataManagerInterface;
7 use PHPUnit\Framework\TestCase;
9 use Drupal\Core\DependencyInjection\Container;
22 "$id": "https://example.com/person.schema.json",
23 "$schema": "http://json-schema.org/draft-07/schema#",
29 "description": "First name."
33 "description": "Last name."
39 "description": "Age in years which must be equal to or greater than zero.",
61 $options = (
new Options())
62 ->add(
'dkan_schema.schema_retriever', SchemaRetriever::class)
63 ->add(
'typed_data_manager', TypedDataManagerInterface::class)
66 $container = (
new Chain($this))
67 ->add(Container::class,
"get", $options)
68 ->add(SchemaRetriever::class,
'retrieve', $schema)
71 \Drupal::setContainer($container);
73 $thing = (object) [
'firstName' =>
'hello',
'lastName' =>
'goodbye',
'age' => 5000,
'occupations' => [
'teacher']];
74 $json = json_encode($thing);
76 $this->assertEquals($json, json_encode($dataset->getValue()));
78 $properties = $dataset->getProperties();
79 $this->assertEquals(6, count($properties));