コード例 #1
0
 public function testRelate()
 {
     $author = new NamespacedAuthor();
     $book = new \Foo\Bar\NamespacedBook();
     $book->setNamespacedAuthor($author);
     $book->save();
     $this->assertFalse($book->isNew());
     $this->assertFalse($author->isNew());
     $author = new NamespacedAuthor();
     $book = new \Foo\Bar\NamespacedBook();
     $author->addNamespacedBook($book);
     $author->save();
     $this->assertFalse($book->isNew());
     $this->assertFalse($author->isNew());
     $publisher = new \Baz\NamespacedPublisher();
     $book = new \Foo\Bar\NamespacedBook();
     $book->setNamespacedPublisher($publisher);
     $book->save();
     $this->assertFalse($book->isNew());
     $this->assertFalse($publisher->isNew());
 }
コード例 #2
0
ファイル: NamespaceTest.php プロジェクト: ketheriel/ETVA
 public function testFindWithOneToMany()
 {
     \Foo\Bar\NamespacedBookQuery::create()->deleteAll();
     NamespacedAuthorQuery::create()->deleteAll();
     $author = new NamespacedAuthor();
     $author->setFirstName('Foo');
     $author->setLastName('Bar');
     $book = new \Foo\Bar\NamespacedBook();
     $book->setTitle('asdf');
     $book->setISBN('something');
     $book->setNamespacedAuthor($author);
     $book->save();
     \Foo\Bar\NamespacedBookPeer::clearInstancePool();
     NamespacedAuthorPeer::clearInstancePool();
     $author2 = NamespacedAuthorQuery::create()->joinWith('NamespacedBook')->findPk($author->getId());
     $book2 = $author2->getNamespacedBooks()->getFirst();
     $this->assertEquals($book->getId(), $book2->getId());
 }