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

[2.0] Cleanups, build fixes.

This commit is contained in:
romanb 2009-06-15 18:25:47 +00:00
parent e21d8fffae
commit f28127664c
30 changed files with 251 additions and 307 deletions

View File

@ -62,26 +62,40 @@
</copy>
</target>
<target name="test">
<mkdir dir="${build.dir}/logs"/>
<mkdir dir="reports/tests"/>
<phpunit printsummary="true" haltonfailure="true">
<formatter todir="${build.dir}/logs" type="xml"/>
<batchtest classpath="tests">
<fileset dir="tests">
<include name="**/*Test.php"/>
</fileset>
</batchtest>
</phpunit>
<!-- <phpunitreport infile="build/logs/testsuites.xml" format="frames" todir="reports/tests" />-->
</target>
<target name="dist-common">
<tar destfile="./dist/Doctrine2-common.tar.gz" compression="gzip">
<fileset dir="./build/common">
<fileset dir="${build.dir}/common">
<include name="**" />
</fileset>
</tar>
</target>
<target name="dist-dbal">
<tar destfile="./dist/Doctrine2-dbal.tar.gz" compression="gzip">
<fileset dir="./build/dbal">
<tar destfile="${dist.dir}/Doctrine2-dbal.tar.gz" compression="gzip">
<fileset dir="${build.dir}/dbal">
<include name="**" />
</fileset>
</tar>
</target>
<target name="dist-all" depends="build-all, dist-common, dist-dbal">
<target name="dist-all" depends="test, build-all, dist-common, dist-dbal">
<tar destfile="./dist/Doctrine2-all.tar.gz" compression="gzip">
<fileset dir="./build/all">
<tar destfile="${dist.dir}/Doctrine2-all.tar.gz" compression="gzip">
<fileset dir="${build.dir}/all">
<include name="**" />
</fileset>
</tar>

View File

@ -41,7 +41,7 @@ class SqlWalker implements TreeWalker
private $_aliasCounter = 0;
/** Counter for generating unique table aliases. */
private $_tableAliasCounter = 0;
private $_scalarResultCounter = 0;
private $_scalarResultCounter = 1;
/** Counter for SQL parameter positions. */
private $_sqlParamIndex = 1;
/** The ParserResult. */

View File

@ -24,23 +24,30 @@
class Annotation {
public $value;
private static $creationStack = array();
public final function __construct($data, $target) {
$reflection = new ReflectionClass($this);
$class = $reflection->getName();
if(isset(self::$creationStack[$class])) {
trigger_error("Circular annotation reference on '$class'", E_USER_ERROR);
return;
}
self::$creationStack[$class] = true;
foreach($data as $key => $value) {
if($reflection->hasProperty($key)) {
$this->$key = $value;
} else {
$class = $reflection->getName();
trigger_error("Property '$key' not defined for annotation '$class'");
}
}
$this->checkTargetConstraints($target);
$this->checkConstraints($target);
unset(self::$creationStack[$class]);
}
private function checkTargetConstraints($target) {
$reflection = new ReflectionAnnotatedClass($this);
/*$reflection = new ReflectionAnnotatedClass($this);
if($reflection->hasAnnotation('Target')) {
$value = $reflection->getAnnotation('Target')->value;
$values = is_array($value) ? $value : array($value);
@ -50,7 +57,7 @@
if($value == 'property' && $target instanceof ReflectionProperty) return;
}
trigger_error("Annotation '".get_class($this)."' not allowed on ".$this->createName($target), E_USER_ERROR);
}
}*/
}
private function createName($target) {
@ -66,7 +73,7 @@
protected function checkConstraints($target) {}
}
class Target extends Annotation {}
//class Target extends Annotation {}
class AnnotationsBuilder {
private static $cache = array();
@ -75,7 +82,7 @@
$data = $this->parse($targetReflection);
$annotations = array();
foreach($data as $class => $parameters) {
if(!Addendum::ignores($class)) {
if(is_subclass_of($class, 'Annotation') && !Addendum::ignores($class)) {
foreach($parameters as $params) {
$annotationReflection = new ReflectionClass($class);
$annotations[$class][] = $annotationReflection->newInstance($params, $targetReflection);

View File

@ -190,6 +190,7 @@
$this->add(new AnnotationStringMatcher);
$this->add(new AnnotationNumberMatcher);
$this->add(new AnnotationArrayMatcher);
$this->add(new AnnotationStaticConstantMatcher);
}
}
@ -332,4 +333,20 @@
return $matches[1];
}
}
class AnnotationStaticConstantMatcher extends RegexMatcher {
public function __construct() {
parent::__construct('(\w+::\w+)');
}
protected function process($matches) {
$name = $matches[1];
if(!defined($name)) {
trigger_error("Constant '$name' used in annotation was not defined.");
return false;
}
return constant($name);
}
}
?>

View File

@ -35,6 +35,32 @@
class FirstAnnotation extends Annotation {}
class SecondAnnotation extends Annotation {}
class NoAnnotation {}
/** @NoAnnotation @FirstAnnotation */
class ExampleWithInvalidAnnotation {}
/** @SelfReferencingAnnotation */
class SelfReferencingAnnotation extends Annotation {}
/** @IndirectReferenceLoopAnnotationHelper */
class IndirectReferenceLoopAnnotation extends Annotation {}
/** @IndirectReferenceLoopAnnotation */
class IndirectReferenceLoopAnnotationHelper extends Annotation {}
class Statics {
const A_CONSTANT = 'constant';
static public $static = 'static';
}
/** @FirstAnnotation(Statics::A_CONSTANT) */
class ClassAnnotatedWithStaticConstant {}
/** @FirstAnnotation(Statics::UNKNOWN_CONSTANT) */
class ClassAnnotatedWithNonExistingConstant {}
class TestOfAnnotations extends UnitTestCase {
public function testReflectionAnnotatedClass() {
@ -192,6 +218,36 @@
$this->assertIsA($annotations[0], 'FirstAnnotation');
$this->assertIsA($annotations[1], 'FirstAnnotation');
}
public function testClassWithNoAnnotationParentShouldNotBeParsed() {
$reflection = new ReflectionAnnotatedClass('ExampleWithInvalidAnnotation');
$annotations = $reflection = $reflection->getAnnotations();
$this->assertEqual(count($annotations), 1);
$this->assertIsA($annotations[0], 'FirstAnnotation');
}
public function testCircularReferenceShouldThrowError() {
$this->expectError("Circular annotation reference on 'SelfReferencingAnnotation'");
$reflection = new ReflectionAnnotatedClass('SelfReferencingAnnotation');
$reflection->getAnnotations();
$this->expectError("Circular annotation reference on 'IndirectReferenceLoopAnnotationHelper'");
$reflection = new ReflectionAnnotatedClass('IndirectReferenceLoopAnnotation');
$reflection->getAnnotations();
}
public function testConstInAnnotationShouldReturnCorrectValue() {
$reflection = new ReflectionAnnotatedClass('ClassAnnotatedWithStaticConstant');
$annotation = $reflection->getAnnotation('FirstAnnotation');
$this->assertEqual($annotation->value, Statics::A_CONSTANT);
}
public function testBadConstInAnnotationShouldCauseError() {
$this->expectError("Constant 'Statics::UNKNOWN_CONSTANT' used in annotation was not defined.");
$reflection = new ReflectionAnnotatedClass('ClassAnnotatedWithNonExistingConstant');
$annotation = $reflection->getAnnotation('FirstAnnotation');
}
}
Mock::generatePartial('AnnotationsBuilder', 'MockedAnnotationsBuilder', array('getDocComment'));

View File

@ -8,26 +8,21 @@
require_once(dirname(__FILE__).'/annotation_parser_test.php');
require_once(dirname(__FILE__).'/doc_comment_test.php');
class AllTests extends GroupTest {
function __construct($title = false) {
parent::__construct($title);
$this->addTestClass('TestOfAnnotations');
$this->addTestClass('TestOfPerformanceFeatures');
$this->addTestClass('TestOfSupportingFeatures');
$this->addTestClass('TestOfAnnotation');
$this->addTestClass('TestOfConstrainedAnnotation');
$this->addTestClass('TestOfMatchers');
$this->addTestClass('TestOfAnnotationMatchers');
$this->addTestClass('TestOfDocComment');
}
}
$suite = new TestSuite('All tests');
$suite->add(new TestOfAnnotations);
$suite->add(new TestOfPerformanceFeatures);
$suite->add(new TestOfSupportingFeatures);
$suite->add(new TestOfAnnotation);
$suite->add(new TestOfConstrainedAnnotation);
$suite->add(new TestOfMatchers);
$suite->add(new TestOfAnnotationMatchers);
$suite->add(new TestOfDocComment);
$reporter = TextReporter::inCli() ? new TextReporter() : new HtmlReporter();
Addendum::setRawMode(false);
$test = new AllTests('All tests in reflection mode');
$test->run(new HtmlReporter());
$suite->run($reporter);
Addendum::setRawMode(true);
$test = new AllTests('All tests in raw mode');
$test->run(new HtmlReporter());
$suite->run($reporter);
?>

View File

@ -48,6 +48,11 @@
$this->assertEqual($value, '1234');
}
}
class StaticClass {
const A_CONSTANT = 'constant';
}
class TestOfAnnotationMatchers extends UnitTestCase {
public function testAnnotationsMatcherShouldMatchAnnotationWithGarbage() {
@ -185,6 +190,11 @@
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, '{1}', array(1));
}
public function testValueMatcherShouldMatchStaticConstant() {
$matcher = new AnnotationValueMatcher;
$this->assertMatcherResult($matcher, 'StaticClass::A_CONSTANT', StaticClass::A_CONSTANT);
}
public function testArrayMatcherShouldMatchEmptyArray() {
$matcher = new AnnotationArrayMatcher;
@ -299,6 +309,18 @@
$this->assertMatcherResult($matcher, '"string\"string"', 'string"string');
$this->assertMatcherResult($matcher, "'string\'string'", "string'string");
}
public function testStaticConstantMatcherShouldMatchConstants() {
$matcher = new AnnotationStaticConstantMatcher;
$this->assertMatcherResult($matcher, 'StaticClass::A_CONSTANT', StaticClass::A_CONSTANT);
}
public function testStaticConstantMatcherShouldThrowErrorOnBadConstant() {
$this->expectError("Constant 'StaticClass::NO_CONSTANT' used in annotation was not defined.");
$matcher = new AnnotationStaticConstantMatcher;
$matcher->matches('StaticClass::NO_CONSTANT', $value);
}
private function assertNotFalse($value) {
$this->assertNotIdentical($value, false);
@ -309,4 +331,4 @@
$this->assertIdentical($value, $expected);
}
}
?>
?>

View File

@ -15,13 +15,13 @@
}
public function testConstructorThrowsErrorOnInvalidParameter() {
$this->expectError("Property 'unknown' not defined for annotation 'TestingAnnotation'");
$annotation = new TestingAnnotation(array('unknown' => 1), $this);
$this->assertError("Property 'unknown' not defined for annotation 'TestingAnnotation'");
}
public function TODO_testConstructorThrowsErrorWithoutSpecifingRequiredParameters() {
$this->expectError("Property 'required' in annotation 'TestingAnnotation' is required");
$annotation = new TestingAnnotation();
$this->assertError("Property 'required' in annotation 'TestingAnnotation' is required");
}
}
?>

View File

@ -55,7 +55,6 @@
$reflection = new ReflectionAnnotatedClass('SuccesfullyAnnotatedClass');
$method = $reflection->getMethod('method');
$property = $reflection->getProperty('property');
$this->assertNoErrors();
}
public function testMultiTargetAnnotationThrowsErrorWhenOnWrongPlace() {
@ -67,7 +66,6 @@
public function testMultiTargetAnnotationThrowsNoErrorWhenOnRightPlace() {
$reflection = new ReflectionAnnotatedClass('SuccesfullyAnnotatedClass');
$method = $reflection->getProperty('property2');
$this->assertNoErrors();
}
}
?>
?>

View File

@ -4,6 +4,8 @@ namespace Doctrine\Tests\Common;
use Doctrine\Common\ClassLoader;
require_once __DIR__ . '/../TestInit.php';
class ClassLoaderTest extends \Doctrine\Tests\DoctrineTestCase
{
public function testCustomFileExtensionAndNamespaceSeparator()

View File

@ -2,6 +2,8 @@
namespace Doctrine\Tests\Common;
require_once __DIR__ . '/../TestInit.php';
class DoctrineExceptionTest extends \Doctrine\Tests\DoctrineTestCase
{
public function testStaticCall()

View File

@ -5,6 +5,8 @@ namespace Doctrine\Tests\Common;
use Doctrine\Common\EventManager;
use Doctrine\Common\EventArgs;
require_once __DIR__ . '/../TestInit.php';
class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
{
/* Some pseudo events */

View File

@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema;
require_once __DIR__ . '/../../../TestInit.php';
class MySqlSchemaManagerTest extends SchemaManagerFunctionalTest
class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testListDatabases()
{
@ -15,14 +15,20 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTest
$this->assertEquals(true, in_array('test_create_database', $databases));
}
/**
* @expectedException \Exception
*/
public function testListFunctions()
{
return $this->assertUnsupportedMethod('listFunctions');
$this->_sm->listFunctions();
}
/**
* @expectedException \Exception
*/
public function testListTriggers()
{
return $this->assertUnsupportedMethod('listTriggers');
$this->_sm->listTriggers();
}
public function testListSequences()

View File

@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema;
require_once __DIR__ . '/../../../TestInit.php';
class OracleSchemaManagerTest extends SchemaManagerFunctionalTest
class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testListDatabases()
{
@ -21,9 +21,12 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTest
$this->assertEquals(array(), $functions);
}
/**
* @expectedException \Exception
*/
public function testListTriggers()
{
return $this->assertUnsupportedMethod('listTriggers');
$this->_sm->listTriggers();
}
public function testListSequences()

View File

@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema;
require_once __DIR__ . '/../../../TestInit.php';
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTest
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testListDatabases()
{
@ -15,9 +15,12 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTest
$this->assertEquals(true, in_array('test_create_database', $databases));
}
/**
* @expectedException \Exception
*/
public function testListFunctions()
{
return $this->assertUnsupportedMethod('listFunctions');
$this->_sm->listFunctions();
}
public function testListTriggers()

View File

@ -4,7 +4,9 @@ namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Types\Type;
class SchemaManagerFunctionalTest extends \Doctrine\Tests\DbalFunctionalTestCase
require_once __DIR__ . '/../../../TestInit.php';
class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTestCase
{
protected function setUp()
{
@ -23,7 +25,7 @@ class SchemaManagerFunctionalTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->_sm = $this->_conn->getSchemaManager();
}
public function createTestTable($name = 'test_table', $data = array())
protected function createTestTable($name = 'test_table', $data = array())
{
if ( ! isset($data['columns'])) {
$columns = array(
@ -52,15 +54,4 @@ class SchemaManagerFunctionalTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->_sm->dropAndCreateTable($name, $columns, $options);
}
public function assertUnsupportedMethod($method)
{
try {
$this->_sm->$method();
} catch (\Exception $e) {
return;
}
$this->fail($method . '() should throw an exception because it is not supported in ' . $this->_conn->getDatabasePlatform()->getName());
}
}

View File

@ -6,21 +6,30 @@ use Doctrine\DBAL\Schema;
require_once __DIR__ . '/../../../TestInit.php';
class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
/**
* @expectedException \Exception
*/
public function testListDatabases()
{
return $this->assertUnsupportedMethod('listDatabases');
$this->_sm->listDatabases();
}
/**
* @expectedException \Exception
*/
public function testListFunctions()
{
return $this->assertUnsupportedMethod('listFunctions');
$this->_sm->listFunctions();
}
/**
* @expectedException \Exception
*/
public function testListTriggers()
{
return $this->assertUnsupportedMethod('listTriggers');
$this->_sm->listTriggers();
}
public function testListSequences()
@ -92,9 +101,12 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
$this->assertEquals(true, in_array('list_tables_test', $tables));
}
/**
* @expectedException \Exception
*/
public function testListUsers()
{
return $this->assertUnsupportedMethod('listUsers');
$this->_sm->listUsers();
}
public function testListViews()
@ -157,14 +169,12 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
$this->assertEquals(null, $tableColumns[1]['default']);
}
/**
* @expectedException \Exception
*/
public function testCreateSequence()
{
return $this->assertUnsupportedMethod('createSequence');
}
public function testCreateConstraint()
{
return $this->assertUnsupportedMethod('createConstraint');
$this->_sm->createSequence('seqname', 1, 1);
}
/* FIXME: See comment in AbstractSchemaManager#dropIndex($table, $name)
@ -185,34 +195,51 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
$this->assertEquals(true, $tableIndexes[0]['unique']);
}*/
/**
* @expectedException \Exception
*/
public function testCreateForeignKey()
{
return $this->assertUnsupportedMethod('createForeignKey');
$this->_sm->createForeignKey('table', array());
}
/**
* @expectedException \Exception
*/
public function testRenameTable()
{
return $this->assertUnsupportedMethod('renameTable');
$this->_sm->renameTable('oldname', 'newname');
}
/**
* @expectedException \Exception
*/
public function testAddTableColumn()
{
return $this->assertUnsupportedMethod('addTableColumn');
return $this->_sm->addTableColumn('table', 'column', array());
}
/**
* @expectedException \Exception
*/
public function testRemoveTableColumn()
{
return $this->assertUnsupportedMethod('removeTableColumn');
$this->_sm->removeTableColumn('table', 'column');
}
/**
* @expectedException \Exception
*/
public function testChangeTableColumn()
{
return $this->assertUnsupportedMethod('changeTableColumn');
$this->_sm->changeTableColumn('name', 'type', null, array());
}
/**
* @expectedException \Exception
*/
public function testRenameTableColumn()
{
return $this->assertUnsupportedMethod('renameTableColumn');
$this->_sm->renameTableColumn('table', 'old', 'new', array());
}
}

View File

@ -30,7 +30,6 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\UnitOfWorkTest');
$suite->addTestSuite('Doctrine\Tests\ORM\EntityManagerTest');
//$suite->addTestSuite('Doctrine\Tests\ORM\EntityPersisterTest');
$suite->addTestSuite('Doctrine\Tests\ORM\CommitOrderCalculatorTest');
$suite->addTest(Query\AllTests::suite());

View File

@ -36,6 +36,10 @@ require_once __DIR__ . '/../../TestInit.php';
*/
class DqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
protected function setUp() {
$this->markTestSkipped('Not yet implemented.');
}
protected function createQuery()
{
return $this->_em->createQuery();

View File

@ -1,74 +0,0 @@
<?php
namespace Doctrine\Tests\ORM;
use Doctrine\Tests\Mocks\ConnectionMock;
use Doctrine\Tests\Mocks\EntityManagerMock;
use Doctrine\Tests\Mocks\UnitOfWorkMock;
use Doctrine\Tests\Mocks\SequenceMock;
use Doctrine\Tests\Models\Forum\ForumUser;
use Doctrine\Tests\Models\Forum\ForumAvatar;
require_once __DIR__ . '/../TestInit.php';
class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
{
private $_connMock;
private $_emMock;
private $_idGenMock;
private $_uowMock;
protected function setUp()
{
parent::setUp();
$this->_connMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
$this->_emMock = EntityManagerMock::create($this->_connMock);
$this->_uowMock = new UnitOfWorkMock($this->_emMock);
$this->_emMock->setUnitOfWork($this->_uowMock);
$this->_idGenMock = new SequenceMock($this->_emMock, 'seq', 20);
//$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $this->_idGenMock);
}
public function testSimpleInsert()
{
$userPersister = new \Doctrine\ORM\Persisters\SingleTablePersister(
$this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser"));
$avatarPersister = new \Doctrine\ORM\Persisters\StandardEntityPersister(
$this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumAvatar"));
$user = new ForumUser();
$user->username = "romanb";
$user->avatar = new ForumAvatar();
$this->_uowMock->setDataChangeSet($user, array(
'username' => array('', 'romanb'),
'avatar' => array('', $user->avatar)));
//insert
$avatarPersister->insert($user->avatar);
$inserts = $this->_connMock->getInserts();
//check
$this->assertEquals(1, count($inserts));
$this->assertTrue(isset($inserts['forum_avatars']));
$this->assertEquals(1, count($inserts['forum_avatars']));
$this->assertEquals(null, $user->avatar->id);
$user->avatar->id = 0; // Fake that we got an id
//insert
$userPersister->insert($user);
$inserts = $this->_connMock->getInserts();
//check
$this->assertEquals(2, count($inserts));
$this->assertEquals(null, $user->id);
$this->assertTrue(isset($inserts['forum_users']));
$this->assertEquals(1, count($inserts['forum_users']));
$this->assertEquals(3, count($inserts['forum_users'][0]));
//username column
$this->assertTrue(isset($inserts['forum_users'][0]['username']));
$this->assertEquals('romanb', $inserts['forum_users'][0]['username']);
//avatar_id join column
$this->assertTrue(isset($inserts['forum_users'][0]['avatar_id']));
$this->assertEquals(0, $inserts['forum_users'][0]['avatar_id']);
}
}

View File

@ -25,6 +25,7 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\ClassTableInheritanceTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\DetachedEntityTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\QueryCacheTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\QueryTest');
return $suite;
}

View File

@ -31,9 +31,9 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear();
$query = $this->_em->createQuery("select u, upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'");
$result = $query->getResultList();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0][0] instanceof CmsUser);
$this->assertEquals('Guilherme', $result[0][0]->name);
@ -54,7 +54,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals('Guilherme', $scalarResult[0]['u_name']);
$this->assertEquals('gblanco', $scalarResult[0]['u_username']);
$this->assertEquals('developer', $scalarResult[0]['u_status']);
$this->assertEquals('GUILHERME', $scalarResult[0]['dctrn_1']);
$this->assertEquals('GUILHERME', $scalarResult[0][1]);
$query = $this->_em->createQuery("select upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'");
$this->assertEquals('GUILHERME', $query->getSingleScalarResult());

View File

@ -7,12 +7,12 @@ use Doctrine\ORM\Query\ResultSetMapping;
require_once __DIR__ . '/../../TestInit.php';
class ArrayHydratorTest extends HydrationTest
class ArrayHydratorTest extends HydrationTestCase
{
/**
* Select u.id, u.name from Doctrine\Tests\Models\CMS\CmsUser u
*/
public function testNewHydrationSimpleEntityQuery()
public function testSimpleEntityQuery()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -48,7 +48,7 @@ class ArrayHydratorTest extends HydrationTest
/**
*
*/
public function testNewHydrationSimpleMultipleRootEntityQuery()
public function testSimpleMultipleRootEntityQuery()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -99,7 +99,7 @@ class ArrayHydratorTest extends HydrationTest
* select u.id, u.status, p.phonenumber, upper(u.name) as u__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
*/
public function testNewHydrationMixedQueryFetchJoin()
public function testMixedQueryFetchJoin()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -166,7 +166,7 @@ class ArrayHydratorTest extends HydrationTest
* select u.id, u.status, count(p.phonenumber) as p__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id group by u.id, u.status
*/
public function testNewHydrationMixedQueryNormalJoin()
public function testMixedQueryNormalJoin()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -211,7 +211,7 @@ class ArrayHydratorTest extends HydrationTest
* select u.id, u.status, upper(u.name) as p__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
*/
public function testNewHydrationMixedQueryFetchJoinCustomIndex()
public function testMixedQueryFetchJoinCustomIndex()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -286,7 +286,7 @@ class ArrayHydratorTest extends HydrationTest
* inner join PHONENUMBERS p ON u.id = p.user_id
* inner join ARTICLES a ON u.id = a.user_id
*/
public function testNewHydrationMixedQueryMultipleFetchJoin()
public function testMixedQueryMultipleFetchJoin()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -405,7 +405,7 @@ class ArrayHydratorTest extends HydrationTest
* inner join ARTICLES a ON u.id = a.user_id
* left outer join COMMENTS c ON a.id = c.article_id
*/
public function testNewHydrationMixedQueryMultipleDeepMixedFetchJoin()
public function testMixedQueryMultipleDeepMixedFetchJoin()
{
$rsm = new ResultSetMapping;
@ -563,7 +563,7 @@ class ArrayHydratorTest extends HydrationTest
* 1 | 0 | First | 1 | 3 | 1
* 1 | 0 | First | 2 | 4 | 1
*/
public function testNewHydrationEntityQueryCustomResultSetOrder()
public function testEntityQueryCustomResultSetOrder()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\Forum\ForumCategory', 'c');

View File

@ -7,7 +7,7 @@ require_once __DIR__ . '/../../TestInit.php';
use Doctrine\ORM\Query\ParserResult;
use Doctrine\ORM\Query\Parser;
class HydrationTest extends \Doctrine\Tests\OrmTestCase
class HydrationTestCase extends \Doctrine\Tests\OrmTestCase
{
protected $_em;

View File

@ -7,12 +7,12 @@ use Doctrine\ORM\Query\ResultSetMapping;
require_once __DIR__ . '/../../TestInit.php';
class ObjectHydratorTest extends HydrationTest
class ObjectHydratorTest extends HydrationTestCase
{
/**
* Select u.id, u.name from \Doctrine\Tests\Models\CMS\CmsUser u
*/
public function testNewHydrationSimpleEntityQuery()
public function testSimpleEntityQuery()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -49,7 +49,7 @@ class ObjectHydratorTest extends HydrationTest
/**
* Select u.id, u.name from \Doctrine\Tests\Models\CMS\CmsUser u
*/
public function testNewHydrationSimpleMultipleRootEntityQuery()
public function testSimpleMultipleRootEntityQuery()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -105,7 +105,7 @@ class ObjectHydratorTest extends HydrationTest
* select u.id, u.status, p.phonenumber, upper(u.name) as u__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
*/
public function testNewHydrationMixedQueryFetchJoin()
public function testMixedQueryFetchJoin()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -179,7 +179,7 @@ class ObjectHydratorTest extends HydrationTest
* select u.id, u.status, count(p.phonenumber) as p__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id group by u.id, u.status
*/
public function testNewHydrationMixedQueryNormalJoin()
public function testMixedQueryNormalJoin()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -226,7 +226,7 @@ class ObjectHydratorTest extends HydrationTest
* select u.id, u.status, upper(u.name) as p__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
*/
public function testNewHydrationMixedQueryFetchJoinCustomIndex()
public function testMixedQueryFetchJoinCustomIndex()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -305,7 +305,7 @@ class ObjectHydratorTest extends HydrationTest
* inner join PHONENUMBERS p ON u.id = p.user_id
* inner join ARTICLES a ON u.id = a.user_id
*/
public function testNewHydrationMixedQueryMultipleFetchJoin()
public function testMixedQueryMultipleFetchJoin()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -420,7 +420,7 @@ class ObjectHydratorTest extends HydrationTest
* inner join ARTICLES a ON u.id = a.user_id
* left outer join COMMENTS c ON a.id = c.article_id
*/
public function testNewHydrationMixedQueryMultipleDeepMixedFetchJoin()
public function testMixedQueryMultipleDeepMixedFetchJoin()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
@ -571,7 +571,7 @@ class ObjectHydratorTest extends HydrationTest
* 1 | 0 | First | 1 | 3 | 1
* 1 | 0 | First | 2 | 4 | 1
*/
public function testNewHydrationEntityQueryCustomResultSetOrder()
public function testEntityQueryCustomResultSetOrder()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\Forum\ForumCategory', 'c');

View File

@ -7,7 +7,7 @@ use Doctrine\ORM\Query\ResultSetMapping;
require_once __DIR__ . '/../../TestInit.php';
class ScalarHydratorTest extends HydrationTest
class ScalarHydratorTest extends HydrationTestCase
{
/**
* Select u.id, u.name from CmsUser u

View File

@ -7,7 +7,7 @@ use Doctrine\ORM\Query\ResultSetMapping;
require_once __DIR__ . '/../../TestInit.php';
class SingleScalarHydratorTest extends HydrationTest
class SingleScalarHydratorTest extends HydrationTestCase
{
/** Result set provider for the HYDRATE_SINGLE_SCALAR tests */
public static function singleScalarResultSetProvider() {

View File

@ -19,7 +19,6 @@ class AllTests
{
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Orm Query');
//$suite->addTestSuite('Doctrine\Tests\ORM\Query\IdentifierRecognitionTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\SelectSqlGenerationTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\LanguageRecognitionTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\LexerTest');

View File

@ -1,130 +0,0 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Tests\ORM\Query;
require_once __DIR__ . '/../../TestInit.php';
/**
* Test case for testing the saving and referencing of query identifiers.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class IdentifierRecognitionTest extends \Doctrine\Tests\OrmTestCase
{
private $_em;
protected function setUp() {
parent::setUp();
$this->_em = $this->_getTestEntityManager();
}
public function testSingleAliasDeclarationIsSupported()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals(null, $decl['map']);
}
public function testSingleAliasDeclarationWithIndexByIsSupported()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('id', $decl['map']);
}
public function testQueryParserSupportsMultipleAliasDeclarations()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.phonenumbers p');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('id', $decl['map']);
$decl = $parserResult->getQueryComponent('p');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertTrue($decl['relation'] instanceof \Doctrine\ORM\Mapping\AssociationMapping);
$this->assertEquals('u', $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals(null, $decl['map']);
}
public function testQueryParserSupportsMultipleAliasDeclarationsWithIndexBy()
{
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.articles a INNER JOIN u.phonenumbers pn INDEX BY pn.phonenumber');
$parserResult = $query->parse();
$decl = $parserResult->getQueryComponent('u');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertEquals(null, $decl['relation']);
$this->assertEquals(null, $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('id', $decl['map']);
$decl = $parserResult->getQueryComponent('a');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertTrue($decl['relation'] instanceof \Doctrine\ORM\Mapping\AssociationMapping);
$this->assertEquals('u', $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals(null, $decl['map']);
$decl = $parserResult->getQueryComponent('pn');
$this->assertTrue($decl['metadata'] instanceof \Doctrine\ORM\Mapping\ClassMetadata);
$this->assertTrue($decl['relation'] instanceof \Doctrine\ORM\Mapping\AssociationMapping);
$this->assertEquals('u', $decl['parent']);
$this->assertEquals(null, $decl['scalar']);
$this->assertEquals('phonenumber', $decl['map']);
}
}

View File

@ -6,7 +6,7 @@ namespace Doctrine\Tests;
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once '../lib/Doctrine/Common/ClassLoader.php';
require_once __DIR__ . '/../../../lib/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader();