Ejemplo n.º 1
1
 public function testRefFKGetJoin()
 {
     BookstoreDataPopulator::populate();
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     PublisherPeer::clearInstancePool();
     $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
     $author = AuthorPeer::doSelectOne(new Criteria(), $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');
 }
 public function testToArrayIncludesForeignObjects()
 {
     BookstoreDataPopulator::populate();
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     PublisherPeer::clearInstancePool();
     $c = new Criteria();
     $c->add(BookPeer::TITLE, 'Don Juan');
     $books = BookPeer::doSelectJoinAuthor($c);
     $book = $books[0];
     $arr1 = $book->toArray(BasePeer::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');
     $c = new Criteria();
     $c->add(BookPeer::TITLE, 'Don Juan');
     $books = BookPeer::doSelectJoinAll($c);
     $book = $books[0];
     $arr2 = $book->toArray(BasePeer::TYPE_PHPNAME, null, array(), true);
     $expectedKeys = array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Publisher', 'Author');
     $this->assertEquals($expectedKeys, array_keys($arr2), 'toArray() can return sub arrays for hydrated related objects');
 }
Ejemplo n.º 3
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();
     PublisherPeer::clearInstancePool();
     $pub2 = PublisherPeer::retrieveByPK($pubId);
     $pub2->setName('Penguin');
     $this->assertFalse($pub2->isModified(), "Expect Publisher to be not modified after setting default value second time.");
 }