Merge pull request #2876 from Aerendir/AnnotateThrowables-improve-tests-organization

`AnnotateThrowablesRector`: Improve organization of tests.
This commit is contained in:
Tomas Votruba 2020-02-18 18:59:06 +01:00 committed by GitHub
commit 36ffd47763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 58 additions and 74 deletions

View File

@ -7,9 +7,9 @@ namespace Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Fixtur
*
* @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.
*
* @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);
}
?>

View File

@ -2,9 +2,9 @@
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;
/**
* @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();
}
?>

View File

@ -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();
}
}

View File

@ -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();
}

View File

@ -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

View File

@ -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
{

View File

@ -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;
use Rector\CodingStyle\Tests\Rector\Throw_\AnnotateThrowablesRector\Source\ExceptionsFactoryStaticMethodWithReturnDocblock;
class ExceptionsFactoryStaticMethodWithReturnDockblock
function throwWithFactoryStaticMethodWithReturnDocblock()
{
/**
* @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);
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
@ -71,9 +26,9 @@ class ExceptionsFactoryStaticMethodWithReturnDockblock
* @throws TheExceptionTheThird
* @throws \RuntimeException
*/
function throwWithFactoryStaticMethodWithReturnDockblock()
function throwWithFactoryStaticMethodWithReturnDocblock()
{
throw ExceptionsFactoryStaticMethodWithReturnDockblock::createExceptionEccolo(1);
throw ExceptionsFactoryStaticMethodWithReturnDocblock::createExceptionEccolo(1);
}
?>

View File

@ -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 {
}

View File

@ -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 {}

View File

@ -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 {}

View File

@ -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();
}
}
}