Skip to content

Commit

Permalink
Fixed documentation for Doctrine\Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Morel committed Dec 14, 2012
1 parent c405f6d commit aadce3c
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 26 deletions.
16 changes: 13 additions & 3 deletions tests/Doctrine/Tests/DbalFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,30 @@

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'])) {
Expand All @@ -29,4 +39,4 @@ protected function setUp()
$this->_conn = self::$_sharedConn;
}
}
}
}
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/DbalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*/
class DbalTestCase extends DoctrineTestCase
{
}
}
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/DoctrineTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*/
abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase
{
}
}
68 changes: 59 additions & 9 deletions tests/Doctrine/Tests/OrmFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@
*/
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;

/**
Expand All @@ -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',
Expand Down Expand Up @@ -126,13 +152,20 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
),
);

/**
* @param string $setName
*
* @return void
*/
protected function useModelSet($setName)
{
$this->_usedModelSets[$setName] = true;
}

/**
* Sweeps the database tables and clears the EntityManager.
*
* @return void
*/
protected function tearDown()
{
Expand Down Expand Up @@ -242,6 +275,13 @@ protected function tearDown()
$this->_em->clear();
}

/**
* @param array $classNames
*
* @return void
*
* @throws \RuntimeException
*/
protected function setUpEntitySchema(array $classNames)
{
if ($this->_em === null) {
Expand All @@ -264,6 +304,8 @@ protected function setUpEntitySchema(array $classNames)
/**
* Creates a connection to the test database, if there is none yet, and
* creates the necessary tables.
*
* @return void
*/
protected function setUp()
{
Expand Down Expand Up @@ -312,9 +354,10 @@ protected function setUp()
/**
* 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
Expand Down Expand Up @@ -370,6 +413,13 @@ protected function _getEntityManager($config = null, $eventManager = null) {
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) {
Expand Down
19 changes: 12 additions & 7 deletions tests/Doctrine/Tests/OrmPerformanceTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -35,9 +36,13 @@ protected function runTest()
}

/**
* @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)
{
Expand All @@ -50,11 +55,11 @@ public function setMaxRunningTime($maxRunningTime)

/**
* @return integer
* @since Method available since Release 2.3.0
*
* @since Method available since Release 2.3.0
*/
public function getMaxRunningTime()
{
return $this->maxRunningTime;
}
}

27 changes: 24 additions & 3 deletions tests/Doctrine/Tests/OrmTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@
*/
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)
Expand Down Expand Up @@ -65,7 +75,12 @@ protected function createAnnotationDriver($paths = array(), $alias = null)
* 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)
{
Expand Down Expand Up @@ -97,6 +112,9 @@ protected function _getTestEntityManager($conn = null, $conf = null, $eventManag
return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager);
}

/**
* @return \Doctrine\Common\Cache\Cache
*/
private static function getSharedMetadataCacheImpl()
{
if (self::$_metadataCacheImpl === null) {
Expand All @@ -106,6 +124,9 @@ private static function getSharedMetadataCacheImpl()
return self::$_metadataCacheImpl;
}

/**
* @return \Doctrine\Common\Cache\Cache
*/
private static function getSharedQueryCacheImpl()
{
if (self::$_queryCacheImpl === null) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/TestUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -116,4 +116,4 @@ public static function getTempConnection()
// Connect to tmpdb in order to drop and create the real test db.
return \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams);
}
}
}

0 comments on commit aadce3c

Please sign in to comment.