Skip to content

Commit

Permalink
Merge pull request #150 from MarioBlazek/feature_use_namespaced_testcase
Browse files Browse the repository at this point in the history
Tests now use namespaced TestCase
  • Loading branch information
alcaeus authored Nov 18, 2017
2 parents c387381 + e7171d0 commit bb12259
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 21 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"require-dev": {
"doctrine/cache": "1.*",
"phpunit/phpunit": "^5.7"
"phpunit/phpunit": "^6.4"
},
"autoload": {
"psr-4": { "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Common\Annotations\AnnotationException;
use PHPUnit\Framework\TestCase;
use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader;

require_once __DIR__ . '/TopLevelAnnotation.php';

abstract class AbstractReaderTest extends \PHPUnit_Framework_TestCase
abstract class AbstractReaderTest extends TestCase
{
public function getReflectionClass()
{
Expand Down Expand Up @@ -440,7 +441,8 @@ public function testIgnoreFixMeAndUpperCaseToDo()
{
$reader = $this->getReader();
$ref = new \ReflectionClass(DCOM106::class);
$reader->getClassAnnotations($ref);

self::assertEmpty($reader->getClassAnnotations($ref));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
namespace Doctrine\Tests\Common\Annotations\Annotation;

use Doctrine\Common\Annotations\Annotation\Target;
use PHPUnit\Framework\TestCase;

/**
* Tests for {@see \Doctrine\Common\Annotations\Annotation\Target}
*
* @covers \Doctrine\Common\Annotations\Annotation\Target
*/
class TargetTest extends \PHPUnit_Framework_TestCase
class TargetTest extends TestCase
{
/**
* @group DDC-3006
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Doctrine\Tests\Common\Annotations;

use Doctrine\Common\Annotations\AnnotationRegistry;
use PHPUnit\Framework\TestCase;

class AnnotationRegistryTest extends \PHPUnit_Framework_TestCase
class AnnotationRegistryTest extends TestCase
{
protected $class = AnnotationRegistry::class;

Expand Down Expand Up @@ -167,4 +168,4 @@ public function testResetClearsRegisteredAutoloaderFailures() : void

self::assertSame(2, $failures);
}
}
}
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Doctrine\Tests\Common\Annotations;

use Doctrine\Common\Annotations\DocLexer;
use PHPUnit\Framework\TestCase;

class DocLexerTest extends \PHPUnit_Framework_TestCase
class DocLexerTest extends TestCase
{
public function testMarkerAnnotation()
{
Expand Down
13 changes: 7 additions & 6 deletions tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants;
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants;
use Doctrine\Tests\Common\Annotations\Fixtures\InterfaceWithConstants;
use PHPUnit\Framework\TestCase;

class DocParserTest extends \PHPUnit_Framework_TestCase
class DocParserTest extends TestCase
{
public function testNestedArraysWithNestedAnnotation()
{
Expand Down Expand Up @@ -1055,8 +1056,8 @@ public function testNotAnAnnotationClassIsIgnoredWithoutWarning()
{
$parser = new DocParser();
$parser->setIgnoreNotImportedAnnotations(true);
$parser->setIgnoredAnnotationNames(array(\PHPUnit_Framework_TestCase::class => true));
$result = $parser->parse('@PHPUnit_Framework_TestCase');
$parser->setIgnoredAnnotationNames(array(\PHPUnit\Framework\TestCase::class => true));
$result = $parser->parse('@\PHPUnit\Framework\TestCase');

self::assertEmpty($result);
}
Expand All @@ -1065,7 +1066,7 @@ public function testNotAnAnnotationClassIsIgnoredWithoutWarningWithoutCheating()
{
$parser = new DocParser();
$parser->setIgnoreNotImportedAnnotations(true);
$result = $parser->parse('@PHPUnit_Framework_TestCase');
$result = $parser->parse('@\PHPUnit\Framework\TestCase');

self::assertEmpty($result);
}
Expand Down Expand Up @@ -1163,7 +1164,7 @@ class A {

try {
$parser = $this->createTestParser();
$parser->parse($docblock);
self::assertEmpty($parser->parse($docblock));
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
Expand All @@ -1184,7 +1185,7 @@ class A {

try {
$parser = $this->createTestParser();
$parser->parse($docblock);
self::assertEmpty($parser->parse($docblock));
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
use Doctrine\Common\Annotations\DocParser;
use Doctrine\Common\Annotations\PhpParser;
use Doctrine\Common\Annotations\AnnotationReader;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/Fixtures/Annotation/Route.php';
require_once __DIR__ . '/Fixtures/Annotation/Template.php';
require_once __DIR__ . '/Fixtures/Annotation/Secure.php';
require_once __DIR__ . '/Fixtures/SingleClassLOC1000.php';

class PerformanceTest extends \PHPUnit_Framework_TestCase
class PerformanceTest extends TestCase
{
/**
* @group performance
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace Doctrine\Tests\Common\Annotations;

use PHPUnit\Framework\TestCase;
use ReflectionClass;
use Doctrine\Common\Annotations\PhpParser;

require_once __DIR__.'/Fixtures/NonNamespacedClass.php';
require_once __DIR__.'/Fixtures/GlobalNamespacesPerFileWithClassAsFirst.php';
require_once __DIR__.'/Fixtures/GlobalNamespacesPerFileWithClassAsLast.php';

class PhpParserTest extends \PHPUnit_Framework_TestCase
class PhpParserTest extends TestCase
{
public function testParseClassWithMultipleClassesInFile()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class SimpleAnnotationReaderTest extends AbstractReaderTest
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testImportDetectsNotImportedAnnotation()
{
Expand All @@ -18,6 +20,8 @@ public function testImportDetectsNotImportedAnnotation()
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testImportDetectsNonExistentAnnotation()
{
Expand All @@ -27,6 +31,8 @@ public function testImportDetectsNonExistentAnnotation()
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testClassWithInvalidAnnotationTargetAtClassDocBlock()
{
Expand All @@ -36,6 +42,8 @@ public function testClassWithInvalidAnnotationTargetAtClassDocBlock()
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock()
{
Expand All @@ -45,6 +53,8 @@ public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock()
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock()
{
Expand All @@ -54,6 +64,8 @@ public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock()
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testClassWithInvalidAnnotationTargetAtMethodDocBlock()
{
Expand All @@ -63,6 +75,8 @@ public function testClassWithInvalidAnnotationTargetAtMethodDocBlock()
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*
* @doesNotPerformAssertions
*/
public function testErrorWhenInvalidAnnotationIsUsed()
{
Expand Down Expand Up @@ -112,4 +126,4 @@ protected function getReader()

return $reader;
}
}
}
5 changes: 3 additions & 2 deletions tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use Doctrine\Tests\Common\Annotations\Fixtures\Controller;
use Doctrine\Common\Annotations\AnnotationReader;
use PHPUnit\Framework\TestCase;

/**
* @group
*/
class DCOM55Test extends \PHPUnit_Framework_TestCase
class DCOM55Test extends TestCase
{
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
Expand Down Expand Up @@ -63,4 +64,4 @@ class DCOM55Annotation
class DCOM55Consumer
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\DocParser;
use Doctrine\Common\Annotations\SimpleAnnotationReader;
use PHPUnit\Framework\TestCase;

//Some class named Entity in the global namespace
include __DIR__ .'/DCOM58Entity.php';

/**
* @group DCOM58
*/
class DCOM58Test extends \PHPUnit_Framework_TestCase
class DCOM58Test extends TestCase
{
public function testIssue()
{
Expand Down
6 changes: 4 additions & 2 deletions tests/Doctrine/Tests/DoctrineTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Doctrine\Tests;

use PHPUnit\Framework\TestCase;

/**
* Base testcase class for all Doctrine testcases.
*/
abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase
abstract class DoctrineTestCase extends TestCase
{
}
}

0 comments on commit bb12259

Please sign in to comment.