/**
  * @covers \eZ\Publish\Core\Persistence\InMemory\ObjectStateHandler::setContentState
  */
 public function testSetContentState()
 {
     $returnValue = $this->handler->setContentState(14, 2, 2);
     $this->assertEquals(true, $returnValue);
     $newObjectState = $this->handler->getContentState(14, 2);
     $this->assertInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState', $newObjectState);
     $this->assertEquals(2, $newObjectState->id);
 }
 /**
  * Sets the object-state of a state group to $state for the given content.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the object state does not belong to the given group
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to change the object state
  *
  * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup
  * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectState $objectState
  */
 public function setContentState(ContentInfo $contentInfo, APIObjectStateGroup $objectStateGroup, APIObjectState $objectState)
 {
     if ($this->repository->canUser('state', 'assign', $contentInfo, $objectState) !== true) {
         throw new UnauthorizedException('state', 'assign', array('contentId' => $contentInfo->id));
     }
     $loadedObjectState = $this->loadObjectState($objectState->id);
     if ($loadedObjectState->getObjectStateGroup()->id != $objectStateGroup->id) {
         throw new InvalidArgumentException('objectState', 'Object state does not belong to the given group');
     }
     $this->repository->beginTransaction();
     try {
         $this->objectStateHandler->setContentState($contentInfo->id, $objectStateGroup->id, $loadedObjectState->id);
         $this->repository->commit();
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
 }