/** * Deletes a object state. The state of the content objects is reset to the * first object state in the group. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to delete an object state * * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectState $objectState */ public function deleteObjectState(APIObjectState $objectState) { if ($this->repository->hasAccess('state', 'administrate') !== true) { throw new UnauthorizedException('state', 'administrate'); } $loadedObjectState = $this->loadObjectState($objectState->id); $this->repository->beginTransaction(); try { $this->objectStateHandler->delete($loadedObjectState->id); $this->repository->commit(); } catch (Exception $e) { $this->repository->rollback(); throw $e; } }
/** * @covers \eZ\Publish\Core\Persistence\InMemory\ObjectStateHandler::delete * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException */ public function testDeleteThrowsNotFoundException() { $this->handler->delete(APIBaseTest::DB_INT_MAX); }