[TriggerExtractor] improve test to match message

This commit is contained in:
TomasVotruba 2017-09-06 12:37:15 +02:00
parent 9cb250f9af
commit 242e185a11
3 changed files with 26 additions and 4 deletions

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace Rector\TriggerExtractor\TriggerError;
final class TriggerMessageResolver
{
// ...
}

View File

@ -32,11 +32,11 @@ final class TriggerExtractor
DeprecationDetector $deprecationDetector,
StandaloneTraverseNodeTraverser $standaloneTraverseNodeTraverser
) {
$this->parser = $parser;
$this->standaloneTraverseNodeTraverser = $standaloneTraverseNodeTraverser;
$this->mainNodeTraverser = $mainNodeTraverser;
$this->mainNodeTraverser->addVisitor($deprecationDetector);
$this->standaloneTraverseNodeTraverser = $standaloneTraverseNodeTraverser;
$this->parser = $parser;
}
/**
@ -48,12 +48,16 @@ final class TriggerExtractor
foreach ($files as $file) {
$nodes = $this->parser->parseFile($file->getRealPath());
// this completes parent & child nodes and types
$this->standaloneTraverseNodeTraverser->traverse($nodes);
$this->mainNodeTraverser->traverse($nodes);
}
}
/**
* @todo duplicated method to
* @see \Rector\Console\Command\ReconstructCommand, extract to class
*
* @param string[] $directories
* @return SplFileInfo[] array
*/

View File

@ -27,6 +27,16 @@ final class TriggerExtractorTest extends AbstractContainerAwareTestCase
public function test(): void
{
$this->triggerExtractor->scanDirectories([__DIR__ . '/TriggerExtractorSource']);
$this->assertCount(2, $this->deprecationCollector->getDeprecations());
$deprecations = $this->deprecationCollector->getDeprecations();
$this->assertCount(2, $deprecations);
$setClassToSetFacoryDeprecation = $deprecations[0];
// @todo: complete class in here!
$this->assertSame(
'setClass() second parameter $args is deprecated, use setFactory()',
$setClassToSetFacoryDeprecation
);
}
}