/** * {@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->delete($document, $this->path); return $document; }
/** * @dataProvider deleteDataProvider * * @param mixed $expected * @param array $document * @param string $path * @param bool $success */ public function testDelete($expected, $document, $path, $success) { if ($success) { $this->facade->delete($document, new JsonPointer($path)); $this->assertEquals($expected, $document); } else { $this->setExpectedException('\\ChiliLabs\\JsonPointer\\Exception\\InvalidPathException'); $this->facade->delete($document, new JsonPointer($path)); } }