mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 11:44:14 +01:00
Merge pull request #91 from RectorPHP/tests-coverage-3
improve coverage
This commit is contained in:
commit
edc53b861e
@ -16,7 +16,7 @@ final class ConstFetchResolver implements PerNodeValueResolverInterface
|
||||
/**
|
||||
* @param ConstFetch $constFetchNode
|
||||
*/
|
||||
public function resolve(Node $constFetchNode): ?bool
|
||||
public function resolve(Node $constFetchNode): bool
|
||||
{
|
||||
$name = $constFetchNode->name->toString();
|
||||
if ($name === 'true') {
|
||||
@ -26,9 +26,5 @@ final class ConstFetchResolver implements PerNodeValueResolverInterface
|
||||
if ($name === 'false') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($name === 'null') {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,10 @@ final class NodeValueResolverTest extends AbstractContainerAwareTestCase
|
||||
$arrayNode = new Array_([
|
||||
new ArrayItem(new String_('hi')),
|
||||
new ArrayItem(BuilderHelpers::normalizeValue(true)),
|
||||
new ArrayItem(BuilderHelpers::normalizeValue(false)),
|
||||
]);
|
||||
|
||||
$resolved = $this->nodeValueResolver->resolve($arrayNode);
|
||||
$this->assertSame(['hi', true], $resolved);
|
||||
$this->assertSame(['hi', true, false], $resolved);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Rector\Tests\Rector;
|
||||
|
||||
use Rector\Exception\Rector\RectorNotFoundException;
|
||||
use Rector\Rector\RectorCollector;
|
||||
use Rector\Tests\AbstractContainerAwareTestCase;
|
||||
use Rector\Tests\Rector\RectorCollectorSource\DummyRector;
|
||||
@ -17,6 +18,9 @@ final class RectorCollectorTest extends AbstractContainerAwareTestCase
|
||||
{
|
||||
$this->rectorCollector = $this->container->get(RectorCollector::class);
|
||||
$this->rectorCollector->addRector(new DummyRector);
|
||||
|
||||
$dummyRector = $this->rectorCollector->getRector(DummyRector::class);
|
||||
$this->assertInstanceOf(DummyRector::class, $dummyRector);
|
||||
}
|
||||
|
||||
public function testCounts(): void
|
||||
@ -32,4 +36,16 @@ final class RectorCollectorTest extends AbstractContainerAwareTestCase
|
||||
$this->assertArrayHasKey(DummyRector::class, $rectors);
|
||||
$this->assertInstanceOf(DummyRector::class, $rectors[DummyRector::class]);
|
||||
}
|
||||
|
||||
public function testGetNonExistinsRector(): void
|
||||
{
|
||||
$this->expectException(RectorNotFoundException::class);
|
||||
$this->expectExceptionMessage(sprintf(
|
||||
'Rectors class "%s" was not found. Available rectors are: "%s".',
|
||||
'MissingRector',
|
||||
DummyRector::class
|
||||
));
|
||||
|
||||
$this->rectorCollector->getRector('MissingRector');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user