コード例 #1
0
 /**
  * @dataProvider provideMutateParserOutput
  */
 public function testMutateParserOutput($references, $expectedItems)
 {
     list($workflow, $revision, $title) = $this->getBlandTestObjects();
     /*
      * Because the data provider is static, we can't access $this->workflow
      * in there. Once of the things being tested is a subpage link.
      * Thus, we would have to provide the correct namespace & title for
      * $this->workflow->getArticleTitle(), under which the subpage will be
      * created.
      * Let's work around this by overwriting $workflow->title to a "known"
      * value, so that we can hardcode that into the expected return value in
      * the static provider.
      */
     $title = static::getTestTitle();
     $reflectionWorkflow = new \ReflectionObject($workflow);
     $reflectionProperty = $reflectionWorkflow->getProperty('title');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($workflow, $title);
     $references = $this->expandReferences($workflow, $revision, $references);
     $parserOutput = new \ParserOutput();
     // Clear the LinksUpdate to allow clean testing
     foreach (array_keys($expectedItems) as $fieldName) {
         $parserOutput->{$fieldName} = array();
     }
     $this->updater->mutateParserOutput($title, $parserOutput, $references);
     foreach ($expectedItems as $method => $content) {
         $this->assertEquals($content, $parserOutput->{$method}(), $method);
     }
 }
コード例 #2
0
 public function onAfterInsert($revision, array $new, array $metadata)
 {
     if (!isset($metadata['workflow'])) {
         return;
     }
     if (!$revision instanceof AbstractRevision) {
         throw new InvalidDataException('ReferenceRecorder can only attach to AbstractRevision storage');
     }
     $workflow = $metadata['workflow'];
     if ($revision instanceof PostRevision && $revision->isTopicTitle()) {
         list($added, $removed) = $this->calculateChangesFromTopic($workflow, $revision);
     } else {
         list($added, $removed) = $this->calculateChangesFromExisting($workflow, $revision);
     }
     $this->storage->multiPut($added);
     $this->storage->multiRemove($removed);
     // Data updates
     $this->linksTableUpdater->doUpdate($workflow);
 }