示例#1
0
 public function testObjectPropertiesSet()
 {
     // setting up testing values
     $id = 1;
     $title = 'tested title';
     // setting up sample case
     $post = new Post();
     $post->setId($id);
     $post->setTitle($title);
     // getting actual values
     $refPost = new \ReflectionObject($post);
     $idProp = $refPost->getProperty('_id');
     $idProp->setAccessible(true);
     $titleProp = $refPost->getProperty('_title');
     $titleProp->setAccessible(true);
     $this->assertEquals($id, $idProp->getValue($post), "ID not properly set by Post setter method");
     $this->assertEquals($title, $titleProp->getValue($post), "title not properly set by Post setter method");
 }
示例#2
0
 /**
  * @param $id
  * @return Post
  */
 public function fetchPostById($id)
 {
     $post = new Post();
     $post->setId(1)->setTitle('first tested post');
     return $post;
 }