public function testCreatePost() { $obj = json_decode($this->user_sample); // Casts a stdObject to the type passed in the second argument $user = AopTestUtils::cast($obj, 'Models\\User'); // when post->save() is invoked return true AopMocker::mock('Models\\Post', 'save', true); // when User::getUser() is called the sample user will be returned AopMocker::mock('Models\\User', 'getUser', $user); $result = Post::createPost($user->_id, "Test", "This is a test post !", array("test", "unit")); $this->assertTrue($result >= 0); }