From 5fe996baf9b6ebde5e9f29fea826cb74fce6c201 Mon Sep 17 00:00:00 2001 From: "Fabio B. Silva" Date: Sun, 25 Sep 2011 12:20:48 -0300 Subject: [PATCH] change tests for DDC-1135 --- lib/Doctrine/ORM/Query/Expr/From.php | 3 ++- .../ORM/Functional/Ticket/DDC1335Test.php | 27 ++++++------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Expr/From.php b/lib/Doctrine/ORM/Query/Expr/From.php index a4ad22c3f..4c0c8175a 100644 --- a/lib/Doctrine/ORM/Query/Expr/From.php +++ b/lib/Doctrine/ORM/Query/Expr/From.php @@ -82,6 +82,7 @@ class From */ public function __toString() { - return $this->_from . ' ' . $this->_alias . ($this->_indexBy ? ' INDEX BY ' . $this->_indexBy : ''); + return $this->_from . ' ' . $this->_alias . + ($this->_indexBy ? ' INDEX BY ' . $this->_indexBy : ''); } } \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index ea7f53842..e12ee9ab7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -14,23 +14,14 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase protected function setUp() { parent::setUp(); - - $classes = array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1135User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1135Phone'), - ); - try { - $this->_schemaTool->dropSchema($classes); - $this->_schemaTool->createSchema($classes); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1135User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1135Phone'), + )); + $this->loadFixture(); } catch(\Exception $e) { - try { - $this->_schemaTool->createSchema($classes); - } catch (Exception $exc) { - $this->fail($exc->getMessage()); - } } - $this->loadFixture(); } @@ -45,7 +36,6 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertArrayHasKey(2, $result); $this->assertArrayHasKey(3, $result); - $dql = 'SELECT u, p FROM '.__NAMESPACE__ . '\DDC1135User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id'; $query = $this->_em->createQuery($dql); $result = $query->getResult(); @@ -84,7 +74,7 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertArrayHasKey(1, $result); $this->assertArrayHasKey(2, $result); $this->assertArrayHasKey(3, $result); - $this->assertEquals('SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1135User u INDEX BY u.id', $dql); + $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1135User u INDEX BY u.id', $dql); } public function testIndexByUnique() @@ -99,7 +89,7 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertArrayHasKey('foo@foo.com', $result); $this->assertArrayHasKey('bar@bar.com', $result); $this->assertArrayHasKey('foobar@foobar.com', $result); - $this->assertEquals('SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1135User u INDEX BY u.email', $dql); + $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1135User u INDEX BY u.email', $dql); } public function testIndexWithJoin() @@ -108,7 +98,6 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase $builder->select('u','p') ->from(__NAMESPACE__ . '\DDC1135User', 'u', 'u.email') ->join('u.phones', 'p', null, null, 'p.id'); - $dql = $builder->getQuery()->getDQL(); $result = $builder->getQuery()->getResult(); @@ -182,7 +171,7 @@ class DDC1135User */ public $phones; - public function __construct($email, $name,array $numbers) + public function __construct($email, $name, array $numbers = array()) { $this->name = $name; $this->email = $email;