Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup: move to correct phpunit assertions #111

Merged
merged 32 commits into from
Dec 30, 2016
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
586af72
Replacing `assertEquals()` + `count()` with `assertCount()`
Ocramius Dec 30, 2016
a7619f0
Replacing `assertEquals()` + `sizeof()` with `assertCount()`
Ocramius Dec 30, 2016
38f40df
Using `::class` where applicable
Ocramius Dec 30, 2016
19a8aa0
Declaring access modifiers
Ocramius Dec 30, 2016
4355e99
Using single quotes where applicable, since we don't rely on interpol…
Ocramius Dec 30, 2016
6e56e66
Importing used classes
Ocramius Dec 30, 2016
029a9de
Removing unnecessary parentheses
Ocramius Dec 30, 2016
60a4073
Using `::class` where applicable
Ocramius Dec 30, 2016
d227309
Using explicit type casts rather than cast functions
Ocramius Dec 30, 2016
ae1b38d
Using `assertArrayNotHasKey` rather than manual `isset()` checking
Ocramius Dec 30, 2016
cc34239
Using `assertInstanceOf` rather than manual `instanceof` checking
Ocramius Dec 30, 2016
18ec721
Removing unsafe `uniqid()` usage
Ocramius Dec 30, 2016
eda8125
Removing non-absolute path include
Ocramius Dec 30, 2016
0d291dd
Typo fix in class name s/contructor/constructor
Ocramius Dec 30, 2016
452c37d
Typo fix s/inteface/interface
Ocramius Dec 30, 2016
33bbb86
Documenting possible mock types
Ocramius Dec 30, 2016
7321a5b
Correcting documented parameter type
Ocramius Dec 30, 2016
b13ba62
Removing double quotes (loads of weird escape sequences otherwise)
Ocramius Dec 30, 2016
f982d4f
Corrected iterations count comparison
Ocramius Dec 30, 2016
2f98446
Corrected namespacing of some docblock variable declarations
Ocramius Dec 30, 2016
247b875
Adding hinting about retrieved annotation type
Ocramius Dec 30, 2016
c79e397
Removed possible undefined variable failure
Ocramius Dec 30, 2016
41ec043
Better error matching via `assertStringMatchesFormat()`
Ocramius Dec 30, 2016
c1a3e60
Removed unused imports
Ocramius Dec 30, 2016
0d192a2
Removed unused variables
Ocramius Dec 30, 2016
1df6eba
Documenting possible mock types
Ocramius Dec 30, 2016
bd26dd1
Replacing useless FQCN
Ocramius Dec 30, 2016
19ea978
Replacing manual `is_array` checks with `assertInternalType('array', …
Ocramius Dec 30, 2016
2f32c47
s/$this->assert/self::assert
Ocramius Dec 30, 2016
2c0e84e
EOF EOL
Ocramius Dec 30, 2016
0393c9c
EOF EOL
Ocramius Dec 30, 2016
38bff01
CS (spacing)
Ocramius Dec 30, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 83 additions & 83 deletions tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ class TargetTest extends \PHPUnit_Framework_TestCase
*/
public function testValidMixedTargets()
{
$target = new Target(array("value" => array("ALL")));
$target = new Target(array('value' => array('ALL')));
$this->assertEquals(Target::TARGET_ALL, $target->targets);

$target = new Target(array("value" => array("METHOD", "METHOD")));
$target = new Target(array('value' => array('METHOD', 'METHOD')));
$this->assertEquals(Target::TARGET_METHOD, $target->targets);
$this->assertNotEquals(Target::TARGET_PROPERTY, $target->targets);

$target = new Target(array("value" => array("PROPERTY", "METHOD")));
$target = new Target(array('value' => array('PROPERTY', 'METHOD')));
$this->assertEquals(Target::TARGET_METHOD | Target::TARGET_PROPERTY, $target->targets);
}
}
Expand Down
18 changes: 9 additions & 9 deletions tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,34 @@ protected function getReader(DocParser $parser = null)
public function testMethodAnnotationFromTrait()
{
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassUsesTrait');
$ref = new \ReflectionClass(Fixtures\ClassUsesTrait::class);

$annotations = $reader->getMethodAnnotations($ref->getMethod('someMethod'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Autoload', $annotations[0]);
$this->assertInstanceOf(Bar\Autoload::class, $annotations[0]);

$annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]);
$this->assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]);
}

public function testMethodAnnotationFromOverwrittenTrait()
{
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassOverwritesTrait');
$ref = new \ReflectionClass(Fixtures\ClassOverwritesTrait::class);

$annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar2\Autoload', $annotations[0]);
$this->assertInstanceOf(Bar2\Autoload::class, $annotations[0]);
}

public function testPropertyAnnotationFromTrait()
{
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassUsesTrait');
$ref = new \ReflectionClass(Fixtures\ClassUsesTrait::class);

$annotations = $reader->getPropertyAnnotations($ref->getProperty('aProperty'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Autoload', $annotations[0]);
$this->assertInstanceOf(Bar\Autoload::class, $annotations[0]);

$annotations = $reader->getPropertyAnnotations($ref->getProperty('traitProperty'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]);
$this->assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]);
}

public function testOmitNotRegisteredAnnotation()
Expand All @@ -58,7 +58,7 @@ public function testOmitNotRegisteredAnnotation()
$parser->setIgnoreNotImportedAnnotations(true);

$reader = $this->getReader($parser);
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithNotRegisteredAnnotationUsed');
$ref = new \ReflectionClass(Fixtures\ClassWithNotRegisteredAnnotationUsed::class);

$annotations = $reader->getMethodAnnotations($ref->getMethod('methodWithNotRegisteredAnnotation'));
$this->assertEquals(array(), $annotations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class AnnotationRegistryTest extends \PHPUnit_Framework_TestCase
{
protected $class = 'Doctrine\Common\Annotations\AnnotationRegistry';
protected $class = AnnotationRegistry::class;

/**
* @runInSeparateProcess
Expand Down
13 changes: 7 additions & 6 deletions tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\Cache;

class CachedReaderTest extends AbstractReaderTest
{
Expand All @@ -16,7 +17,7 @@ public function testIgnoresStaleCache()
$cache = time() - 10;
touch(__DIR__.'/Fixtures/Controller.php', $cache + 10);

$this->doTestCacheStale('Doctrine\Tests\Common\Annotations\Fixtures\Controller', $cache);
$this->doTestCacheStale(Fixtures\Controller::class, $cache);
}

/**
Expand All @@ -28,7 +29,7 @@ public function testIgnoresStaleCacheWithParentClass()
touch(__DIR__.'/Fixtures/ControllerWithParentClass.php', $cache - 10);
touch(__DIR__.'/Fixtures/AbstractController.php', $cache + 10);

$this->doTestCacheStale('Doctrine\Tests\Common\Annotations\Fixtures\ControllerWithParentClass', $cache);
$this->doTestCacheStale(Fixtures\ControllerWithParentClass::class, $cache);
}

/**
Expand All @@ -40,7 +41,7 @@ public function testIgnoresStaleCacheWithTraits()
touch(__DIR__.'/Fixtures/ControllerWithTrait.php', $cache - 10);
touch(__DIR__.'/Fixtures/Traits/SecretRouteTrait.php', $cache + 10);

$this->doTestCacheStale('Doctrine\Tests\Common\Annotations\Fixtures\ControllerWithTrait', $cache);
$this->doTestCacheStale(Fixtures\ControllerWithTrait::class, $cache);
}

/**
Expand All @@ -54,7 +55,7 @@ public function testIgnoresStaleCacheWithTraitsThatUseOtherTraits()
touch(__DIR__ . '/Fixtures/Traits/EmptyTrait.php', $cache + 10);

$this->doTestCacheStale(
'Doctrine\Tests\Common\Annotations\Fixtures\ClassThatUsesTraitThatUsesAnotherTrait',
Fixtures\ClassThatUsesTraitThatUsesAnotherTrait::class,
$cache
);
}
Expand All @@ -70,7 +71,7 @@ public function testIgnoresStaleCacheWithInterfacesThatExtendOtherInterfaces()
touch(__DIR__ . '/Fixtures/EmptyInterface.php', $cache + 10);

$this->doTestCacheStale(
'Doctrine\Tests\Common\Annotations\Fixtures\InterfaceThatExtendsAnInterface',
Fixtures\InterfaceThatExtendsAnInterface::class,
$cache
);
}
Expand All @@ -79,7 +80,7 @@ protected function doTestCacheStale($className, $lastCacheModification)
{
$cacheKey = $className;

$cache = $this->createMock('Doctrine\Common\Cache\Cache');
$cache = $this->createMock(Cache::class);
$cache
->expects($this->at(0))
->method('fetch')
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function testMarkerAnnotation()
{
$lexer = new DocLexer;

$lexer->setInput("@Name");
$lexer->setInput('@Name');
$this->assertNull($lexer->token);
$this->assertNull($lexer->lookahead);

Expand Down
Loading