Ejemplo n.º 1
0
 /**
  * Tests the flattening API
  *
  * @group flattening
  */
 public function testFlatten()
 {
     $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR;
     $expected = json_decode(file_get_contents($path . 'sample-flattened.jsonld'));
     $input = $path . 'sample-in.jsonld';
     $context = $path . 'sample-context.jsonld';
     $this->assertJsonEquals($expected, JsonLD::flatten($input, $context), 'Passing the file path');
     $input = file_get_contents($input);
     $context = file_get_contents($context);
     $this->assertJsonEquals($expected, JsonLD::flatten($input, $context), 'Passing the raw input (string)');
     $input = json_decode($input);
     $context = json_decode($context);
     $this->assertJsonEquals($expected, JsonLD::flatten($input, $context), 'Passing the parsed object');
 }
Ejemplo n.º 2
0
 /**
  * Tests errors (uses flattening).
  *
  * @param string $name    The test name.
  * @param object $test    The test definition.
  * @param object $options The options to configure the algorithms.
  *
  * @group errors
  * @dataProvider errorProvider
  */
 public function testError($name, $test, $options)
 {
     $this->setExpectedException('ML\\JsonLD\\Exception\\JsonLdException', '', $test->{'expect'});
     JsonLD::flatten($this->basedir . $test->{'input'}, isset($test->{'context'}) ? $this->basedir . $test->{'context'} : null, $options);
 }