예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function __invoke($document, AccessFacade $access)
 {
     if (!$access->isWritable($document, $this->path)) {
         throw new OperationException(sprintf('The path "%s" does not exist.', (string) $this->path));
     }
     $access->set($document, $this->path, $this->value);
     return $document;
 }
예제 #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;
 }
예제 #5
0
 /**
  * @dataProvider isWritableDataProvider
  *
  * @param mixed  $expected
  * @param array  $document
  * @param string $path
  */
 public function testIsWritable($expected, $document, $path)
 {
     $result = $this->facade->isWritable($document, new JsonPointer($path));
     $this->assertEquals($expected, $result);
 }