Browse files

[Tests] fix tests columns contant removed from Peer

  • Loading branch information...
1 parent e2e7673 commit 80b6b02fc2f1ec0c88466159f8e54a82f0282b84 @jaugustin jaugustin committed Jan 12, 2013
View
40 tests/Propel/Tests/BookstoreTest.php
@@ -27,6 +27,10 @@
use Propel\Tests\Bookstore\Publisher;
use Propel\Tests\Bookstore\PublisherPeer;
use Propel\Tests\Bookstore\PublisherQuery;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
+use Propel\Tests\Bookstore\Map\BookTableMap;
+use Propel\Tests\Bookstore\Map\BookClubListTableMap;
+use Propel\Tests\Bookstore\Map\PublisherTableMap;
use Propel\Tests\Bookstore\Media;
use Propel\Tests\Bookstore\MediaPeer;
use Propel\Tests\Bookstore\MediaQuery;
@@ -174,12 +178,12 @@ public function testScenario()
// --------------------------
$crit = new Criteria();
- $crit->add(BookPeer::TITLE, 'Harry%', Criteria::LIKE);
+ $crit->add(BookTableMap::TITLE, 'Harry%', Criteria::LIKE);
$results = BookPeer::doSelect($crit);
$this->assertEquals(1, count($results));
$crit2 = new Criteria();
- $crit2->add(BookPeer::ISBN, array("0380977427", "0140422161"), Criteria::IN);
+ $crit2->add(BookTableMap::ISBN, array("0380977427", "0140422161"), Criteria::IN);
$results = BookPeer::doSelect($crit2);
$this->assertEquals(2, count($results));
@@ -189,7 +193,7 @@ public function testScenario()
$crit = new Criteria();
$crit->setLimit(2);
$crit->setOffset(1);
- $crit->addAscendingOrderByColumn(BookPeer::TITLE);
+ $crit->addAscendingOrderByColumn(BookTableMap::TITLE);
$results = BookPeer::doSelect($crit);
$this->assertEquals(2, count($results));
@@ -311,17 +315,17 @@ public function testScenario()
// re-fetch books and lists from db to be sure that nothing is cached
$crit = new Criteria();
- $crit->add(BookPeer::ID, $phoenix->getId());
+ $crit->add(BookTableMap::ID, $phoenix->getId());
$phoenix = BookPeer::doSelectOne($crit);
$this->assertNotNull($phoenix, "book 'phoenix' has been re-fetched from db");
$crit = new Criteria();
- $crit->add(BookClubListPeer::ID, $blc1->getId());
+ $crit->add(BookClubListTableMap::ID, $blc1->getId());
$blc1 = BookClubListPeer::doSelectOne($crit);
$this->assertNotNull($blc1, 'BookClubList 1 has been re-fetched from db');
$crit = new Criteria();
- $crit->add(BookClubListPeer::ID, $blc2->getId());
+ $crit->add(BookClubListTableMap::ID, $blc2->getId());
$blc2 = BookClubListPeer::doSelectOne($crit);
$this->assertNotNull($blc2, 'BookClubList 2 has been re-fetched from db');
@@ -344,12 +348,12 @@ public function testScenario()
// Attempting to delete [multi-table] by found pk
$c = new Criteria();
- $c->add(BookPeer::ID, $hp->getId());
+ $c->add(BookTableMap::ID, $hp->getId());
// The only way for cascading to work currently
// is to specify the author_id and publisher_id (i.e. the fkeys
// have to be in the criteria).
- $c->add(AuthorPeer::ID, $hp->getAuthor()->getId());
- $c->add(PublisherPeer::ID, $hp->getPublisher()->getId());
+ $c->add(AuthorTableMap::ID, $hp->getAuthor()->getId());
+ $c->add(PublisherTableMap::ID, $hp->getPublisher()->getId());
$c->setSingleRecord(true);
BookPeer::doDelete($c);
@@ -360,9 +364,9 @@ public function testScenario()
// Attempting to delete books by complex criteria
$c = new Criteria();
- $cn = $c->getNewCriterion(BookPeer::ISBN, "043935806X");
- $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0380977427"));
- $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0140422161"));
+ $cn = $c->getNewCriterion(BookTableMap::ISBN, "043935806X");
+ $cn->addOr($c->getNewCriterion(BookTableMap::ISBN, "0380977427"));
+ $cn->addOr($c->getNewCriterion(BookTableMap::ISBN, "0140422161"));
$c->add($cn);
BookPeer::doDelete($c);
@@ -664,17 +668,17 @@ public function testScenarioUsingQuery()
// re-fetch books and lists from db to be sure that nothing is cached
$crit = new Criteria();
- $crit->add(BookPeer::ID, $phoenix->getId());
+ $crit->add(BookTableMap::ID, $phoenix->getId());
$phoenix = BookPeer::doSelectOne($crit);
$this->assertNotNull($phoenix, "book 'phoenix' has been re-fetched from db");
$crit = new Criteria();
- $crit->add(BookClubListPeer::ID, $blc1->getId());
+ $crit->add(BookClubListTableMap::ID, $blc1->getId());
$blc1 = BookClubListPeer::doSelectOne($crit);
$this->assertNotNull($blc1, 'BookClubList 1 has been re-fetched from db');
$crit = new Criteria();
- $crit->add(BookClubListPeer::ID, $blc2->getId());
+ $crit->add(BookClubListTableMap::ID, $blc2->getId());
$blc2 = BookClubListPeer::doSelectOne($crit);
$this->assertNotNull($blc2, 'BookClubList 2 has been re-fetched from db');
@@ -697,12 +701,12 @@ public function testScenarioUsingQuery()
// Attempting to delete [multi-table] by found pk
$c = new Criteria();
- $c->add(BookPeer::ID, $hp->getId());
+ $c->add(BookTableMap::ID, $hp->getId());
// The only way for cascading to work currently
// is to specify the author_id and publisher_id (i.e. the fkeys
// have to be in the criteria).
- $c->add(AuthorPeer::ID, $hp->getAuthor()->getId());
- $c->add(PublisherPeer::ID, $hp->getPublisher()->getId());
+ $c->add(AuthorTableMap::ID, $hp->getAuthor()->getId());
+ $c->add(PublisherTableMap::ID, $hp->getPublisher()->getId());
$c->setSingleRecord(true);
BookPeer::doDelete($c);
View
174 tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php
@@ -11,11 +11,9 @@
namespace Propel\Tests\Runtime\ActiveQuery;
use Propel\Tests\Helpers\Bookstore\BookstoreTestBase;
-use Propel\Tests\Bookstore\AuthorPeer;
-use Propel\Tests\Bookstore\BookPeer;
use Propel\Tests\Bookstore\Map\AuthorTableMap;
use Propel\Tests\Bookstore\Map\BookTableMap;
-use Propel\Tests\Bookstore\PublisherPeer;
+use Propel\Tests\Bookstore\Map\PublisherTableMap;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Util\BasePeer;
@@ -104,51 +102,51 @@ public function testMergeWithSelectModifiers()
public function testMergeWithSelectColumns()
{
$c1 = new Criteria();
- $c1->addSelectColumn(BookPeer::TITLE);
- $c1->addSelectColumn(BookPeer::ID);
+ $c1->addSelectColumn(BookTableMap::TITLE);
+ $c1->addSelectColumn(BookTableMap::ID);
$c2 = new Criteria();
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getSelectColumns(), 'mergeWith() does not remove an existing select columns');
+ $this->assertEquals(array(BookTableMap::TITLE, BookTableMap::ID), $c1->getSelectColumns(), 'mergeWith() does not remove an existing select columns');
$c1 = new Criteria();
$c2 = new Criteria();
- $c2->addSelectColumn(BookPeer::TITLE);
- $c2->addSelectColumn(BookPeer::ID);
+ $c2->addSelectColumn(BookTableMap::TITLE);
+ $c2->addSelectColumn(BookTableMap::ID);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getSelectColumns(), 'mergeWith() merges the select columns to an empty select');
+ $this->assertEquals(array(BookTableMap::TITLE, BookTableMap::ID), $c1->getSelectColumns(), 'mergeWith() merges the select columns to an empty select');
$c1 = new Criteria();
- $c1->addSelectColumn(BookPeer::TITLE);
+ $c1->addSelectColumn(BookTableMap::TITLE);
$c2 = new Criteria();
- $c2->addSelectColumn(BookPeer::ID);
+ $c2->addSelectColumn(BookTableMap::ID);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getSelectColumns(), 'mergeWith() merges the select columns after the existing select columns');
+ $this->assertEquals(array(BookTableMap::TITLE, BookTableMap::ID), $c1->getSelectColumns(), 'mergeWith() merges the select columns after the existing select columns');
$c1 = new Criteria();
- $c1->addSelectColumn(BookPeer::TITLE);
+ $c1->addSelectColumn(BookTableMap::TITLE);
$c2 = new Criteria();
- $c2->addSelectColumn(BookPeer::TITLE);
+ $c2->addSelectColumn(BookTableMap::TITLE);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE, BookPeer::TITLE), $c1->getSelectColumns(), 'mergeWith() merges the select columns to an existing select, even if duplicated');
+ $this->assertEquals(array(BookTableMap::TITLE, BookTableMap::TITLE), $c1->getSelectColumns(), 'mergeWith() merges the select columns to an existing select, even if duplicated');
}
public function testMergeWithAsColumns()
{
$c1 = new Criteria();
- $c1->addAsColumn('foo', BookPeer::TITLE);
- $c1->addAsColumn('bar', BookPeer::ID);
+ $c1->addAsColumn('foo', BookTableMap::TITLE);
+ $c1->addAsColumn('bar', BookTableMap::ID);
$c2 = new Criteria();
$c1->mergeWith($c2);
- $this->assertEquals(array('foo' => BookPeer::TITLE, 'bar' => BookPeer::ID), $c1->getAsColumns(), 'mergeWith() does not remove an existing as columns');
+ $this->assertEquals(array('foo' => BookTableMap::TITLE, 'bar' => BookTableMap::ID), $c1->getAsColumns(), 'mergeWith() does not remove an existing as columns');
$c1 = new Criteria();
$c2 = new Criteria();
- $c2->addAsColumn('foo', BookPeer::TITLE);
- $c2->addAsColumn('bar', BookPeer::ID);
+ $c2->addAsColumn('foo', BookTableMap::TITLE);
+ $c2->addAsColumn('bar', BookTableMap::ID);
$c1->mergeWith($c2);
- $this->assertEquals(array('foo' => BookPeer::TITLE, 'bar' => BookPeer::ID), $c1->getAsColumns(), 'mergeWith() merges the select columns to an empty as');
+ $this->assertEquals(array('foo' => BookTableMap::TITLE, 'bar' => BookTableMap::ID), $c1->getAsColumns(), 'mergeWith() merges the select columns to an empty as');
$c1 = new Criteria();
- $c1->addAsColumn('foo', BookPeer::TITLE);
+ $c1->addAsColumn('foo', BookTableMap::TITLE);
$c2 = new Criteria();
- $c2->addAsColumn('bar', BookPeer::ID);
+ $c2->addAsColumn('bar', BookTableMap::ID);
$c1->mergeWith($c2);
- $this->assertEquals(array('foo' => BookPeer::TITLE, 'bar' => BookPeer::ID), $c1->getAsColumns(), 'mergeWith() merges the select columns after the existing as columns');
+ $this->assertEquals(array('foo' => BookTableMap::TITLE, 'bar' => BookTableMap::ID), $c1->getAsColumns(), 'mergeWith() merges the select columns after the existing as columns');
}
/**
@@ -157,107 +155,107 @@ public function testMergeWithAsColumns()
public function testMergeWithAsColumnsThrowsException()
{
$c1 = new Criteria();
- $c1->addAsColumn('foo', BookPeer::TITLE);
+ $c1->addAsColumn('foo', BookTableMap::TITLE);
$c2 = new Criteria();
- $c2->addAsColumn('foo', BookPeer::ID);
+ $c2->addAsColumn('foo', BookTableMap::ID);
$c1->mergeWith($c2);
}
public function testMergeWithOrderByColumns()
{
$c1 = new Criteria();
- $c1->addAscendingOrderByColumn(BookPeer::TITLE);
- $c1->addAscendingOrderByColumn(BookPeer::ID);
+ $c1->addAscendingOrderByColumn(BookTableMap::TITLE);
+ $c1->addAscendingOrderByColumn(BookTableMap::ID);
$c2 = new Criteria();
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not remove an existing orderby columns');
+ $this->assertEquals(array(BookTableMap::TITLE . ' ASC', BookTableMap::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not remove an existing orderby columns');
$c1 = new Criteria();
$c2 = new Criteria();
- $c2->addAscendingOrderByColumn(BookPeer::TITLE);
- $c2->addAscendingOrderByColumn(BookPeer::ID);
+ $c2->addAscendingOrderByColumn(BookTableMap::TITLE);
+ $c2->addAscendingOrderByColumn(BookTableMap::ID);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns to an empty order by');
+ $this->assertEquals(array(BookTableMap::TITLE . ' ASC', BookTableMap::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns to an empty order by');
$c1 = new Criteria();
- $c1->addAscendingOrderByColumn(BookPeer::TITLE);
+ $c1->addAscendingOrderByColumn(BookTableMap::TITLE);
$c2 = new Criteria();
- $c2->addAscendingOrderByColumn(BookPeer::ID);
+ $c2->addAscendingOrderByColumn(BookTableMap::ID);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns after the existing orderby columns');
+ $this->assertEquals(array(BookTableMap::TITLE . ' ASC', BookTableMap::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns after the existing orderby columns');
$c1 = new Criteria();
- $c1->addAscendingOrderByColumn(BookPeer::TITLE);
+ $c1->addAscendingOrderByColumn(BookTableMap::TITLE);
$c2 = new Criteria();
- $c2->addAscendingOrderByColumn(BookPeer::TITLE);
+ $c2->addAscendingOrderByColumn(BookTableMap::TITLE);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not merge duplicated orderby columns');
+ $this->assertEquals(array(BookTableMap::TITLE . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not merge duplicated orderby columns');
$c1 = new Criteria();
- $c1->addAscendingOrderByColumn(BookPeer::TITLE);
+ $c1->addAscendingOrderByColumn(BookTableMap::TITLE);
$c2 = new Criteria();
- $c2->addDescendingOrderByColumn(BookPeer::TITLE);
+ $c2->addDescendingOrderByColumn(BookTableMap::TITLE);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::TITLE . ' DESC'), $c1->getOrderByColumns(), 'mergeWith() merges duplicated orderby columns with inverse direction');
+ $this->assertEquals(array(BookTableMap::TITLE . ' ASC', BookTableMap::TITLE . ' DESC'), $c1->getOrderByColumns(), 'mergeWith() merges duplicated orderby columns with inverse direction');
}
public function testMergeWithGroupByColumns()
{
$c1 = new Criteria();
- $c1->addGroupByColumn(BookPeer::TITLE);
- $c1->addGroupByColumn(BookPeer::ID);
+ $c1->addGroupByColumn(BookTableMap::TITLE);
+ $c1->addGroupByColumn(BookTableMap::ID);
$c2 = new Criteria();
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getGroupByColumns(), 'mergeWith() does not remove an existing groupby columns');
+ $this->assertEquals(array(BookTableMap::TITLE, BookTableMap::ID), $c1->getGroupByColumns(), 'mergeWith() does not remove an existing groupby columns');
$c1 = new Criteria();
$c2 = new Criteria();
- $c2->addGroupByColumn(BookPeer::TITLE);
- $c2->addGroupByColumn(BookPeer::ID);
+ $c2->addGroupByColumn(BookTableMap::TITLE);
+ $c2->addGroupByColumn(BookTableMap::ID);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getGroupByColumns(), 'mergeWith() merges the select columns to an empty groupby');
+ $this->assertEquals(array(BookTableMap::TITLE, BookTableMap::ID), $c1->getGroupByColumns(), 'mergeWith() merges the select columns to an empty groupby');
$c1 = new Criteria();
- $c1->addGroupByColumn(BookPeer::TITLE);
+ $c1->addGroupByColumn(BookTableMap::TITLE);
$c2 = new Criteria();
- $c2->addGroupByColumn(BookPeer::ID);
+ $c2->addGroupByColumn(BookTableMap::ID);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getGroupByColumns(), 'mergeWith() merges the select columns after the existing groupby columns');
+ $this->assertEquals(array(BookTableMap::TITLE, BookTableMap::ID), $c1->getGroupByColumns(), 'mergeWith() merges the select columns after the existing groupby columns');
$c1 = new Criteria();
- $c1->addGroupByColumn(BookPeer::TITLE);
+ $c1->addGroupByColumn(BookTableMap::TITLE);
$c2 = new Criteria();
- $c2->addGroupByColumn(BookPeer::TITLE);
+ $c2->addGroupByColumn(BookTableMap::TITLE);
$c1->mergeWith($c2);
- $this->assertEquals(array(BookPeer::TITLE), $c1->getGroupByColumns(), 'mergeWith() does not merge duplicated groupby columns');
+ $this->assertEquals(array(BookTableMap::TITLE), $c1->getGroupByColumns(), 'mergeWith() does not merge duplicated groupby columns');
}
public function testMergeWithWhereConditions()
{
$c1 = new Criteria();
- $c1->add(BookPeer::TITLE, 'foo');
+ $c1->add(BookTableMap::TITLE, 'foo');
$c2 = new Criteria();
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` WHERE book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing where condition');
$c1 = new Criteria();
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'foo');
+ $c2->add(BookTableMap::TITLE, 'foo');
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` WHERE book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to an empty condition');
$c1 = new Criteria();
- $c1->add(BookPeer::ID, 123);
+ $c1->add(BookTableMap::ID, 123);
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'foo');
+ $c2->add(BookTableMap::TITLE, 'foo');
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` WHERE book.ID=:p1 AND book.TITLE=:p2';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions');
$c1 = new Criteria();
- $c1->add(BookPeer::TITLE, 'foo');
+ $c1->add(BookTableMap::TITLE, 'foo');
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'bar');
+ $c2->add(BookTableMap::TITLE, 'bar');
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` WHERE (book.TITLE=:p1 AND book.TITLE=:p2)';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the same column');
$c1 = new Criteria();
- $c1->add(BookPeer::TITLE, 'foo');
- $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN);
+ $c1->add(BookTableMap::TITLE, 'foo');
+ $c1->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::LEFT_JOIN);
$c2 = new Criteria();
- $c2->add(AuthorPeer::FIRST_NAME, 'bar');
+ $c2->add(AuthorTableMap::FIRST_NAME, 'bar');
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` LEFT JOIN `author` ON (book.AUTHOR_ID=author.ID) WHERE book.TITLE=:p1 AND author.FIRST_NAME=:p2';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables');
@@ -266,36 +264,36 @@ public function testMergeWithWhereConditions()
public function testMergeOrWithWhereConditions()
{
$c1 = new Criteria();
- $c1->add(BookPeer::TITLE, 'foo');
+ $c1->add(BookTableMap::TITLE, 'foo');
$c2 = new Criteria();
$c1->mergeWith($c2, Criteria::LOGICAL_OR);
$sql = 'SELECT FROM `book` WHERE book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing where condition');
$c1 = new Criteria();
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'foo');
+ $c2->add(BookTableMap::TITLE, 'foo');
$c1->mergeWith($c2, Criteria::LOGICAL_OR);
$sql = 'SELECT FROM `book` WHERE book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to an empty condition');
$c1 = new Criteria();
- $c1->add(BookPeer::ID, 123);
+ $c1->add(BookTableMap::ID, 123);
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'foo');
+ $c2->add(BookTableMap::TITLE, 'foo');
$c1->mergeWith($c2, Criteria::LOGICAL_OR);
$sql = 'SELECT FROM `book` WHERE (book.ID=:p1 OR book.TITLE=:p2)';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions');
$c1 = new Criteria();
- $c1->add(BookPeer::TITLE, 'foo');
+ $c1->add(BookTableMap::TITLE, 'foo');
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'bar');
+ $c2->add(BookTableMap::TITLE, 'bar');
$c1->mergeWith($c2, Criteria::LOGICAL_OR);
$sql = 'SELECT FROM `book` WHERE (book.TITLE=:p1 OR book.TITLE=:p2)';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the same column');
$c1 = new Criteria();
- $c1->add(BookPeer::TITLE, 'foo');
- $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN);
+ $c1->add(BookTableMap::TITLE, 'foo');
+ $c1->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::LEFT_JOIN);
$c2 = new Criteria();
- $c2->add(AuthorPeer::FIRST_NAME, 'bar');
+ $c2->add(AuthorTableMap::FIRST_NAME, 'bar');
$c1->mergeWith($c2, Criteria::LOGICAL_OR);
$sql = 'SELECT FROM `book` LEFT JOIN `author` ON (book.AUTHOR_ID=author.ID) WHERE (book.TITLE=:p1 OR author.FIRST_NAME=:p2)';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables');
@@ -304,66 +302,66 @@ public function testMergeOrWithWhereConditions()
public function testMerge_OrWithWhereConditions()
{
$c1 = new Criteria();
- $c1->add(BookPeer::TITLE, 'foo');
+ $c1->add(BookTableMap::TITLE, 'foo');
$c2 = new Criteria();
$c1->_or();
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` WHERE book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing where condition');
$c1 = new Criteria();
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'foo');
+ $c2->add(BookTableMap::TITLE, 'foo');
$c1->_or();
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` WHERE book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to an empty condition');
$c1 = new Criteria();
- $c1->add(BookPeer::ID, 123);
+ $c1->add(BookTableMap::ID, 123);
$c1->_or();
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'foo');
+ $c2->add(BookTableMap::TITLE, 'foo');
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` WHERE (book.ID=:p1 OR book.TITLE=:p2)';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions');
$c1 = new Criteria();
- $c1->add(BookPeer::TITLE, 'foo');
+ $c1->add(BookTableMap::TITLE, 'foo');
$c1->_or();
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'bar');
+ $c2->add(BookTableMap::TITLE, 'bar');
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` WHERE (book.TITLE=:p1 OR book.TITLE=:p2)';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the same column');
$c1 = new Criteria();
- $c1->add(BookPeer::TITLE, 'foo');
- $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN);
+ $c1->add(BookTableMap::TITLE, 'foo');
+ $c1->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::LEFT_JOIN);
$c1->_or();
$c2 = new Criteria();
- $c2->add(AuthorPeer::FIRST_NAME, 'bar');
+ $c2->add(AuthorTableMap::FIRST_NAME, 'bar');
$c1->mergeWith($c2);
$sql = 'SELECT FROM `book` LEFT JOIN `author` ON (book.AUTHOR_ID=author.ID) WHERE (book.TITLE=:p1 OR author.FIRST_NAME=:p2)';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables');
}
public function testMergeWithHavingConditions()
{
$c1 = new Criteria();
- $cton = $c1->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL);
+ $cton = $c1->getNewCriterion(BookTableMap::TITLE, 'foo', Criteria::EQUAL);
$c1->addHaving($cton);
$c2 = new Criteria();
$c1->mergeWith($c2);
$sql = 'SELECT FROM HAVING book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing having condition');
$c1 = new Criteria();
$c2 = new Criteria();
- $cton = $c2->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL);
+ $cton = $c2->getNewCriterion(BookTableMap::TITLE, 'foo', Criteria::EQUAL);
$c2->addHaving($cton);
$c1->mergeWith($c2);
$sql = 'SELECT FROM HAVING book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges having condition to an empty having');
$c1 = new Criteria();
- $cton = $c1->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL);
+ $cton = $c1->getNewCriterion(BookTableMap::TITLE, 'foo', Criteria::EQUAL);
$c1->addHaving($cton);
$c2 = new Criteria();
- $cton = $c2->getNewCriterion(BookPeer::TITLE, 'bar', Criteria::EQUAL);
+ $cton = $c2->getNewCriterion(BookTableMap::TITLE, 'bar', Criteria::EQUAL);
$c2->addHaving($cton);
$c1->mergeWith($c2);
$sql = 'SELECT FROM HAVING (book.TITLE=:p1 AND book.TITLE=:p2)';
@@ -405,23 +403,23 @@ public function testMergeWithAliasesThrowsException()
public function testMergeWithJoins()
{
$c1 = new Criteria();
- $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN);
+ $c1->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::LEFT_JOIN);
$c2 = new Criteria();
$c1->mergeWith($c2);
$joins = $c1->getJoins();
$this->assertEquals(1, count($joins), 'mergeWith() does not remove an existing join');
$this->assertEquals('LEFT JOIN author ON (book.AUTHOR_ID=author.ID)', $joins[0]->toString(), 'mergeWith() does not remove an existing join');
$c1 = new Criteria();
$c2 = new Criteria();
- $c2->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN);
+ $c2->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::LEFT_JOIN);
$c1->mergeWith($c2);
$joins = $c1->getJoins();
$this->assertEquals(1, count($joins), 'mergeWith() merge joins to an empty join');
$this->assertEquals('LEFT JOIN author ON (book.AUTHOR_ID=author.ID)', $joins[0]->toString(), 'mergeWith() merge joins to an empty join');
$c1 = new Criteria();
- $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN);
+ $c1->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID, Criteria::LEFT_JOIN);
$c2 = new Criteria();
- $c2->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::INNER_JOIN);
+ $c2->addJoin(BookTableMap::PUBLISHER_ID, PublisherTableMap::ID, Criteria::INNER_JOIN);
$c1->mergeWith($c2);
$joins = $c1->getJoins();
$this->assertEquals(2, count($joins), 'mergeWith() merge joins to an existing join');
View
11 tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php
@@ -12,6 +12,7 @@
use Propel\Tests\Helpers\Bookstore\BookstoreTestBase;
use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\Adapter\Pdo\MysqlAdapter;
@@ -351,7 +352,7 @@ public function testOrderByIgnoreCase()
$criteria = new Criteria();
$criteria->setIgnoreCase(true);
- $criteria->addAscendingOrderByColumn(BookPeer::TITLE);
+ $criteria->addAscendingOrderByColumn(BookTableMap::TITLE);
BookPeer::addSelectColumns($criteria);
$params=array();
$sql = BasePeer::createSelectSql($criteria, $params);
@@ -925,8 +926,8 @@ public function testAliasInCriterion()
public function testHaving()
{
$c = new Criteria();
- $c->addSelectColumn(BookPeer::TITLE);
- $c->addAsColumn('isb_n', BookPeer::ISBN);
+ $c->addSelectColumn(BookTableMap::TITLE);
+ $c->addAsColumn('isb_n', BookTableMap::ISBN);
$crit = $c->getNewCriterion('isb_n', '1234567890123');
$c->addHaving($crit);
$expected = 'SELECT book.TITLE, book.ISBN AS isb_n FROM book HAVING isb_n=:p1';
@@ -941,8 +942,8 @@ public function testHaving()
public function testHavingRaw()
{
$c = new Criteria();
- $c->addSelectColumn(BookPeer::TITLE);
- $c->addAsColumn("isb_n", BookPeer::ISBN);
+ $c->addSelectColumn(BookTableMap::TITLE);
+ $c->addAsColumn("isb_n", BookTableMap::ISBN);
$c->addHaving('isb_n = ?', '1234567890123', \PDO::PARAM_STR);
$expected = 'SELECT book.TITLE, book.ISBN AS isb_n FROM book HAVING isb_n = :p1';
$params = array();
View
4 tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaSelectTest.php
@@ -10,7 +10,7 @@
namespace Propel\Tests\Runtime\ActiveQuery;
-use Propel\Tests\Bookstore\AuthorPeer;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
use Propel\Tests\Bookstore\BookQuery;
use Propel\Tests\Helpers\Bookstore\BookstoreTestBase;
use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator;
@@ -127,7 +127,7 @@ public function testSelectStringFindOne()
$this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'findOne() called after select(string) allows for where() statements');
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author');
- $c->select(AuthorPeer::FIRST_NAME);
+ $c->select(AuthorTableMap::FIRST_NAME);
$author = $c->find($this->con);
$expectedSQL = "SELECT author.FIRST_NAME AS \"author.FIRST_NAME\" FROM `author`";
$this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select(string) accepts model Peer Constants');
View
285 tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php
@@ -18,14 +18,17 @@
use Propel\Tests\Bookstore\AuthorQuery;
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
-use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\BookQuery;
use Propel\Tests\Bookstore\Book2;
use Propel\Tests\Bookstore\Book2Query;
use Propel\Tests\Bookstore\BookstoreEmployeePeer;
use Propel\Tests\Bookstore\Publisher;
use Propel\Tests\Bookstore\PublisherPeer;
use Propel\Tests\Bookstore\ReviewPeer;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
+use Propel\Tests\Bookstore\Map\BookTableMap;
+use Propel\Tests\Bookstore\Map\PublisherTableMap;
+use Propel\Tests\Bookstore\Map\ReviewTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\Collection\Collection;
@@ -510,7 +513,7 @@ public function testMixedCriteria()
{
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->where('Propel\Tests\Bookstore\Book.Title = ?', 'foo');
- $c->add(BookPeer::ID, array(1, 2), Criteria::IN);
+ $c->add(BookTableMap::ID, array(1, 2), Criteria::IN);
if (in_array($this->getDriver(), array('mysql'))) {
$sql = 'SELECT FROM `book` WHERE book.TITLE = :p1 AND book.ID IN (:p2,:p3)';
@@ -677,7 +680,7 @@ public function testOrderBySimpleColumn()
public function testOrderByAlias()
{
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $c->addAsColumn('t', BookPeer::TITLE);
+ $c->addAsColumn('t', BookTableMap::TITLE);
$c->orderBy('t');
$sql = 'SELECT book.TITLE AS t FROM ORDER BY t ASC';
@@ -716,7 +719,7 @@ public function testGroupBySimpleColumn()
public function testGroupByAlias()
{
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $c->addAsColumn('t', BookPeer::TITLE);
+ $c->addAsColumn('t', BookTableMap::TITLE);
$c->groupBy('t');
$sql = 'SELECT book.TITLE AS t FROM GROUP BY t';
@@ -817,8 +820,8 @@ public function testOffset()
public function testAddJoin()
{
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID);
- $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID);
+ $c->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID);
+ $c->addJoin(BookTableMap::PUBLISHER_ID, PublisherTableMap::ID);
$sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.AUTHOR_ID=author.ID) INNER JOIN `publisher` ON (book.PUBLISHER_ID=publisher.ID)';
$params = array();
$this->assertCriteriaTranslation($c, $sql, $params, 'addJoin() works the same as in Criteria');
@@ -1134,7 +1137,7 @@ public function testSetJoinConditionCriterion()
$con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN);
- $criterion = $c->getNewCriterion(BookPeer::TITLE, BookPeer::TITLE . ' = ' . AuthorPeer::FIRST_NAME, Criteria::CUSTOM);
+ $criterion = $c->getNewCriterion(BookTableMap::TITLE, BookTableMap::TITLE . ' = ' . AuthorTableMap::FIRST_NAME, Criteria::CUSTOM);
$c->setJoinCondition('Author', $criterion);
$books = BookPeer::doSelect($c, $con);
$expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` INNER JOIN `author` ON book.TITLE = author.FIRST_NAME";
@@ -1207,17 +1210,17 @@ public function testWithAddsSelectColumns()
$c->join('Propel\Tests\Bookstore\Book.Author');
$c->with('Author');
$expectedColumns = array(
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
- AuthorPeer::ID,
- AuthorPeer::FIRST_NAME,
- AuthorPeer::LAST_NAME,
- AuthorPeer::EMAIL,
- AuthorPeer::AGE
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
+ AuthorTableMap::ID,
+ AuthorTableMap::FIRST_NAME,
+ AuthorTableMap::LAST_NAME,
+ AuthorTableMap::EMAIL,
+ AuthorTableMap::AGE
);
$this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table');
}
@@ -1229,12 +1232,12 @@ public function testWithAliasAddsSelectColumns()
$c->join('Propel\Tests\Bookstore\Book.Author a');
$c->with('a');
$expectedColumns = array(
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
'a.ID',
'a.FIRST_NAME',
'a.LAST_NAME',
@@ -1250,17 +1253,17 @@ public function testWithAddsSelectColumnsOfMainTable()
$c->join('Propel\Tests\Bookstore\Book.Author');
$c->with('Author');
$expectedColumns = array(
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
- AuthorPeer::ID,
- AuthorPeer::FIRST_NAME,
- AuthorPeer::LAST_NAME,
- AuthorPeer::EMAIL,
- AuthorPeer::AGE
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
+ AuthorTableMap::ID,
+ AuthorTableMap::FIRST_NAME,
+ AuthorTableMap::LAST_NAME,
+ AuthorTableMap::EMAIL,
+ AuthorTableMap::AGE
);
$this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the main table if required');
}
@@ -1294,17 +1297,17 @@ public function testWithOneToManyAddsSelectColumns()
$c->leftJoin('Propel\Tests\Bookstore\Author.Book');
$c->with('Book');
$expectedColumns = array(
- AuthorPeer::ID,
- AuthorPeer::FIRST_NAME,
- AuthorPeer::LAST_NAME,
- AuthorPeer::EMAIL,
- AuthorPeer::AGE,
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
+ AuthorTableMap::ID,
+ AuthorTableMap::FIRST_NAME,
+ AuthorTableMap::LAST_NAME,
+ AuthorTableMap::EMAIL,
+ AuthorTableMap::AGE,
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
);
$this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table even in a one-to-many relationship');
}
@@ -1314,17 +1317,17 @@ public function testJoinWith()
$c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->joinWith('Propel\Tests\Bookstore\Book.Author');
$expectedColumns = array(
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
- AuthorPeer::ID,
- AuthorPeer::FIRST_NAME,
- AuthorPeer::LAST_NAME,
- AuthorPeer::EMAIL,
- AuthorPeer::AGE
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
+ AuthorTableMap::ID,
+ AuthorTableMap::FIRST_NAME,
+ AuthorTableMap::LAST_NAME,
+ AuthorTableMap::EMAIL,
+ AuthorTableMap::AGE
);
$this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the join');
$joins = $c->getJoins();
@@ -1346,12 +1349,12 @@ public function testJoinWithAlias()
$c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->joinWith('Propel\Tests\Bookstore\Book.Author a');
$expectedColumns = array(
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
'a.ID',
'a.FIRST_NAME',
'a.LAST_NAME',
@@ -1368,25 +1371,25 @@ public function testJoinWithSeveral()
$c->joinWith('Propel\Tests\Bookstore\Book.Author');
$c->joinWith('Book.Publisher');
$expectedColumns = array(
- ReviewPeer::ID,
- ReviewPeer::REVIEWED_BY,
- ReviewPeer::REVIEW_DATE,
- ReviewPeer::RECOMMENDED,
- ReviewPeer::STATUS,
- ReviewPeer::BOOK_ID,
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
- AuthorPeer::ID,
- AuthorPeer::FIRST_NAME,
- AuthorPeer::LAST_NAME,
- AuthorPeer::EMAIL,
- AuthorPeer::AGE,
- PublisherPeer::ID,
- PublisherPeer::NAME
+ ReviewTableMap::ID,
+ ReviewTableMap::REVIEWED_BY,
+ ReviewTableMap::REVIEW_DATE,
+ ReviewTableMap::RECOMMENDED,
+ ReviewTableMap::STATUS,
+ ReviewTableMap::BOOK_ID,
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
+ AuthorTableMap::ID,
+ AuthorTableMap::FIRST_NAME,
+ AuthorTableMap::LAST_NAME,
+ AuthorTableMap::EMAIL,
+ AuthorTableMap::AGE,
+ PublisherTableMap::ID,
+ PublisherTableMap::NAME
);
$this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the with');
$joins = $c->getJoins();
@@ -1401,23 +1404,23 @@ public function testJoinWithTwice()
$c->joinWith('Propel\Tests\Bookstore\Book.Author');
$c->joinWith('Propel\Tests\Bookstore\Book.Review');
$expectedColumns = array(
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
- AuthorPeer::ID,
- AuthorPeer::FIRST_NAME,
- AuthorPeer::LAST_NAME,
- AuthorPeer::EMAIL,
- AuthorPeer::AGE,
- ReviewPeer::ID,
- ReviewPeer::REVIEWED_BY,
- ReviewPeer::REVIEW_DATE,
- ReviewPeer::RECOMMENDED,
- ReviewPeer::STATUS,
- ReviewPeer::BOOK_ID,
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
+ AuthorTableMap::ID,
+ AuthorTableMap::FIRST_NAME,
+ AuthorTableMap::LAST_NAME,
+ AuthorTableMap::EMAIL,
+ AuthorTableMap::AGE,
+ ReviewTableMap::ID,
+ ReviewTableMap::REVIEWED_BY,
+ ReviewTableMap::REVIEW_DATE,
+ ReviewTableMap::RECOMMENDED,
+ ReviewTableMap::STATUS,
+ ReviewTableMap::BOOK_ID,
);
$this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the with');
$joins = $c->getJoins();
@@ -2271,12 +2274,12 @@ public function testMagicJoinWith()
$c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->leftJoinWith('Propel\Tests\Bookstore\Book.Author a');
$expectedColumns = array(
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
'a.ID',
'a.FIRST_NAME',
'a.LAST_NAME',
@@ -2294,17 +2297,17 @@ public function testMagicJoinWithRelation()
$c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->joinWithAuthor();
$expectedColumns = array(
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
- AuthorPeer::ID,
- AuthorPeer::FIRST_NAME,
- AuthorPeer::LAST_NAME,
- AuthorPeer::EMAIL,
- AuthorPeer::AGE
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
+ AuthorTableMap::ID,
+ AuthorTableMap::FIRST_NAME,
+ AuthorTableMap::LAST_NAME,
+ AuthorTableMap::EMAIL,
+ AuthorTableMap::AGE
);
$this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWithXXX() adds the join with the XXX relation');
$joins = $c->getJoins();
@@ -2317,17 +2320,17 @@ public function testMagicJoinWithTypeAndRelation()
$c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->leftJoinWithAuthor();
$expectedColumns = array(
- BookPeer::ID,
- BookPeer::TITLE,
- BookPeer::ISBN,
- BookPeer::PRICE,
- BookPeer::PUBLISHER_ID,
- BookPeer::AUTHOR_ID,
- AuthorPeer::ID,
- AuthorPeer::FIRST_NAME,
- AuthorPeer::LAST_NAME,
- AuthorPeer::EMAIL,
- AuthorPeer::AGE
+ BookTableMap::ID,
+ BookTableMap::TITLE,
+ BookTableMap::ISBN,
+ BookTableMap::PRICE,
+ BookTableMap::PUBLISHER_ID,
+ BookTableMap::AUTHOR_ID,
+ AuthorTableMap::ID,
+ AuthorTableMap::FIRST_NAME,
+ AuthorTableMap::LAST_NAME,
+ AuthorTableMap::EMAIL,
+ AuthorTableMap::AGE
);
$this->assertEquals($expectedColumns, $c->getSelectColumns(), 'leftJoinWithXXX() adds the join with the XXX relation');
$joins = $c->getJoins();
@@ -2610,40 +2613,40 @@ public function testMergeWithWiths()
public function testGetAliasedColName()
{
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $this->assertEquals(BookPeer::TITLE, $c->getAliasedColName(BookPeer::TITLE), 'getAliasedColName() returns the input when the table has no alias');
+ $this->assertEquals(BookTableMap::TITLE, $c->getAliasedColName(BookTableMap::TITLE), 'getAliasedColName() returns the input when the table has no alias');
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->setModelAlias('foo');
- $this->assertEquals(BookPeer::TITLE, $c->getAliasedColName(BookPeer::TITLE), 'getAliasedColName() returns the input when the table has a query alias');
+ $this->assertEquals(BookTableMap::TITLE, $c->getAliasedColName(BookTableMap::TITLE), 'getAliasedColName() returns the input when the table has a query alias');
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->setModelAlias('foo', true);
- $this->assertEquals('foo.TITLE', $c->getAliasedColName(BookPeer::TITLE), 'getAliasedColName() returns the column name with table alias when the table has a true alias');
+ $this->assertEquals('foo.TITLE', $c->getAliasedColName(BookTableMap::TITLE), 'getAliasedColName() returns the column name with table alias when the table has a true alias');
}
public function testAddUsingAliasNoAlias()
{
$c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $c1->addUsingAlias(BookPeer::TITLE, 'foo');
+ $c1->addUsingAlias(BookTableMap::TITLE, 'foo');
$c2 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $c2->add(BookPeer::TITLE, 'foo');
+ $c2->add(BookTableMap::TITLE, 'foo');
$this->assertEquals($c2, $c1, 'addUsingalias() translates to add() when the table has no alias');
}
public function testAddUsingAliasQueryAlias()
{
$c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b');
- $c1->addUsingAlias(BookPeer::TITLE, 'foo');
+ $c1->addUsingAlias(BookTableMap::TITLE, 'foo');
$c2 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b');
- $c2->add(BookPeer::TITLE, 'foo');
+ $c2->add(BookTableMap::TITLE, 'foo');
$this->assertEquals($c2, $c1, 'addUsingalias() translates the colname using the table alias before calling add() when the table has a true alias');
}
public function testAddUsingAliasTrueAlias()
{
$c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c1->setModelAlias('b', true);
- $c1->addUsingAlias(BookPeer::TITLE, 'foo');
+ $c1->addUsingAlias(BookTableMap::TITLE, 'foo');
$c2 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c2->setModelAlias('b', true);
$c2->add('b.TITLE', 'foo');
@@ -2653,20 +2656,20 @@ public function testAddUsingAliasTrueAlias()
public function testAddUsingAliasTwice()
{
$c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $c1->addUsingAlias(BookPeer::TITLE, 'foo');
- $c1->addUsingAlias(BookPeer::TITLE, 'bar');
+ $c1->addUsingAlias(BookTableMap::TITLE, 'foo');
+ $c1->addUsingAlias(BookTableMap::TITLE, 'bar');
$c2 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $c2->add(BookPeer::TITLE, 'foo');
- $c2->addAnd(BookPeer::TITLE, 'bar');
+ $c2->add(BookTableMap::TITLE, 'foo');
+ $c2->addAnd(BookTableMap::TITLE, 'bar');
$this->assertEquals($c2, $c1, 'addUsingalias() translates to addAnd() when the table already has a condition on the column');
}
public function testAddUsingAliasTrueAliasTwice()
{
$c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c1->setModelAlias('b', true);
- $c1->addUsingAlias(BookPeer::TITLE, 'foo');
- $c1->addUsingAlias(BookPeer::TITLE, 'bar');
+ $c1->addUsingAlias(BookTableMap::TITLE, 'foo');
+ $c1->addUsingAlias(BookTableMap::TITLE, 'bar');
$c2 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c2->setModelAlias('b', true);
$c2->add('b.TITLE', 'foo');
View
18 tests/Propel/Tests/Runtime/ActiveQuery/ModelJoinTest.php
@@ -12,10 +12,12 @@
use Propel\Tests\Helpers\Bookstore\BookstoreTestBase;
-use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\BookPeer;
-use Propel\Tests\Bookstore\BookOpinionPeer;
use Propel\Tests\Bookstore\ReaderFavoritePeer;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
+use Propel\Tests\Bookstore\Map\BookTableMap;
+use Propel\Tests\Bookstore\Map\BookOpinionTableMap;
+use Propel\Tests\Bookstore\Map\ReaderFavoriteTableMap;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Map\TableMap;
@@ -56,8 +58,8 @@ public function testSetRelationMapDefinesJoinColumns()
$join = new ModelJoin();
$join->setTableMap($bookTable);
$join->setRelationMap($bookTable->getRelation('Author'));
- $this->assertEquals(array(BookPeer::AUTHOR_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns');
- $this->assertEquals(array(AuthorPeer::ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns');
+ $this->assertEquals(array(BookTableMap::AUTHOR_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns');
+ $this->assertEquals(array(AuthorTableMap::ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns');
}
public function testSetRelationMapLeftAlias()
@@ -67,7 +69,7 @@ public function testSetRelationMapLeftAlias()
$join->setTableMap($bookTable);
$join->setRelationMap($bookTable->getRelation('Author'), 'b');
$this->assertEquals(array('b.AUTHOR_ID'), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns using the left table alias');
- $this->assertEquals(array(AuthorPeer::ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns');
+ $this->assertEquals(array(AuthorTableMap::ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns');
}
public function testSetRelationMapRightAlias()
@@ -76,7 +78,7 @@ public function testSetRelationMapRightAlias()
$join = new ModelJoin();
$join->setTableMap($bookTable);
$join->setRelationMap($bookTable->getRelation('Author'), null, 'a');
- $this->assertEquals(array(BookPeer::AUTHOR_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns');
+ $this->assertEquals(array(BookTableMap::AUTHOR_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns');
$this->assertEquals(array('a.ID'), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns using the right table alias');
}
@@ -86,8 +88,8 @@ public function testSetRelationMapComposite()
$join = new ModelJoin();
$join->setTableMap($table);
$join->setRelationMap($table->getRelation('BookOpinion'));
- $this->assertEquals(array(ReaderFavoritePeer::BOOK_ID, ReaderFavoritePeer::READER_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns for composite relationships');
- $this->assertEquals(array(BookOpinionPeer::BOOK_ID, BookOpinionPeer::READER_ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns for composite relationships');
+ $this->assertEquals(array(ReaderFavoriteTableMap::BOOK_ID, ReaderFavoriteTableMap::READER_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns for composite relationships');
+ $this->assertEquals(array(BookOpinionTableMap::BOOK_ID, BookOpinionTableMap::READER_ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns for composite relationships');
}
}
View
44 tests/Propel/Tests/Runtime/Adapter/DBAdapterTest.php
@@ -28,62 +28,62 @@ public function testTurnSelectColumnsToAliases()
{
$db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
$c1 = new Criteria();
- $c1->addSelectColumn(BookPeer::ID);
+ $c1->addSelectColumn(BookTableMap::ID);
$db->turnSelectColumnsToAliases($c1);
$c2 = new Criteria();
- $c2->addAsColumn('book_ID', BookPeer::ID);
+ $c2->addAsColumn('book_ID', BookTableMap::ID);
$this->assertTrue($c1->equals($c2));
}
public function testTurnSelectColumnsToAliasesPreservesAliases()
{
$db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
$c1 = new Criteria();
- $c1->addSelectColumn(BookPeer::ID);
- $c1->addAsColumn('foo', BookPeer::TITLE);
+ $c1->addSelectColumn(BookTableMap::ID);
+ $c1->addAsColumn('foo', BookTableMap::TITLE);
$db->turnSelectColumnsToAliases($c1);
$c2 = new Criteria();
- $c2->addAsColumn('book_ID', BookPeer::ID);
- $c2->addAsColumn('foo', BookPeer::TITLE);
+ $c2->addAsColumn('book_ID', BookTableMap::ID);
+ $c2->addAsColumn('foo', BookTableMap::TITLE);
$this->assertTrue($c1->equals($c2));
}
public function testTurnSelectColumnsToAliasesExisting()
{
$db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
$c1 = new Criteria();
- $c1->addSelectColumn(BookPeer::ID);
- $c1->addAsColumn('book_ID', BookPeer::ID);
+ $c1->addSelectColumn(BookTableMap::ID);
+ $c1->addAsColumn('book_ID', BookTableMap::ID);
$db->turnSelectColumnsToAliases($c1);
$c2 = new Criteria();
- $c2->addAsColumn('book_ID_1', BookPeer::ID);
- $c2->addAsColumn('book_ID', BookPeer::ID);
+ $c2->addAsColumn('book_ID_1', BookTableMap::ID);
+ $c2->addAsColumn('book_ID', BookTableMap::ID);
$this->assertTrue($c1->equals($c2));
}
public function testTurnSelectColumnsToAliasesDuplicate()
{
$db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
$c1 = new Criteria();
- $c1->addSelectColumn(BookPeer::ID);
- $c1->addSelectColumn(BookPeer::ID);
+ $c1->addSelectColumn(BookTableMap::ID);
+ $c1->addSelectColumn(BookTableMap::ID);
$db->turnSelectColumnsToAliases($c1);
$c2 = new Criteria();
- $c2->addAsColumn('book_ID', BookPeer::ID);
- $c2->addAsColumn('book_ID_1', BookPeer::ID);
+ $c2->addAsColumn('book_ID', BookTableMap::ID);
+ $c2->addAsColumn('book_ID_1', BookTableMap::ID);
$this->assertTrue($c1->equals($c2));
}
public function testCreateSelectSqlPart()
{
$db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
$c = new Criteria();
- $c->addSelectColumn(BookPeer::ID);
- $c->addAsColumn('book_ID', BookPeer::ID);
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addAsColumn('book_ID', BookTableMap::ID);
$fromClause = array();
$selectSql = $db->createSelectSqlPart($c, $fromClause);
$this->assertEquals('SELECT book.ID, book.ID AS book_ID', $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns');
@@ -94,8 +94,8 @@ public function testCreateSelectSqlPartWithFnc()
{
$db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
$c = new Criteria();
- $c->addSelectColumn(BookPeer::ID);
- $c->addAsColumn('book_ID', 'IF(1, '.BookPeer::ID.', '.BookPeer::TITLE.')');
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addAsColumn('book_ID', 'IF(1, '.BookTableMap::ID.', '.BookTableMap::TITLE.')');
$fromClause = array();
$selectSql = $db->createSelectSqlPart($c, $fromClause);
$this->assertEquals('SELECT book.ID, IF(1, book.ID, book.TITLE) AS book_ID', $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns');
@@ -106,8 +106,8 @@ public function testCreateSelectSqlPartSelectModifier()
{
$db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
$c = new Criteria();
- $c->addSelectColumn(BookPeer::ID);
- $c->addAsColumn('book_ID', BookPeer::ID);
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addAsColumn('book_ID', BookTableMap::ID);
$c->setDistinct();
$fromClause = array();
$selectSql = $db->createSelectSqlPart($c, $fromClause);
@@ -119,8 +119,8 @@ public function testCreateSelectSqlPartAliasAll()
{
$db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
$c = new Criteria();
- $c->addSelectColumn(BookPeer::ID);
- $c->addAsColumn('book_ID', BookPeer::ID);
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addAsColumn('book_ID', BookTableMap::ID);
$fromClause = array();
$selectSql = $db->createSelectSqlPart($c, $fromClause, true);
$this->assertEquals('SELECT book.ID AS book_ID_1, book.ID AS book_ID', $selectSql, 'createSelectSqlPart() aliases all columns if passed true as last parameter');
View
8 tests/Propel/Tests/Runtime/Adapter/Pdo/OracleAdapterTest.php
@@ -18,6 +18,8 @@
use Propel\Tests\Helpers\Bookstore\BookstoreTestBase;
use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
+use Propel\Tests\Bookstore\Map\BookTableMap;
/**
* Tests the DbOracle adapter
@@ -59,7 +61,7 @@ public function testApplyLimitDuplicateColumnNameWithColumn()
$c->setDbName('oracle');
BookPeer::addSelectColumns($c);
AuthorPeer::addSelectColumns($c);
- $c->addAsColumn('BOOK_PRICE', BookPeer::PRICE);
+ $c->addAsColumn('BOOK_PRICE', BookTableMap::PRICE);
$c->setLimit(1);
$params = array();
$asColumns = $c->getAsColumns();
@@ -73,8 +75,8 @@ public function testCreateSelectSqlPart()
Propel::getServiceContainer()->setAdapter('oracle', new OracleAdapter());
$db = Propel::getServiceContainer()->getAdapter();
$c = new Criteria();
- $c->addSelectColumn(BookPeer::ID);
- $c->addAsColumn('book_ID', BookPeer::ID);
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addAsColumn('book_ID', BookTableMap::ID);
$fromClause = array();
$selectSql = $db->createSelectSqlPart($c, $fromClause);
$this->assertEquals('SELECT book.ID, book.ID AS book_ID', $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns');
View
9 tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php
@@ -15,6 +15,7 @@
use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Runtime\Propel;
@@ -315,7 +316,7 @@ public function testLatestQueryMoreThanTenArgs()
{
$con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new Criteria();
- $c->add(BookPeer::ID, array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), Criteria::IN);
+ $c->add(BookTableMap::ID, array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), Criteria::IN);
$books = BookPeer::doSelect($c, $con);
$expected = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.ID IN (1,1,1,1,1,1,1,1,1,1,1,1)";
$this->assertEquals($expected, $con->getLastExecutedQuery(), 'PropelPDO correctly replaces arguments in queries');
@@ -344,7 +345,7 @@ public function testDebugLatestQuery()
{
$con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new Criteria();
- $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE);
+ $c->add(BookTableMap::TITLE, 'Harry%s', Criteria::LIKE);
$con->useDebug(false);
$this->assertEquals('', $con->getLastExecutedQuery(), 'PropelPDO reinitializes the latest query when debug is set to false');
@@ -387,7 +388,7 @@ public function testDebugQueryCount()
{
$con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
$c = new Criteria();
- $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE);
+ $c->add(BookTableMap::TITLE, 'Harry%s', Criteria::LIKE);
$con->useDebug(false);
$this->assertEquals(0, $con->getQueryCount(), 'PropelPDO does not update the query count when useLogging is false');
@@ -469,7 +470,7 @@ public function testDebugLog()
$con->beginTransaction();
$c = new Criteria();
- $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE);
+ $c->add(BookTableMap::TITLE, 'Harry%s', Criteria::LIKE);
$books = BookPeer::doSelect($c, $con);
$latestExecutedQuery = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE LIKE 'Harry%s'";
View
13 tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php
@@ -19,10 +19,11 @@
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
use Propel\Tests\Bookstore\BookQuery;
-use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\BookstoreEmployeePeer;
use Propel\Tests\Bookstore\Essay;
use Propel\Tests\Bookstore\EssayPeer;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
+use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\Review;
use Propel\Tests\Bookstore\ReviewPeer;
@@ -262,7 +263,7 @@ public function testFindOneWithOneToManyAndLimit()
{
$c = new ModelCriteria('bookstore', '\Propel\Tests\Bookstore\Book');
$c->setFormatter(ModelCriteria::FORMAT_ARRAY);
- $c->add(BookPeer::ISBN, '043935806X');
+ $c->add(BookTableMap::ISBN, '043935806X');
$c->leftJoin('Propel\Tests\Bookstore\Book.Review');
$c->with('Review');
$c->limit(5);
@@ -277,7 +278,7 @@ public function testFindOneWithOneToMany()
ReviewPeer::clearInstancePool();
$c = new ModelCriteria('bookstore', '\Propel\Tests\Bookstore\Book');
$c->setFormatter(ModelCriteria::FORMAT_ARRAY);
- $c->add(BookPeer::ISBN, '043935806X');
+ $c->add(BookTableMap::ISBN, '043935806X');
$c->leftJoin('Propel\Tests\Bookstore\Book.Review');
$c->with('Review');
$con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
@@ -331,7 +332,7 @@ public function testFindOneWithOneToManyThenManyToOne()
AuthorPeer::clearInstancePool();
ReviewPeer::clearInstancePool();
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author');
- $c->add(AuthorPeer::LAST_NAME, 'Rowling');
+ $c->add(AuthorTableMap::LAST_NAME, 'Rowling');
$c->leftJoinWith('Propel\Tests\Bookstore\Author.Book');
$c->leftJoinWith('Book.Review');
$c->setFormatter(ModelCriteria::FORMAT_ARRAY);
@@ -355,7 +356,7 @@ public function testFindOneWithOneToManyThenManyToOneUsingAlias()
AuthorPeer::clearInstancePool();
ReviewPeer::clearInstancePool();
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author');
- $c->add(AuthorPeer::LAST_NAME, 'Rowling');
+ $c->add(AuthorTableMap::LAST_NAME, 'Rowling');
$c->leftJoinWith('Propel\Tests\Bookstore\Author.Book b');
$c->leftJoinWith('b.Review r');
$c->setFormatter(ModelCriteria::FORMAT_ARRAY);
@@ -383,7 +384,7 @@ public function testFindWithLeftJoinWithOneToManyAndNullObject()
$freud->save($this->con);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author');
$c->setFormatter(ModelCriteria::FORMAT_ARRAY);
- $c->add(AuthorPeer::LAST_NAME, 'Freud');
+ $c->add(AuthorTableMap::LAST_NAME, 'Freud');
$c->leftJoinWith('Propel\Tests\Bookstore\Author.Book');
$c->leftJoinWith('Book.Review');
// should not raise a notice
View
15 tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php
@@ -16,10 +16,8 @@
use Propel\Tests\Bookstore\Author;
use Propel\Tests\Bookstore\AuthorPeer;
use Propel\Tests\Bookstore\AuthorQuery;
-use Propel\Tests\Bookstore\Map\AuthorTableMap;
use Propel\Tests\Bookstore\Book;
use Propel\Tests\Bookstore\BookPeer;
-use Propel\Tests\Bookstore\Map\BookTableMap;
use Propel\Tests\Bookstore\BookQuery;
use Propel\Tests\Bookstore\BookstoreEmployee;
use Propel\Tests\Bookstore\BookstoreEmployeePeer;
@@ -32,6 +30,9 @@
use Propel\Tests\Bookstore\Publisher;
use Propel\Tests\Bookstore\Review;
use Propel\Tests\Bookstore\ReviewPeer;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
+use Propel\Tests\Bookstore\Map\BookTableMap;
+use Propel\Tests\Bookstore\Map\BookOpinionTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
@@ -313,7 +314,7 @@ public function testFindOneWithDistantClassRenamedRelation()
public function testFindOneWithOneToManyAndLimit()
{
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $c->add(BookPeer::ISBN, '043935806X');
+ $c->add(BookTableMap::ISBN, '043935806X');
$c->leftJoin('Book.Review');
$c->with('Review');
$c->limit(5);
@@ -327,7 +328,7 @@ public function testFindOneWithOneToMany()
AuthorPeer::clearInstancePool();
ReviewPeer::clearInstancePool();
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
- $c->add(BookPeer::ISBN, '043935806X');
+ $c->add(BookTableMap::ISBN, '043935806X');
$c->leftJoin('Propel\Tests\Bookstore\Book.Review');
$c->with('Review');
$con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
@@ -384,7 +385,7 @@ public function testFindOneWithOneToManyThenManyToOne()
AuthorPeer::clearInstancePool();
ReviewPeer::clearInstancePool();
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author');
- $c->add(AuthorPeer::LAST_NAME, 'Rowling');
+ $c->add(AuthorTableMap::LAST_NAME, 'Rowling');
$c->leftJoinWith('Propel\Tests\Bookstore\Author.Book');
$c->leftJoinWith('Book.Review');
$con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
@@ -413,7 +414,7 @@ public function testFindWithLeftJoinWithOneToManyAndNullObject()
$freud->setLastName("Freud");
$freud->save($this->con);
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author');
- $c->add(AuthorPeer::LAST_NAME, 'Freud');
+ $c->add(AuthorTableMap::LAST_NAME, 'Freud');
$c->leftJoinWith('Propel\Tests\Bookstore\Author.Book');
$c->leftJoinWith('Book.Review');
// should not raise a notice
@@ -478,7 +479,7 @@ public function testFindOneWithOneToManyThenManyToOneUsingAlias()
AuthorPeer::clearInstancePool();
ReviewPeer::clearInstancePool();
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author');
- $c->add(AuthorPeer::LAST_NAME, 'Rowling');
+ $c->add(AuthorTableMap::LAST_NAME, 'Rowling');
$c->leftJoinWith('Propel\Tests\Bookstore\Author.Book b');
$c->leftJoinWith('b.Review r');
$con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
View
2 tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php
@@ -259,7 +259,7 @@ public function testFindOneWithOneToMany()
ReviewPeer::clearInstancePool();
$c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
$c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
- $c->add(BookPeer::ISBN, '043935806X');
+ $c->add(BookTableMap::ISBN, '043935806X');
$c->leftJoin('Propel\Tests\Bookstore\Book.Review');
$c->with('Review');
$books = $c->find();
View
12 tests/Propel/Tests/Runtime/Util/BasePeerExceptionsTest.php
@@ -30,7 +30,7 @@ public function testDoSelect()
{
try {
$c = new Criteria();
- $c->add(BookPeer::ID, 12, ' BAD SQL');
+ $c->add(BookTableMap::ID, 12, ' BAD SQL');
BookPeer::addSelectColumns($c);
BasePeer::doSelect($c);
} catch (RuntimeException $e) {
@@ -42,7 +42,7 @@ public function testDoCount()
{
try {
$c = new Criteria();
- $c->add(BookPeer::ID, 12, ' BAD SQL');
+ $c->add(BookTableMap::ID, 12, ' BAD SQL');
BookPeer::addSelectColumns($c);
BasePeer::doCount($c);
} catch (RuntimeException $e) {
@@ -55,7 +55,7 @@ public function testDoDelete()
try {
$c = new Criteria();
$c->setPrimaryTableName(BookTableMap::TABLE_NAME);
- $c->add(BookPeer::ID, 12, ' BAD SQL');
+ $c->add(BookTableMap::ID, 12, ' BAD SQL');
BasePeer::doDelete($c, Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME));
} catch (RuntimeException $e) {
$this->assertContains('[DELETE FROM `book` WHERE book.ID BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message');
@@ -76,9 +76,9 @@ public function testDoUpdate()
try {
$c1 = new Criteria();
$c1->setPrimaryTableName(BookTableMap::TABLE_NAME);
- $c1->add(BookPeer::ID, 12, ' BAD SQL');
+ $c1->add(BookTableMap::ID, 12, ' BAD SQL');
$c2 = new Criteria();
- $c2->add(BookPeer::TITLE, 'Foo');
+ $c2->add(BookTableMap::TITLE, 'Foo');
BasePeer::doUpdate($c1, $c2, Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME));
} catch (RuntimeException $e) {
$this->assertContains('[UPDATE `book` SET `TITLE`=:p1 WHERE book.ID BAD SQL:p2]', $e->getMessage(), 'SQL query is written in the exception message');
@@ -90,7 +90,7 @@ public function testDoInsert()
try {
$c = new Criteria();
$c->setPrimaryTableName(BookTableMap::TABLE_NAME);
- $c->add(BookPeer::AUTHOR_ID, 'lkhlkhj');
+ $c->add(BookTableMap::AUTHOR_ID, 'lkhlkhj');
BasePeer::doInsert($c, Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME));
} catch (RuntimeException $e) {
$this->assertContains('[INSERT INTO `book` (`AUTHOR_ID`) VALUES (:p1)]', $e->getMessage(), 'SQL query is written in the exception message');
View
88 tests/Propel/Tests/Runtime/Util/BasePeerTest.php
@@ -15,7 +15,9 @@
use Propel\Tests\Bookstore\BookPeer;
use Propel\Tests\Bookstore\Bookstore;
use Propel\Tests\Bookstore\BookstorePeer;
+use Propel\Tests\Bookstore\Map\AuthorTableMap;
use Propel\Tests\Bookstore\Map\BookTableMap;
+use Propel\Tests\Bookstore\Map\BookstoreTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Exception\PropelException;
@@ -40,7 +42,7 @@ public function testMultipleFunctionInCriteria()
$c = new Criteria();
$c->setDistinct();
if ($db instanceof PgsqlAdapter) {
- $c->addSelectColumn("substring(".BookPeer::TITLE." from position('Potter' in ".BookPeer::TITLE.")) AS col");
+ $c->addSelectColumn("substring(".BookTableMap::TITLE." from position('Potter' in ".BookTableMap::TITLE.")) AS col");
} else {
$this->markTestSkipped('Configured database vendor is not PostgreSQL');
}
@@ -56,27 +58,27 @@ public function testNeedsSelectAliases()
$this->assertFalse(BasePeer::needsSelectAliases($c), 'Empty Criterias don\'t need aliases');
$c = new Criteria();
- $c->addSelectColumn(BookPeer::ID);
- $c->addSelectColumn(BookPeer::TITLE);
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addSelectColumn(BookTableMap::TITLE);
$this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with distinct column names don\'t need aliases');
$c = new Criteria();
BookPeer::addSelectColumns($c);
$this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with only the columns of a model don\'t need aliases');
$c = new Criteria();
- $c->addSelectColumn(BookPeer::ID);
- $c->addSelectColumn(AuthorPeer::ID);
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addSelectColumn(AuthorTableMap::ID);
$this->assertTrue(BasePeer::needsSelectAliases($c), 'Criterias with common column names do need aliases');
}
public function testDoCountDuplicateColumnName()
{
$con = Propel::getServiceContainer()->getReadConnection(BookTableMap::DATABASE_NAME);
$c = new Criteria();
- $c->addSelectColumn(BookPeer::ID);
- $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID);
- $c->addSelectColumn(AuthorPeer::ID);
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID);
+ $c->addSelectColumn(AuthorTableMap::ID);
$c->setLimit(3);
try {
$count = BasePeer::doCount($c, $con);
@@ -104,8 +106,8 @@ public function testBigIntIgnoreCaseOrderBy()
$c = new Criteria();
$c->setIgnoreCase(true);
- $c->add(BookstorePeer::STORE_NAME, 'SortTest%', Criteria::LIKE);
- $c->addAscendingOrderByColumn(BookstorePeer::POPULATION_SERVED);
+ $c->add(BookstoreTableMap::STORE_NAME, 'SortTest%', Criteria::LIKE);
+ $c->addAscendingOrderByColumn(BookstoreTableMap::POPULATION_SERVED);
$rows = BookstorePeer::doSelect($c);
$this->assertEquals('SortTest2', $rows[0]->getStoreName());
@@ -121,11 +123,11 @@ public function testMixedJoinOrder()
{
$this->markTestSkipped('Famous cross join problem, to be solved one day');
$c = new Criteria(BookTableMap::DATABASE_NAME);
- $c->addSelectColumn(BookPeer::ID);
- $c->addSelectColumn(BookPeer::TITLE);
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addSelectColumn(BookTableMap::TITLE);
- $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN);
- $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID);
+ $c->addJoin(BookTableMap::PUBLISHER_ID, PublisherTableMap::ID, Criteria::LEFT_JOIN);
+ $c->addJoin(BookTableMap::AUTHOR_ID, AuthorTableMap::ID);
$params = array();
$sql = BasePeer::createSelectSql($c, $params);
@@ -142,12 +144,12 @@ public function testMssqlApplyLimitNoOffset()
}
$c = new Criteria(BookTableMap::DATABASE_NAME);
- $c->addSelectColumn(BookPeer::ID);
- $c->addSelectColumn(BookPeer::TITLE);
- $c->addSelectColumn(PublisherPeer::NAME);
+ $c->addSelectColumn(BookTableMap::ID);
+ $c->addSelectColumn(BookTableMap::TITLE);
+ $c->addSelectColumn(PublisherTableMap::NAME);
$c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID)');
- $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN);
+ $c->addJoin(BookTableMap::PUBLISHER_ID, PublisherTableMap::ID, Criteria::LEFT_JOIN);
$c->setOffset(0);
$c->setLimit(20);