public function testToArrayIncludesForeignObjects()
 {
     BookstoreDataPopulator::populate();
     BookTableMap::clearInstancePool();
     AuthorTableMap::clearInstancePool();
     PublisherTableMap::clearInstancePool();
     $c = new Criteria();
     $c->add(BookTableMap::COL_TITLE, 'Don Juan');
     $books = BookQuery::create(null, $c)->joinWith('Author')->find();
     $book = $books[0];
     $arr1 = $book->toArray(TableMap::TYPE_PHPNAME, null, array(), true);
     $expectedKeys = array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Author');
     $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() can return sub arrays for hydrated related objects');
     $this->assertEquals('George', $arr1['Author']['FirstName'], 'toArray() can return sub arrays for hydrated related objects');
 }
Example #2
0
 /**
  * Test isModified() to be false after setting default value second time
  */
 public function testDefaultValueSetTwice()
 {
     $pub = new Publisher();
     $pub->setName('Penguin');
     $pub->save();
     $pubId = $pub->getId();
     PublisherTableMap::clearInstancePool();
     $pub2 = PublisherQuery::create()->findPk($pubId);
     $pub2->setName('Penguin');
     $this->assertFalse($pub2->isModified(), "Expect Publisher to be not modified after setting default value second time.");
 }
 public function testRefFKGetJoin()
 {
     BookstoreDataPopulator::populate();
     BookTableMap::clearInstancePool();
     AuthorTableMap::clearInstancePool();
     PublisherTableMap::clearInstancePool();
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     $author = AuthorQuery::create()->findOne($con);
     // populate book instance pool
     $books = $author->getBooksJoinPublisher(null, $con);
     $sql = $con->getLastExecutedQuery();
     $publisher = $books[0]->getPublisher($con);
     $this->assertEquals($sql, $con->getLastExecutedQuery(), 'refFK getter uses instance pool if possible');
 }