/**
  * @dataProvider provideInvalidApply
  */
 public function testInvalidApply(Entity $item, ChangeOp $changeOp)
 {
     $this->setExpectedException('Wikibase\\ChangeOp\\ChangeOpException');
     $changeOp->apply($item);
 }
Exemplo n.º 2
0
 /**
  * Applies the given ChangeOp to the given Entity.
  * Any ChangeOpException is converted into a UsageException with the code 'modification-failed'.
  *
  * @since 0.5
  *
  * @param ChangeOp $changeOp
  * @param Entity $entity
  * @param Summary $summary The summary object to update with information about the change.
  *
  * @throws UsageException
  */
 protected function applyChangeOp(ChangeOp $changeOp, Entity $entity, Summary $summary = null)
 {
     try {
         $result = $changeOp->validate($entity);
         if (!$result->isValid()) {
             throw new ChangeOpValidationException($result);
         }
         $changeOp->apply($entity, $summary);
     } catch (ChangeOpException $ex) {
         $this->errorReporter->dieException($ex, 'modification-failed');
     }
 }
 /**
  * @dataProvider changeOpSummaryProvider
  */
 public function testUpdateSummary($entity, ChangeOp $changeOp, $summaryExpectedAction, $summaryExpectedLanguage)
 {
     $summary = new Summary();
     $changeOp->apply($entity, $summary);
     $this->assertEquals($summaryExpectedAction, $summary->getActionName());
     $this->assertEquals($summaryExpectedLanguage, $summary->getLanguageCode());
 }
 /**
  * Applies the given ChangeOp to the given Entity.
  * If validation fails, a ChangeOpValidationException is thrown.
  *
  * @since 0.5
  *
  * @param ChangeOp $changeOp
  * @param EntityDocument $entity
  * @param Summary|null $summary The summary object to update with information about the change.
  *
  * @throws ChangeOpException
  */
 protected function applyChangeOp(ChangeOp $changeOp, EntityDocument $entity, Summary $summary = null)
 {
     $result = $changeOp->validate($entity);
     if (!$result->isValid()) {
         throw new ChangeOpValidationException($result);
     }
     $changeOp->apply($entity, $summary);
 }