教你一步一步写一个phpunit testcase(5)

发表于:2017-06-01来源:叶左左作者:叶左左点击数: 标签:PHPUnit
@param $id * @param $name * @param $startDate * @param $endDate * @param $attendLimit */ public function __construct ($id, $name, $startDate, $endDate, $attendLimit) { $this -id = $id; $this -name = $
@param $id * @param $name * @param $startDate * @param $endDate * @param $attendLimit */ public function __construct($id, $name, $startDate, $endDate, $attendLimit) { $this->id = $id; $this->name = $name; $this->startDate = $startDate; $this->endDate = $endDate; $this->attendLimit = $attendLimit; } /** * 用户报名,将报名的用户存在数组中,数组的索引值就是用户的id * * @param $user * @return bool * @throws EventException */ public function reserve($user) { // 报名人数是否超过限制 if ($this->attendLimit > $this->getAttendNumber()) { if (array_key_exists($user->id, $this->attendArr)) { throw new EventException('Duplicated reservation', EventException::DUPLICATED_RESERVATION); } // 使用者报名 $this->attendArr[$user->id] = $user; return true; } return false; } /** * 获取报名用户的人数 * * @return int */ public function

原文转自:http://www.jianshu.com/p/ba6829a6f3ec