public function testReplaceRelation() { AggregateCommentQuery::create()->deleteAll($this->con); AggregatePostQuery::create()->deleteAll($this->con); $post1 = new AggregatePost(); $post1->save($this->con); $post2 = new AggregatePost(); $post2->save($this->con); $comment = new AggregateComment(); $comment->setAggregatePost($post1); $comment->save($this->con); $this->assertEquals(1, $post1->getNbComments()); $this->assertNull($post2->getNbComments()); $comment->setAggregatePost($post2); $comment->save($this->con); $this->assertEquals(0, $post1->getNbComments(), 'Replacing a relation changes the related object aggregate column'); $this->assertEquals(1, $post2->getNbComments(), 'Replacing a relation changes the related object aggregate column'); }
/** * @param PropelPDO $con * @return string */ public function computeNbComments(PropelPDO $con) { $this->countComputeCall++; return parent::computeNbComments($con); }