This commit is contained in:
Gabriel Caruso 2018-04-30 08:40:52 -03:00 committed by Tomas Votruba
parent 7f1d9072dd
commit bee8c051b5
3 changed files with 20 additions and 14 deletions

View File

@ -54,7 +54,7 @@
"@check-cs",
"phpunit",
"@phpstan",
"update-docs"
"@update-docs"
],
"check-cs": "vendor/bin/ecs check bin packages src tests",
"fix-cs": [

View File

@ -40,16 +40,19 @@ final class DelegateExceptionArgumentsRector extends AbstractPHPUnitRector
public function getDefinition(): RectorDefinition
{
return new RectorDefinition('Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.', [
new CodeSample(
'$this->setExpectedException(Exception::class, "Message", "CODE");',
<<<'CODE_SAMPLE'
return new RectorDefinition(
'Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.',
[
new CodeSample(
'$this->setExpectedException(Exception::class, "Message", "CODE");',
<<<'CODE_SAMPLE'
$this->setExpectedException(Exception::class);
$this->expectExceptionMessage("Message");
$this->expectExceptionCode("CODE");
CODE_SAMPLE
),
]);
),
]
);
}
public function isCandidate(Node $node): bool

View File

@ -45,9 +45,11 @@ final class ExceptionAnnotationRector extends AbstractPHPUnitRector
public function getDefinition(): RectorDefinition
{
return new RectorDefinition('Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.', [
new CodeSample(
<<<'CODE_SAMPLE'
return new RectorDefinition(
'Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.',
[
new CodeSample(
<<<'CODE_SAMPLE'
/**
* @expectedException Exception
* @expectedExceptionMessage Message
@ -57,8 +59,8 @@ public function test()
// tested code
}
CODE_SAMPLE
,
<<<'CODE_SAMPLE'
,
<<<'CODE_SAMPLE'
public function test()
{
$this->expectException('Exception');
@ -66,8 +68,9 @@ public function test()
// tested code
}
CODE_SAMPLE
),
]);
),
]
);
}
public function isCandidate(Node $node): bool