1
0
mirror of synced 2025-02-03 05:49:25 +03:00

Increment assertion count manually

Which is needed to test void methods that shouldn't raise any exception
on a certain condition. If the interpreter gets to the point where the
assertion count is incremented it means that no exceptions have been
thrown and our test is successful.

Important to note that some tests were slighly refactored to simplify
things a bit.
This commit is contained in:
Luís Cobucci 2017-05-31 08:05:01 +02:00
parent 8d144daf01
commit 1bf884970f
No known key found for this signature in database
GPG Key ID: EC61C5F01750ED3C
9 changed files with 39 additions and 73 deletions

View File

@ -179,6 +179,8 @@ class ConfigurationTest extends TestCase
{
$this->setProductionSettings();
$this->configuration->ensureProductionSettings();
$this->addToAssertionCount(1);
}
public function testEnsureProductionSettingsQueryCache()

View File

@ -301,6 +301,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
->setParameter(1, 'IT')
->execute();
$this->addToAssertionCount(1);
}
/**

View File

@ -37,6 +37,8 @@ class LockTest extends OrmFunctionalTestCase
$this->_em->flush();
$this->_em->lock($article, LockMode::OPTIMISTIC, $article->version);
$this->addToAssertionCount(1);
}
/**

View File

@ -178,6 +178,8 @@ class OptimisticTest extends OrmFunctionalTestCase
$proxy = $this->_em->getReference(OptimisticStandard::class, $test->id);
$this->_em->lock($proxy, LockMode::OPTIMISTIC, 1);
$this->addToAssertionCount(1);
}
public function testOptimisticTimestampSetsDefaultValue()

View File

@ -36,6 +36,8 @@ class PersistentObjectTest extends OrmFunctionalTestCase
$this->_em->persist($entity);
$this->_em->flush();
$this->addToAssertionCount(1);
}
public function testFind()

View File

@ -46,27 +46,17 @@ class DDC3170Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
$this->_em->clear();
try {
$this->_em->createQueryBuilder()
->select('p')
->from(DDC3170ProductJoined::class, 'p')
->getQuery()
->getResult(AbstractQuery::HYDRATE_SIMPLEOBJECT);
} catch (HydrationException $e) // Thrown by SimpleObjectHydrator
{
$this->fail('Failed correct mapping of discriminator column when using simple object hydration and class table inheritance');
}
try {
$this->_em->createQueryBuilder()
->select('p')
->from(DDC3170ProductSingleTable::class, 'p')
->getQuery()
->getResult(AbstractQuery::HYDRATE_SIMPLEOBJECT);
} catch (HydrationException $e) // Thrown by SimpleObjectHydrator
{
$this->fail('Failed correct mapping of discriminator column when using simple object hydration and single table inheritance');
}
}
}

View File

@ -23,6 +23,8 @@ class DDC588Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
// Following should not result in exception
$this->_em->refresh($site);
$this->addToAssertionCount(1);
}
}

View File

@ -68,6 +68,7 @@ class DDC742Test extends \Doctrine\Tests\OrmFunctionalTestCase
$user->favoriteComments->add($this->_em->find(DDC742Comment::class, $comment3->id));
$this->_em->flush();
$this->addToAssertionCount(1);
}
}

View File

@ -24,64 +24,28 @@ class SchemaValidatorTest extends OrmTestCase
$this->validator = new SchemaValidator($this->em);
}
public function testCmsModelSet()
/**
* @dataProvider modelSetProvider
*/
public function testCmsModelSet(string $path)
{
$this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(
[
__DIR__ . "/../../Models/CMS"
]
);
$this->em->getConfiguration()
->getMetadataDriverImpl()
->addPaths([$path]);
$this->validator->validateMapping();
}
public function testCompanyModelSet()
public function modelSetProvider(): array
{
$this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(
[
__DIR__ . "/../../Models/Company"
]
);
$this->validator->validateMapping();
}
public function testECommerceModelSet()
{
$this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(
[
__DIR__ . "/../../Models/ECommerce"
]
);
$this->validator->validateMapping();
}
public function testForumModelSet()
{
$this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(
[
__DIR__ . "/../../Models/Forum"
]
);
$this->validator->validateMapping();
}
public function testNavigationModelSet()
{
$this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(
[
__DIR__ . "/../../Models/Navigation"
]
);
$this->validator->validateMapping();
}
public function testRoutingModelSet()
{
$this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(
[
__DIR__ . "/../../Models/Routing"
]
);
$this->validator->validateMapping();
return [
'cms' => [__DIR__ . '/../../Models/CMS'],
'company' => [__DIR__ . '/../../Models/Company'],
'ecommerce' => [__DIR__ . '/../../Models/ECommerce'],
'forum' => [__DIR__ . '/../../Models/Forum'],
'navigation' => [__DIR__ . '/../../Models/Navigation'],
'routing' => [__DIR__ . '/../../Models/Routing'],
];
}
/**