Permalink
Browse files

move tests to SelectSqlGenerationTest

  • Loading branch information...
1 parent 3f8347a commit 08edf3405705fda847dfa3e3151968237d0d8fd4 @FabioBatSilva FabioBatSilva committed Nov 15, 2011
@@ -1,122 +0,0 @@
-<?php
-
-namespace Doctrine\Tests\ORM\Functional\Ticket;
-
-require_once __DIR__ . '/../../../TestInit.php';
-
-/**
- * @group DDC-1474
- */
-class DDC1474Test extends \Doctrine\Tests\OrmFunctionalTestCase
-{
-
- protected function setUp()
- {
- parent::setUp();
-
- try {
- $this->_schemaTool->createSchema(array(
- $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1474Entity'),
- ));
-
- $this->loadFixtures();
- } catch (\Exception $exc) {
-
- }
- }
-
- public function testTicket()
- {
- $query = $this->_em->createQuery('SELECT - e.value AS value, e.id FROM ' . __NAMESPACE__ . '\DDC1474Entity e');
- $this->assertEquals('SELECT -d0_.value AS sclr0, d0_.id AS id1 FROM DDC1474Entity d0_', $query->getSQL());
- $result = $query->getResult();
-
- $this->assertEquals(2, sizeof($result));
-
- $this->assertEquals(1, $result[0]['id']);
- $this->assertEquals(2, $result[1]['id']);
-
- $this->assertEquals(-10, $result[0]['value']);
- $this->assertEquals(20, $result[1]['value']);
-
-
-
-
-
- $query = $this->_em->createQuery('SELECT e.id, + e.value AS value FROM ' . __NAMESPACE__ . '\DDC1474Entity e');
- $this->assertEquals('SELECT d0_.id AS id0, +d0_.value AS sclr1 FROM DDC1474Entity d0_', $query->getSQL());
- $result = $query->getResult();
-
- $this->assertEquals(2, sizeof($result));
-
- $this->assertEquals(1, $result[0]['id']);
- $this->assertEquals(2, $result[1]['id']);
-
- $this->assertEquals(10, $result[0]['value']);
- $this->assertEquals(-20, $result[1]['value']);
- }
-
- public function loadFixtures()
- {
- $e1 = new DDC1474Entity(10);
- $e2 = new DDC1474Entity(-20);
-
- $this->_em->persist($e1);
- $this->_em->persist($e2);
-
- $this->_em->flush();
- }
-
-}
-
-/**
- * @Entity
- */
-class DDC1474Entity
-{
-
- /**
- * @Id
- * @Column(type="integer")
- * @GeneratedValue()
- */
- protected $id;
-
- /**
- * @column(type="float")
- */
- private $value;
-
- /**
- * @param string $float
- */
- public function __construct($float)
- {
- $this->value = $float;
- }
-
- /**
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
-
- /**
- * @return float
- */
- public function getValue()
- {
- return $this->value;
- }
-
- /**
- * @param float $value
- */
- public function setValue($value)
- {
- $this->value = $value;
- }
-
-}
@@ -1301,6 +1301,22 @@ public function testForeignKeyAsPrimaryKeySubselect()
"SELECT d0_.article_id AS article_id0, d0_.title AS title1 FROM DDC117Article d0_ WHERE EXISTS (SELECT d1_.source_id, d1_.target_id FROM DDC117Reference d1_ WHERE d1_.source_id = d0_.article_id)"
);
}
+
+ /**
+ * @group DDC-1474
+ */
+ public function testSelectWithArithmeticExpressionBeforeField()
+ {
+ $this->assertSqlGeneration(
+ 'SELECT - e.value AS value, e.id FROM ' . __NAMESPACE__ . '\DDC1474Entity e',
+ 'SELECT -d0_.value AS sclr0, d0_.id AS id1 FROM DDC1474Entity d0_'
+ );
+
+ $this->assertSqlGeneration(
+ 'SELECT e.id, + e.value AS value FROM ' . __NAMESPACE__ . '\DDC1474Entity e',
+ 'SELECT d0_.id AS id0, +d0_.value AS sclr1 FROM DDC1474Entity d0_'
+ );
+ }
}
@@ -1343,3 +1359,57 @@ class DDC1384Model
*/
protected $aVeryLongIdentifierThatShouldBeShortenedByTheSQLWalker_fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo;
}
+
+
+/**
+ * @Entity
+ */
+class DDC1474Entity
+{
+
+ /**
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue()
+ */
+ protected $id;
+
+ /**
+ * @column(type="float")
+ */
+ private $value;
+
+ /**
+ * @param string $float
+ */
+ public function __construct($float)
+ {
+ $this->value = $float;
+ }
+
+ /**
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @return float
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * @param float $value
+ */
+ public function setValue($value)
+ {
+ $this->value = $value;
+ }
+
+}
+

0 comments on commit 08edf34

Please sign in to comment.