1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Fixed documentation for Doctrine\Tests

This commit is contained in:
Benjamin Morel 2012-12-14 18:55:49 +00:00
parent c405f6d3f6
commit aadce3c747
7 changed files with 112 additions and 26 deletions

View File

@ -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;
}
}
}
}

View File

@ -7,4 +7,4 @@ namespace Doctrine\Tests;
*/
class DbalTestCase extends DoctrineTestCase
{
}
}

View File

@ -7,4 +7,4 @@ namespace Doctrine\Tests;
*/
abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase
{
}
}

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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) {

View File

@ -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);
}
}
}