Example #1
0
 /**
  * Test the effect of typecast on primary key values and instance pool retrieval.
  */
 public function testObjectInstancePoolTypecasting()
 {
     $reader = new BookReader();
     $reader->setName("Tester");
     $reader->save();
     $readerId = $reader->getId();
     $book = new Book();
     $book->setTitle("BookTest");
     $book->setISBN("TEST");
     $book->save();
     $bookId = $book->getId();
     $opinion = new BookOpinion();
     $opinion->setBookId((string) $bookId);
     $opinion->setReaderId((string) $readerId);
     $opinion->setRating(5);
     $opinion->setRecommendToFriend(false);
     $opinion->save();
     $opinion2 = BookOpinionPeer::retrieveByPK($bookId, $readerId);
     $this->assertSame($opinion, $opinion2, "Expected same object to be retrieved from differently type-casted primary key values.");
 }
 public function testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins()
 {
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     BookOpinionPeer::clearInstancePool();
     BookReaderPeer::clearInstancePool();
     $freud = new Author();
     $freud->setFirstName("Sigmund");
     $freud->setLastName("Freud");
     $freud->save($this->con);
     $publisher = new Publisher();
     $publisher->setName('Psycho Books');
     $publisher->save();
     $book = new Book();
     $book->setAuthor($freud);
     $book->setTitle('Weirdness');
     $book->setIsbn('abc123456');
     $book->setPrice('14.99');
     $book->setPublisher($publisher);
     $book->save();
     $query = BookQuery::create()->filterByTitle('Weirdness')->innerJoinAuthor()->useBookOpinionQuery(null, Criteria::LEFT_JOIN)->leftJoinBookReader()->endUse()->with('Author')->with('BookOpinion')->with('BookReader');
     $books = $query->findOne($this->con);
     $this->assertEquals(0, count($books->getBookOpinions()));
 }