教你一步一步写一个phpunit testcase(8)
发表于:2017-06-01来源:叶左左作者:叶左左点击数:
标签:PHPUnit
0 ]; $user = $obj[ 1 ]; // 使用者取消报名 $event-unReserve($user); $unReserveExpectedCount = 0 ; // 预期报名人数 $this -assertEquals($unReserveExpectedCount, $event-getAttendNumber()); //
0];
$user = $obj[
1];
$event->unReserve($user);
$unReserveExpectedCount =
0;
$this->assertEquals($unReserveExpectedCount, $event->getAttendNumber());
$this->assertNotContains($user, $event->attendArr);
}
public function testAttendeeLimitReserve($eventId, $eventName, $eventStartDate, $eventEndDate, $eventAttendLimit) {
$event =
new \PHPUnitEventDemo\Event($eventId, $eventName, $eventStartDate, $eventEndDate, $eventAttendLimit);
$userNumber =
6;
for ($userCount =
1; $userCount < $userNumber; $userCount++) {
$userId = $userCount;
$userName =
'User ' . $userId;
$userEmail =
'user' . $userId .
'@zoco.space';
$user =
new \PHPUnitEventDemo\User($userId, $userName, $userEmail);
$reservedResult = $event->reserve($user);
if ($userCount > $eventAttendLimit) {
$this->assertFalse($reservedResult);
}
else {
$this->assertTrue($reservedResult);
}
}
}
public
原文转自:http://www.jianshu.com/p/ba6829a6f3ec