Skip to content

Commit

Permalink
Merge pull request #7122 from Majkl578/dev/tests/typing-setup-teardow…
Browse files Browse the repository at this point in the history
…n-tests

Tests: Return types for setUp, tearDown and all test methods
  • Loading branch information
Ocramius committed Mar 9, 2018
2 parents 1a14c85 + a754acb commit 43c2524
Show file tree
Hide file tree
Showing 366 changed files with 2,507 additions and 2,517 deletions.
5 changes: 1 addition & 4 deletions tests/Doctrine/Tests/DbalFunctionalTestCase.php
Expand Up @@ -28,10 +28,7 @@ protected function resetSharedConn()
self::$sharedConn = null;
}

/**
* @return void
*/
protected function setUp()
protected function setUp() : void
{
if (isset($this->sharedFixture['conn'])) {
$this->conn = $this->sharedFixture['conn'];
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php
Expand Up @@ -21,7 +21,7 @@ abstract class AbstractRegionTest extends OrmFunctionalTestCase
/** @var ArrayCache */
protected $cache;

protected function setUp()
protected function setUp() : void
{
parent::setUp();

Expand All @@ -45,7 +45,7 @@ public static function dataProviderCacheValues()
/**
* @dataProvider dataProviderCacheValues
*/
public function testPutGetContainsEvict($key, $value)
public function testPutGetContainsEvict($key, $value) : void
{
self::assertFalse($this->region->contains($key));

Expand All @@ -62,7 +62,7 @@ public function testPutGetContainsEvict($key, $value)
self::assertFalse($this->region->contains($key));
}

public function testEvictAll()
public function testEvictAll() : void
{
$key1 = new CacheKeyMock('key.1');
$key2 = new CacheKeyMock('key.2');
Expand Down
10 changes: 5 additions & 5 deletions tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php
Expand Up @@ -25,14 +25,14 @@ class CacheConfigTest extends DoctrineTestCase
/**
* {@inheritDoc}
*/
protected function setUp()
protected function setUp() : void
{
parent::setUp();

$this->config = new CacheConfiguration();
}

public function testSetGetRegionLifetime()
public function testSetGetRegionLifetime() : void
{
$config = $this->config->getRegionsConfiguration();

Expand All @@ -45,7 +45,7 @@ public function testSetGetRegionLifetime()
self::assertEquals(222, $config->getLifetime('foo_region'));
}

public function testSetGetCacheLogger()
public function testSetGetCacheLogger() : void
{
$logger = $this->createMock(CacheLogger::class);

Expand All @@ -56,7 +56,7 @@ public function testSetGetCacheLogger()
self::assertEquals($logger, $this->config->getCacheLogger());
}

public function testSetGetCacheFactory()
public function testSetGetCacheFactory() : void
{
$factory = $this->createMock(CacheFactory::class);

Expand All @@ -67,7 +67,7 @@ public function testSetGetCacheFactory()
self::assertEquals($factory, $this->config->getCacheFactory());
}

public function testSetGetQueryValidator()
public function testSetGetQueryValidator() : void
{
$factory = $this->createMock(CacheFactory::class);
$factory->method('getTimestampRegion')->willReturn($this->createMock(TimestampRegion::class));
Expand Down
14 changes: 7 additions & 7 deletions tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php
Expand Up @@ -13,55 +13,55 @@
*/
class CacheKeyTest extends DoctrineTestCase
{
public function testEntityCacheKeyIdentifierCollision()
public function testEntityCacheKeyIdentifierCollision() : void
{
$key1 = new EntityCacheKey('Foo', ['id' => 1]);
$key2 = new EntityCacheKey('Bar', ['id' => 1]);

self::assertNotEquals($key1->hash, $key2->hash);
}

public function testEntityCacheKeyIdentifierType()
public function testEntityCacheKeyIdentifierType() : void
{
$key1 = new EntityCacheKey('Foo', ['id' => 1]);
$key2 = new EntityCacheKey('Foo', ['id' => '1']);

self::assertEquals($key1->hash, $key2->hash);
}

public function testEntityCacheKeyIdentifierOrder()
public function testEntityCacheKeyIdentifierOrder() : void
{
$key1 = new EntityCacheKey('Foo', ['foo_bar' => 1, 'bar_foo' => 2]);
$key2 = new EntityCacheKey('Foo', ['bar_foo' => 2, 'foo_bar' => 1]);

self::assertEquals($key1->hash, $key2->hash);
}

public function testCollectionCacheKeyIdentifierType()
public function testCollectionCacheKeyIdentifierType() : void
{
$key1 = new CollectionCacheKey('Foo', 'assoc', ['id' => 1]);
$key2 = new CollectionCacheKey('Foo', 'assoc', ['id' => '1']);

self::assertEquals($key1->hash, $key2->hash);
}

public function testCollectionCacheKeyIdentifierOrder()
public function testCollectionCacheKeyIdentifierOrder() : void
{
$key1 = new CollectionCacheKey('Foo', 'assoc', ['foo_bar' => 1, 'bar_foo' => 2]);
$key2 = new CollectionCacheKey('Foo', 'assoc', ['bar_foo' => 2, 'foo_bar' => 1]);

self::assertEquals($key1->hash, $key2->hash);
}

public function testCollectionCacheKeyIdentifierCollision()
public function testCollectionCacheKeyIdentifierCollision() : void
{
$key1 = new CollectionCacheKey('Foo', 'assoc', ['id' => 1]);
$key2 = new CollectionCacheKey('Bar', 'assoc', ['id' => 1]);

self::assertNotEquals($key1->hash, $key2->hash);
}

public function testCollectionCacheKeyAssociationCollision()
public function testCollectionCacheKeyAssociationCollision() : void
{
$key1 = new CollectionCacheKey('Foo', 'assoc1', ['id' => 1]);
$key2 = new CollectionCacheKey('Foo', 'assoc2', ['id' => 1]);
Expand Down
10 changes: 5 additions & 5 deletions tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php
Expand Up @@ -23,15 +23,15 @@ class CacheLoggerChainTest extends DoctrineTestCase
/** @var \PHPUnit_Framework_MockObject_MockObject|CacheLogger */
private $mock;

protected function setUp()
protected function setUp() : void
{
parent::setUp();

$this->logger = new CacheLoggerChain();
$this->mock = $this->createMock(CacheLogger::class);
}

public function testGetAndSetLogger()
public function testGetAndSetLogger() : void
{
self::assertEmpty($this->logger->getLoggers());

Expand All @@ -43,7 +43,7 @@ public function testGetAndSetLogger()
self::assertEquals(['mock' => $this->mock], $this->logger->getLoggers());
}

public function testEntityCacheChain()
public function testEntityCacheChain() : void
{
$name = 'my_entity_region';
$key = new EntityCacheKey(State::class, ['id' => 1]);
Expand All @@ -67,7 +67,7 @@ public function testEntityCacheChain()
$this->logger->entityCacheMiss($name, $key);
}

public function testCollectionCacheChain()
public function testCollectionCacheChain() : void
{
$name = 'my_collection_region';
$key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]);
Expand All @@ -91,7 +91,7 @@ public function testCollectionCacheChain()
$this->logger->collectionCacheMiss($name, $key);
}

public function testQueryCacheChain()
public function testQueryCacheChain() : void
{
$name = 'my_query_region';
$key = new QueryCacheKey('my_query_hash');
Expand Down
36 changes: 18 additions & 18 deletions tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php
Expand Up @@ -45,7 +45,7 @@ class DefaultCacheFactoryTest extends OrmTestCase
/** @var RegionsConfiguration */
private $regionsConfig;

protected function setUp()
protected function setUp() : void
{
$this->enableSecondLevelCache();

Expand All @@ -66,12 +66,12 @@ protected function setUp()
;
}

public function testImplementsCacheFactory()
public function testImplementsCacheFactory() : void
{
self::assertInstanceOf(CacheFactory::class, $this->factory);
}

public function testBuildCachedEntityPersisterReadOnly()
public function testBuildCachedEntityPersisterReadOnly() : void
{
$em = $this->em;
$metadata = clone $em->getClassMetadata(State::class);
Expand All @@ -95,7 +95,7 @@ public function testBuildCachedEntityPersisterReadOnly()
self::assertInstanceOf(ReadOnlyCachedEntityPersister::class, $cachedPersister);
}

public function testBuildCachedEntityPersisterReadWrite()
public function testBuildCachedEntityPersisterReadWrite() : void
{
$em = $this->em;
$metadata = clone $em->getClassMetadata(State::class);
Expand All @@ -119,7 +119,7 @@ public function testBuildCachedEntityPersisterReadWrite()
self::assertInstanceOf(ReadWriteCachedEntityPersister::class, $cachedPersister);
}

public function testBuildCachedEntityPersisterNonStrictReadWrite()
public function testBuildCachedEntityPersisterNonStrictReadWrite() : void
{
$em = $this->em;
$metadata = clone $em->getClassMetadata(State::class);
Expand All @@ -143,7 +143,7 @@ public function testBuildCachedEntityPersisterNonStrictReadWrite()
self::assertInstanceOf(NonStrictReadWriteCachedEntityPersister::class, $cachedPersister);
}

public function testBuildCachedCollectionPersisterReadOnly()
public function testBuildCachedCollectionPersisterReadOnly() : void
{
$em = $this->em;
$metadata = clone $em->getClassMetadata(State::class);
Expand All @@ -168,7 +168,7 @@ public function testBuildCachedCollectionPersisterReadOnly()
self::assertInstanceOf(ReadOnlyCachedCollectionPersister::class, $cachedPersister);
}

public function testBuildCachedCollectionPersisterReadWrite()
public function testBuildCachedCollectionPersisterReadWrite() : void
{
$em = $this->em;
$metadata = clone $em->getClassMetadata(State::class);
Expand All @@ -193,7 +193,7 @@ public function testBuildCachedCollectionPersisterReadWrite()
self::assertInstanceOf(ReadWriteCachedCollectionPersister::class, $cachedPersister);
}

public function testBuildCachedCollectionPersisterNonStrictReadWrite()
public function testBuildCachedCollectionPersisterNonStrictReadWrite() : void
{
$em = $this->em;
$metadata = clone $em->getClassMetadata(State::class);
Expand All @@ -218,7 +218,7 @@ public function testBuildCachedCollectionPersisterNonStrictReadWrite()
self::assertInstanceOf(NonStrictReadWriteCachedCollectionPersister::class, $cachedPersister);
}

public function testInheritedEntityCacheRegion()
public function testInheritedEntityCacheRegion() : void
{
$em = $this->em;
$metadata1 = clone $em->getClassMetadata(AttractionContactInfo::class);
Expand All @@ -237,7 +237,7 @@ public function testInheritedEntityCacheRegion()
self::assertSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion());
}

public function testCreateNewCacheDriver()
public function testCreateNewCacheDriver() : void
{
$em = $this->em;
$metadata1 = clone $em->getClassMetadata(State::class);
Expand All @@ -256,7 +256,7 @@ public function testCreateNewCacheDriver()
self::assertNotSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion());
}

public function testBuildCachedEntityPersisterNonStrictException()
public function testBuildCachedEntityPersisterNonStrictException() : void
{
$em = $this->em;
$metadata = clone $em->getClassMetadata(State::class);
Expand All @@ -272,7 +272,7 @@ public function testBuildCachedEntityPersisterNonStrictException()
$this->factory->buildCachedEntityPersister($em, $persister, $metadata);
}

public function testBuildCachedCollectionPersisterException()
public function testBuildCachedCollectionPersisterException() : void
{
$em = $this->em;
$metadata = clone $em->getClassMetadata(State::class);
Expand All @@ -289,7 +289,7 @@ public function testBuildCachedCollectionPersisterException()
$this->factory->buildCachedCollectionPersister($em, $persister, $association);
}

public function testInvalidFileLockRegionDirectoryException()
public function testInvalidFileLockRegionDirectoryException() : void
{
$factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl());

Expand All @@ -304,7 +304,7 @@ public function testInvalidFileLockRegionDirectoryException()
$factory->getRegion($fooCache);
}

public function testInvalidFileLockRegionDirectoryExceptionWithEmptyString()
public function testInvalidFileLockRegionDirectoryExceptionWithEmptyString() : void
{
$factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl());

Expand All @@ -321,7 +321,7 @@ public function testInvalidFileLockRegionDirectoryExceptionWithEmptyString()
$factory->getRegion($fooCache);
}

public function testBuildsNewNamespacedCacheInstancePerRegionInstance()
public function testBuildsNewNamespacedCacheInstancePerRegionInstance() : void
{
$factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl());

Expand All @@ -335,7 +335,7 @@ public function testBuildsNewNamespacedCacheInstancePerRegionInstance()
self::assertSame('bar', $barRegion->getCache()->getNamespace());
}

public function testAppendsNamespacedCacheInstancePerRegionInstanceWhenItsAlreadySet()
public function testAppendsNamespacedCacheInstancePerRegionInstanceWhenItsAlreadySet() : void
{
$cache = clone $this->getSharedSecondLevelCacheDriverImpl();
$cache->setNamespace('testing');
Expand All @@ -352,7 +352,7 @@ public function testAppendsNamespacedCacheInstancePerRegionInstanceWhenItsAlread
self::assertSame('testing:bar', $barRegion->getCache()->getNamespace());
}

public function testBuildsDefaultCacheRegionFromGenericCacheRegion()
public function testBuildsDefaultCacheRegionFromGenericCacheRegion() : void
{
/* @var $cache \Doctrine\Common\Cache\Cache */
$cache = $this->createMock(Cache::class);
Expand All @@ -364,7 +364,7 @@ public function testBuildsDefaultCacheRegionFromGenericCacheRegion()
self::assertInstanceOf(DefaultRegion::class, $barRegion);
}

public function testBuildsMultiGetCacheRegionFromGenericCacheRegion()
public function testBuildsMultiGetCacheRegionFromGenericCacheRegion() : void
{
/* @var $cache \Doctrine\Common\Cache\CacheProvider */
$cache = $this->getMockForAbstractClass(CacheProvider::class);
Expand Down

0 comments on commit 43c2524

Please sign in to comment.