教你一步一步写一个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; } /** * 测试报名 * * @return array */ 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]; } /** * 测试取消报名 * * @param $obj * @depends testReserve */ public function testUnReserve($obj) { $event = $obj[

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