From aadce3c7471ac098a2c3f7f1aafa07e16557c1ac Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Fri, 14 Dec 2012 18:55:49 +0000 Subject: [PATCH] Fixed documentation for Doctrine\Tests --- .../Doctrine/Tests/DbalFunctionalTestCase.php | 16 ++++- tests/Doctrine/Tests/DbalTestCase.php | 2 +- tests/Doctrine/Tests/DoctrineTestCase.php | 2 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 68 ++++++++++++++++--- .../Doctrine/Tests/OrmPerformanceTestCase.php | 19 ++++-- tests/Doctrine/Tests/OrmTestCase.php | 27 +++++++- tests/Doctrine/Tests/TestUtil.php | 4 +- 7 files changed, 112 insertions(+), 26 deletions(-) diff --git a/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/tests/Doctrine/Tests/DbalFunctionalTestCase.php index 07e48dc36..0be58edf3 100644 --- a/tests/Doctrine/Tests/DbalFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DbalFunctionalTestCase.php @@ -4,20 +4,30 @@ namespace Doctrine\Tests; class DbalFunctionalTestCase extends DbalTestCase { - /* Shared connection when a TestCase is run alone (outside of its functional suite) */ + /** + * Shared connection when a TestCase is run alone (outside of its functional suite). + * + * @var \Doctrine\DBAL\Connection|null + */ private static $_sharedConn; /** - * @var Doctrine\DBAL\Connection + * @var \Doctrine\DBAL\Connection */ protected $_conn; + /** + * @return void + */ protected function resetSharedConn() { $this->sharedFixture['conn'] = null; self::$_sharedConn = null; } + /** + * @return void + */ protected function setUp() { if (isset($this->sharedFixture['conn'])) { @@ -29,4 +39,4 @@ class DbalFunctionalTestCase extends DbalTestCase $this->_conn = self::$_sharedConn; } } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/DbalTestCase.php b/tests/Doctrine/Tests/DbalTestCase.php index 2478e7bcc..35ef8bc86 100644 --- a/tests/Doctrine/Tests/DbalTestCase.php +++ b/tests/Doctrine/Tests/DbalTestCase.php @@ -7,4 +7,4 @@ namespace Doctrine\Tests; */ class DbalTestCase extends DoctrineTestCase { -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/DoctrineTestCase.php b/tests/Doctrine/Tests/DoctrineTestCase.php index e8323d294..e5ce27af9 100644 --- a/tests/Doctrine/Tests/DoctrineTestCase.php +++ b/tests/Doctrine/Tests/DoctrineTestCase.php @@ -7,4 +7,4 @@ namespace Doctrine\Tests; */ abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase { -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 571e2e10f..715c32a5f 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -9,12 +9,25 @@ namespace Doctrine\Tests; */ abstract class OrmFunctionalTestCase extends OrmTestCase { - /* The metadata cache shared between all functional tests. */ + /** + * The metadata cache shared between all functional tests. + * + * @var \Doctrine\Common\Cache\Cache|null + */ private static $_metadataCacheImpl = null; - /* The query cache shared between all functional tests. */ + + /** + * The query cache shared between all functional tests. + * + * @var \Doctrine\Common\Cache\Cache|null + */ private static $_queryCacheImpl = null; - /* Shared connection when a TestCase is run alone (outside of its functional suite) */ + /** + * Shared connection when a TestCase is run alone (outside of its functional suite). + * + * @var \Doctrine\DBAL\Connection|null + */ protected static $_sharedConn; /** @@ -32,19 +45,32 @@ abstract class OrmFunctionalTestCase extends OrmTestCase */ protected $_sqlLoggerStack; - /** The names of the model sets used in this testcase. */ + /** + * The names of the model sets used in this testcase. + * + * @var array + */ protected $_usedModelSets = array(); - /** Whether the database schema has already been created. */ + /** + * Whether the database schema has already been created. + * + * @var array + */ protected static $_tablesCreated = array(); /** * Array of entity class name to their tables that were created. + * * @var array */ protected static $_entityTablesCreated = array(); - /** List of model sets and their classes. */ + /** + * List of model sets and their classes. + * + * @var array + */ protected static $_modelSets = array( 'cms' => array( 'Doctrine\Tests\Models\CMS\CmsUser', @@ -126,6 +152,11 @@ abstract class OrmFunctionalTestCase extends OrmTestCase ), ); + /** + * @param string $setName + * + * @return void + */ protected function useModelSet($setName) { $this->_usedModelSets[$setName] = true; @@ -133,6 +164,8 @@ abstract class OrmFunctionalTestCase extends OrmTestCase /** * Sweeps the database tables and clears the EntityManager. + * + * @return void */ protected function tearDown() { @@ -242,6 +275,13 @@ abstract class OrmFunctionalTestCase extends OrmTestCase $this->_em->clear(); } + /** + * @param array $classNames + * + * @return void + * + * @throws \RuntimeException + */ protected function setUpEntitySchema(array $classNames) { if ($this->_em === null) { @@ -264,6 +304,8 @@ abstract class OrmFunctionalTestCase extends OrmTestCase /** * Creates a connection to the test database, if there is none yet, and * creates the necessary tables. + * + * @return void */ protected function setUp() { @@ -312,9 +354,10 @@ abstract class OrmFunctionalTestCase extends OrmTestCase /** * Gets an EntityManager for testing purposes. * - * @param Configuration $config The Configuration to pass to the EntityManager. - * @param EventManager $eventManager The EventManager to pass to the EntityManager. - * @return EntityManager + * @param \Doctrine\ORM\Configuration $config The Configuration to pass to the EntityManager. + * @param \Doctrine\Common\EventManager $eventManager The EventManager to pass to the EntityManager. + * + * @return \Doctrine\ORM\EntityManager */ protected function _getEntityManager($config = null, $eventManager = null) { // NOTE: Functional tests use their own shared metadata cache, because @@ -370,6 +413,13 @@ abstract class OrmFunctionalTestCase extends OrmTestCase return \Doctrine\ORM\EntityManager::create($conn, $config); } + /** + * @param \Exception $e + * + * @return void + * + * @throws \Exception + */ protected function onNotSuccessfulTest(\Exception $e) { if ($e instanceof \PHPUnit_Framework_AssertionFailedError) { diff --git a/tests/Doctrine/Tests/OrmPerformanceTestCase.php b/tests/Doctrine/Tests/OrmPerformanceTestCase.php index ab8fcf503..39bae39b6 100644 --- a/tests/Doctrine/Tests/OrmPerformanceTestCase.php +++ b/tests/Doctrine/Tests/OrmPerformanceTestCase.php @@ -3,18 +3,19 @@ namespace Doctrine\Tests; /** - * Description of DoctrinePerformanceTestCase + * Description of DoctrinePerformanceTestCase. * * @author robo */ class OrmPerformanceTestCase extends OrmFunctionalTestCase { /** - * @var integer + * @var integer */ protected $maxRunningTime = 0; /** + * @return void */ protected function runTest() { @@ -35,9 +36,13 @@ class OrmPerformanceTestCase extends OrmFunctionalTestCase } /** - * @param integer $maxRunningTime - * @throws InvalidArgumentException - * @since Method available since Release 2.3.0 + * @param integer $maxRunningTime + * + * @return void + * + * @throws \InvalidArgumentException + * + * @since Method available since Release 2.3.0 */ public function setMaxRunningTime($maxRunningTime) { @@ -50,11 +55,11 @@ class OrmPerformanceTestCase extends OrmFunctionalTestCase /** * @return integer - * @since Method available since Release 2.3.0 + * + * @since Method available since Release 2.3.0 */ public function getMaxRunningTime() { return $this->maxRunningTime; } } - diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 4ad60d68b..9ba32cf8b 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -9,14 +9,24 @@ use Doctrine\Common\Cache\ArrayCache; */ abstract class OrmTestCase extends DoctrineTestCase { - /** The metadata cache that is shared between all ORM tests (except functional tests). */ + /** + * The metadata cache that is shared between all ORM tests (except functional tests). + * + * @var \Doctrine\Common\Cache\Cache|null + */ private static $_metadataCacheImpl = null; - /** The query cache that is shared between all ORM tests (except functional tests). */ + /** + * The query cache that is shared between all ORM tests (except functional tests). + * + * @var \Doctrine\Common\Cache\Cache|null + */ private static $_queryCacheImpl = null; /** * @param array $paths + * @param mixed $alias + * * @return \Doctrine\ORM\Mapping\Driver\AnnotationDriver */ protected function createAnnotationDriver($paths = array(), $alias = null) @@ -65,7 +75,12 @@ abstract class OrmTestCase extends DoctrineTestCase * be configured in the tests to simulate the DBAL behavior that is desired * for a particular test, * - * @return Doctrine\ORM\EntityManager + * @param \Doctrine\DBAL\Connection|array $conn + * @param mixed $conf + * @param \Doctrine\Common\EventManager|null $eventManager + * @param bool $withSharedMetadata + * + * @return \Doctrine\ORM\EntityManager */ protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null, $withSharedMetadata = true) { @@ -97,6 +112,9 @@ abstract class OrmTestCase extends DoctrineTestCase return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager); } + /** + * @return \Doctrine\Common\Cache\Cache + */ private static function getSharedMetadataCacheImpl() { if (self::$_metadataCacheImpl === null) { @@ -106,6 +124,9 @@ abstract class OrmTestCase extends DoctrineTestCase return self::$_metadataCacheImpl; } + /** + * @return \Doctrine\Common\Cache\Cache + */ private static function getSharedQueryCacheImpl() { if (self::$_queryCacheImpl === null) { diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index b78d06e4e..451a2b76d 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -28,7 +28,7 @@ class TestUtil * 1) Each invocation of this method returns a NEW database connection. * 2) The database is dropped and recreated to ensure it's clean. * - * @return Doctrine\DBAL\Connection The database connection instance. + * @return \Doctrine\DBAL\Connection The database connection instance. */ public static function getConnection() { @@ -116,4 +116,4 @@ class TestUtil // Connect to tmpdb in order to drop and create the real test db. return \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); } -} \ No newline at end of file +}