RectorDefinitionTest: cover guard method

This commit is contained in:
Tomas Votruba 2018-04-08 17:41:06 +02:00
parent 8a185e93ec
commit 4171ca8317

View File

@ -3,8 +3,11 @@
namespace Rector\Tests\RectorDefinition;
use PHPUnit\Framework\TestCase;
use Rector\Exception\RectorDefinition\CodeSamplesMissingException;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
use stdClass;
use TypeError;
final class RectorDefinitionTest extends TestCase
{
@ -23,4 +26,16 @@ final class RectorDefinitionTest extends TestCase
$this->assertSame('Code before', $codeSample->getCodeBefore());
$this->assertSame('Code after', $codeSample->getCodeAfter());
}
public function testInvalidCodeSamplesType(): void
{
$this->expectException(TypeError::class);
new RectorDefinition('Some description', [new stdClass()]);
}
public function testInvalidCodeSamplesCount(): void
{
$this->expectException(CodeSamplesMissingException::class);
new RectorDefinition('Some description', []);
}
}