mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 14:27:14 +01:00
AnnotateThrowablesRector
: Improve organization of tests.
This commit is contained in:
parent
85aa4dd4bc
commit
15f97ae2f3
@ -9,7 +9,7 @@ namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixtur
|
||||
*/
|
||||
function throwCustomExceptionInFunctionWithDockblock(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.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException('', $code);
|
||||
throw new \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException('', $code);
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -4,7 +4,7 @@ namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixtur
|
||||
|
||||
function throwCustomExceptionInFunctionWithoutDockblock()
|
||||
{
|
||||
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;
|
||||
|
||||
/**
|
||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException
|
||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException
|
||||
*/
|
||||
function throwCustomExceptionInFunctionWithoutDockblock()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException
|
||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException
|
||||
* @throws \Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException
|
||||
*/
|
||||
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;
|
||||
|
||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheException;
|
||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\Exceptions\TheException;
|
||||
|
||||
/**
|
||||
* @throws TheException
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -2,35 +2,11 @@
|
||||
|
||||
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\TheExceptionTheSecond;
|
||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheExceptionTheThird;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\ExceptionsFactoryStaticMethodWithReturnDocblock;
|
||||
|
||||
function throwWithFactoryStaticMethodWithReturnDockblock()
|
||||
{
|
||||
throw ExceptionsFactoryStaticMethodWithReturnDockblock::createExceptionEccolo(1);
|
||||
throw ExceptionsFactoryStaticMethodWithReturnDocblock::createExceptionEccolo(1);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -39,31 +15,10 @@ function throwWithFactoryStaticMethodWithReturnDockblock()
|
||||
|
||||
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\TheExceptionTheSecond;
|
||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\TheExceptionTheThird;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\ExceptionsFactoryStaticMethodWithReturnDocblock;
|
||||
|
||||
/**
|
||||
* @throws TheException
|
||||
@ -73,7 +28,7 @@ class ExceptionsFactoryStaticMethodWithReturnDockblock
|
||||
*/
|
||||
function throwWithFactoryStaticMethodWithReturnDockblock()
|
||||
{
|
||||
throw ExceptionsFactoryStaticMethodWithReturnDockblock::createExceptionEccolo(1);
|
||||
throw ExceptionsFactoryStaticMethodWithReturnDocblock::createExceptionEccolo(1);
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
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 {
|
||||
}
|
@ -2,6 +2,6 @@
|
||||
|
||||
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 {}
|
@ -2,6 +2,6 @@
|
||||
|
||||
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 {}
|
@ -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…
x
Reference in New Issue
Block a user