/**
  * Tests the getNewCommentator() method returns new instances of
  * the CommentatorObject
  */
 public function testGetNewCommentatorReturnsNewCommentator()
 {
     $mockApp = m::mock(\Silex\Application::class)->makePartial();
     $factory = new CommentatorFactory($mockApp);
     $object1 = $factory->getNewCommentator();
     $object2 = $factory->getNewCommentator();
     $this->assertInstanceOf(CommentatorData::class, $object1);
     $this->assertNotSame($object1, $object2);
 }
Example #2
0
 /**
  * Fetch a list of comments records
  *
  * @param $post_id int
  *
  * @return array
  */
 public function fetchAll($post_id, CommentatorFactory $factory)
 {
     // Comment data
     $commentDataObject = $this->getDataObject();
     $commentRecords = $commentDataObject->fetchCommentsByPostId($post_id);
     $records = [];
     // Commentator data
     foreach ($commentRecords as $comment) {
         $commentatorDataObject = $factory->getNewCommentator();
         $commentator = $commentatorDataObject->fetchCommentatorBasicDataById($comment['commentator_id']);
         $records[] = array_merge($comment, $commentator);
     }
     return $records;
 }