/**
  * @dataProvider accessorDataProvider
  *
  * @param mixed  $expected
  * @param array  $node
  * @param string $path
  * @param bool   $success
  */
 public function testGet($expected, $node, $path, $success)
 {
     if ($success) {
         $this->assertEquals($expected, $this->facade->get($node, new JsonPointer($path)), 'Accessor must report true for this combination of document and path');
     } else {
         $this->setExpectedException('\\ChiliLabs\\JsonPointer\\Exception\\InvalidPathException');
         $this->facade->get($node, new JsonPointer($path));
     }
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function __invoke($document, AccessFacade $access)
 {
     if ($access->isReadable($document, $this->path) && $access->get($document, $this->path) !== null) {
         throw new OperationException(sprintf('The path "%s" does already exist.', (string) $this->path));
     }
     $access->create($document, $this->path, $this->value);
     return $document;
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function __invoke($document, AccessFacade $access)
 {
     if (!$access->isReadable($document, $this->from)) {
         throw new OperationException(sprintf('The path "%s" is not readable.', (string) $this->from));
     }
     $value = $access->get($document, $this->from);
     $addOperation = new AddOperation($this->path, $value);
     $document = $addOperation($document, $access);
     return $document;
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function __invoke($document, AccessFacade $access)
 {
     if (!$access->isReadable($document, $this->path)) {
         throw new OperationException(sprintf('The path "%s" does not exist.', (string) $this->path));
     }
     $value = $access->get($document, $this->path);
     if ($value != $this->value) {
         throw new OperationException(sprintf('Test failed: Values do not match (%s != %s).', $value, $this->value));
     }
     return $document;
 }