コード例 #1
0
 public function testCompute()
 {
     AggregateCommentQuery::create()->deleteAll($this->con);
     AggregatePostQuery::create()->deleteAll($this->con);
     $post = new AggregatePost();
     $post->save($this->con);
     $this->assertEquals(0, $post->computeNbComments($this->con), 'The compute method returns 0 for objects with no related objects');
     $comment1 = new AggregateComment();
     $comment1->setAggregatePost($post);
     $comment1->save($this->con);
     $this->assertEquals(1, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects');
     $comment2 = new AggregateComment();
     $comment2->setAggregatePost($post);
     $comment2->save($this->con);
     $this->assertEquals(2, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects');
     $comment1->delete($this->con);
     $this->assertEquals(1, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects');
 }
コード例 #2
0
 /**
  * @param PropelPDO $con
  * @return string
  */
 public function computeNbComments(PropelPDO $con)
 {
     $this->countComputeCall++;
     return parent::computeNbComments($con);
 }