mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-27 05:03:31 +00:00
Merge pull request #2876 from Aerendir/AnnotateThrowables-improve-tests-organization
`AnnotateThrowablesRector`: Improve organization of tests.
This commit is contained in:
commit
36ffd47763
|
@ -7,9 +7,9 @@ namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixtur
|
||||||
*
|
*
|
||||||
* @param int $code
|
* @param int $code
|
||||||
*/
|
*/
|
||||||
function throwCustomExceptionInFunctionWithDockblock(int $code)
|
function throwCustomExceptionInFunctionWithDocblock(int $code)
|
||||||
{
|
{
|
||||||
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException('', $code);
|
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException('', $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -22,11 +22,11 @@ namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixtur
|
||||||
* This is a comment.
|
* This is a comment.
|
||||||
*
|
*
|
||||||
* @param int $code
|
* @param int $code
|
||||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException
|
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException
|
||||||
*/
|
*/
|
||||||
function throwCustomExceptionInFunctionWithDockblock(int $code)
|
function throwCustomExceptionInFunctionWithDocblock(int $code)
|
||||||
{
|
{
|
||||||
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException('', $code);
|
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException('', $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
||||||
|
|
||||||
function throwCustomExceptionInFunctionWithoutDockblock()
|
function throwCustomExceptionInFunctionWithoutDocblock()
|
||||||
{
|
{
|
||||||
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException();
|
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -14,11 +14,11 @@ function throwCustomExceptionInFunctionWithoutDockblock()
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException
|
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException
|
||||||
*/
|
*/
|
||||||
function throwCustomExceptionInFunctionWithoutDockblock()
|
function throwCustomExceptionInFunctionWithoutDocblock()
|
||||||
{
|
{
|
||||||
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException();
|
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -6,7 +6,7 @@ class CustomExceptionInMethodWithoutDocblock
|
||||||
{
|
{
|
||||||
public function throwException()
|
public function throwException()
|
||||||
{
|
{
|
||||||
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException();
|
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixtur
|
||||||
class CustomExceptionInMethodWithoutDocblock
|
class CustomExceptionInMethodWithoutDocblock
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException
|
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException
|
||||||
*/
|
*/
|
||||||
public function throwException()
|
public function throwException()
|
||||||
{
|
{
|
||||||
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException();
|
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException
|
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException
|
||||||
*/
|
*/
|
||||||
function throwCustomExceptionAlreadyAnnotatedInFunction()
|
function throwCustomExceptionAlreadyAnnotatedInFunction()
|
||||||
{
|
{
|
||||||
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException();
|
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
||||||
|
|
||||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException;
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws TheException
|
* @throws TheException
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
||||||
|
|
||||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException;
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException;
|
||||||
|
|
||||||
class SkipCustomImportedExceptionAlreadyAnnotatedInMethod
|
class SkipCustomImportedExceptionAlreadyAnnotatedInMethod
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,35 +2,11 @@
|
||||||
|
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
||||||
|
|
||||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException;
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\ExceptionsFactoryStaticMethodWithReturnDocblock;
|
||||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheExceptionTheSecond;
|
|
||||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheExceptionTheThird;
|
|
||||||
|
|
||||||
class ExceptionsFactoryStaticMethodWithReturnDockblock
|
function throwWithFactoryStaticMethodWithReturnDocblock()
|
||||||
{
|
{
|
||||||
/**
|
throw ExceptionsFactoryStaticMethodWithReturnDocblock::createExceptionEccolo(1);
|
||||||
* @param int $code
|
|
||||||
*
|
|
||||||
* @return TheException|TheExceptionTheSecond|TheExceptionTheThird|\RuntimeException
|
|
||||||
*/
|
|
||||||
public static function createExceptionEccolo(int $code)
|
|
||||||
{
|
|
||||||
switch ($code) {
|
|
||||||
case 1:
|
|
||||||
return new TheException();
|
|
||||||
case 2:
|
|
||||||
return new TheExceptionTheSecond();
|
|
||||||
case 3:
|
|
||||||
return new TheExceptionTheThird();
|
|
||||||
default:
|
|
||||||
return new \RuntimeException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function throwWithFactoryStaticMethodWithReturnDockblock()
|
|
||||||
{
|
|
||||||
throw ExceptionsFactoryStaticMethodWithReturnDockblock::createExceptionEccolo(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -39,31 +15,10 @@ function throwWithFactoryStaticMethodWithReturnDockblock()
|
||||||
|
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixture;
|
||||||
|
|
||||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException;
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException;
|
||||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheExceptionTheSecond;
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheExceptionTheSecond;
|
||||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheExceptionTheThird;
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheExceptionTheThird;
|
||||||
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\ExceptionsFactoryStaticMethodWithReturnDocblock;
|
||||||
class ExceptionsFactoryStaticMethodWithReturnDockblock
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param int $code
|
|
||||||
*
|
|
||||||
* @return TheException|TheExceptionTheSecond|TheExceptionTheThird|\RuntimeException
|
|
||||||
*/
|
|
||||||
public static function createExceptionEccolo(int $code)
|
|
||||||
{
|
|
||||||
switch ($code) {
|
|
||||||
case 1:
|
|
||||||
return new TheException();
|
|
||||||
case 2:
|
|
||||||
return new TheExceptionTheSecond();
|
|
||||||
case 3:
|
|
||||||
return new TheExceptionTheThird();
|
|
||||||
default:
|
|
||||||
return new \RuntimeException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws TheException
|
* @throws TheException
|
||||||
|
@ -71,9 +26,9 @@ class ExceptionsFactoryStaticMethodWithReturnDockblock
|
||||||
* @throws TheExceptionTheThird
|
* @throws TheExceptionTheThird
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
function throwWithFactoryStaticMethodWithReturnDockblock()
|
function throwWithFactoryStaticMethodWithReturnDocblock()
|
||||||
{
|
{
|
||||||
throw ExceptionsFactoryStaticMethodWithReturnDockblock::createExceptionEccolo(1);
|
throw ExceptionsFactoryStaticMethodWithReturnDocblock::createExceptionEccolo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions;
|
||||||
|
|
||||||
class TheException extends \RuntimeException {
|
class TheException extends \RuntimeException {
|
||||||
}
|
}
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions;
|
||||||
|
|
||||||
class TheExceptionTheSecond extends \RuntimeException {}
|
class TheExceptionTheSecond extends \RuntimeException {}
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source;
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions;
|
||||||
|
|
||||||
class TheExceptionTheThird extends \RuntimeException {}
|
class TheExceptionTheThird extends \RuntimeException {}
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source;
|
||||||
|
|
||||||
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException;
|
||||||
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheExceptionTheSecond;
|
||||||
|
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheExceptionTheThird;
|
||||||
|
|
||||||
|
class ExceptionsFactoryStaticMethodWithReturnDocblock
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param int $code
|
||||||
|
*
|
||||||
|
* @return TheException|TheExceptionTheSecond|TheExceptionTheThird|\RuntimeException
|
||||||
|
*/
|
||||||
|
public static function createExceptionEccolo(int $code)
|
||||||
|
{
|
||||||
|
switch ($code) {
|
||||||
|
case 1:
|
||||||
|
return new TheException();
|
||||||
|
case 2:
|
||||||
|
return new TheExceptionTheSecond();
|
||||||
|
case 3:
|
||||||
|
return new TheExceptionTheThird();
|
||||||
|
default:
|
||||||
|
return new \RuntimeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user