示例#1
0
 /**
  *   Get Profile data
  *   @param  Number          $id    User Id
  *   @return ProfileData
  *   @throws Exception
  */
 public function getData($id = null)
 {
     $valid = new ProfileData();
     $valid->validation("id", $id);
     //Query database
     $profileData = ProfileData::makeProfile($id, 'yoyo', '*****@*****.**', 0);
     return $profileData;
 }
 /**
  * @dataProvider additionInitProvider
  */
 public function testInitDataObject($id, $name, $email, $sex)
 {
     $obj = ProfileData::makeProfile($id, $name, $email, $sex);
     if ($id === null) {
         $this->setExpectedException('\\InvalidArgumentException', "id must only contain numeric.");
         $obj->checkData();
     }
 }
 public function testUpdateData()
 {
     //test normal case
     $profileData = ProfileData::makeProfile(1, 'tester', '*****@*****.**', 1);
     $obj = new Profile();
     $this->assertEquals($obj->updateData($profileData), true);
     //test exception case
     $profileData = ProfileData::makeProfile(null, 'tester', '*****@*****.**', 1);
     $this->setExpectedException('\\InvalidArgumentException', "id must only contain numeric.");
     $obj->updateData($profileData);
 }