public function testGetChildObject() { ConcreteArticleQuery::create()->deleteAll(); ConcreteQuizzQuery::create()->deleteAll(); ConcreteContentQuery::create()->deleteAll(); $content = new ConcreteContent(); $content->save(); $this->assertNull($content->getChildObject()); $article = new ConcreteArticle(); $article->save(); $content = $article->getConcreteContent(); $this->assertEquals($article, $content->getChildObject()); }
public function testDeepCopyConcretInheritance() { $comment1 = new ConcreteComment(); $comment1->setMessage('my-new-comment1'); $concreteArticle = new ConcreteArticle(); $concreteArticle->setBody('TestBody'); $concreteArticle->addConcreteComment($comment1); $concreteArticle->save(); $comment1->save(); $this->assertNotNull($comment1->getId()); $this->assertNotNull($concreteArticle->getId()); $this->assertEquals(1, $concreteArticle->countConcreteComments()); $this->assertEquals($comment1->getConcreteContentId(), $concreteArticle->getId()); $copy = $concreteArticle->copy(true); $this->assertNull($copy->getId()); $this->assertEquals(1, $concreteArticle->countConcreteComments()); $comments = $copy->getConcreteContent()->getConcreteComments(); $this->assertEquals('my-new-comment1', $comments[0]->getMessage()); }
/** * */ public function testCopyConcretInheritance() { $concreteArticle = new ConcreteArticle(); $concreteArticle->setBody('TestBody'); $concreteArticle->save(); $copy = $concreteArticle->copy(); $this->assertNull($copy->getId(), "single PK not autoincremented shouldn't be copied"); }
public function testPostDeleteCopyData() { ConcreteArticleQuery::create()->deleteAll(); ConcreteQuizzQuery::create()->deleteAll(); ConcreteContentQuery::create()->deleteAll(); ConcreteCategoryQuery::create()->deleteAll(); $category = new ConcreteCategory(); $category->setName('main'); $article = new ConcreteArticle(); $article->setConcreteCategory($category); $article->save(); $id = $article->getId(); $article->delete(); $this->assertNull(ConcreteContentQuery::create()->findPk($id), 'delete() removes the parent record as well'); }
public function testSetPkAllowPkInsertIsFalse() { ConcreteContentQuery::create()->deleteAll(); ConcreteArticleQuery::create()->deleteAll(); try { $article = new ConcreteArticle(); $article->setId(4); $article->save(); $this->fail('SetPk fails when allowPkInsert is false'); } catch (PropelException $e) { $this->assertTrue(true, 'SetPk fails when allowPkInsert is false'); } }