教你一步一步写一个phpunit testcase(7)
发表于:2017-06-01来源:叶左左作者:叶左左点击数:
标签:PHPUnit
; $eventAttendLimit = 10 ; $this -event = new \PHPUnitEventDemo\Event($eventId, $eventName, $eventStartDate, $eventEndDate, $eventAttendLimit); $userId = 1 ; $userName = User1 ; $userEmail = user1@zoc
;
$eventAttendLimit =
10;
$this->event =
new \PHPUnitEventDemo\Event($eventId, $eventName, $eventStartDate, $eventEndDate, $eventAttendLimit);
$userId =
1;
$userName =
'User1';
$userEmail =
'user1@zoco.space';
$this->user =
new \PHPUnitEventDemo\User($userId, $userName, $userEmail);
}
public function tearDown() {
$this->event =
null;
$this->user =
null;
}
public function testReserve() {
$this->event->reserve(
$this->user);
$expectedNumber =
1;
$this->assertEquals($expectedNumber,
$this->event->getAttendNumber());
$this->assertContains(
$this->user,
$this->event->attendArr);
return [
$this->event,
$this->user];
}
public function testUnReserve($obj) {
$event = $obj[
原文转自:http://www.jianshu.com/p/ba6829a6f3ec