Created
October 28, 2014 12:04
-
-
Save ymhuang0808/ed996beee4bed6cf574c to your computer and use it in GitHub Desktop.
EventTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class EvnetTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function eventsProvider() | |
{ | |
return [ | |
[ | |
[ | |
[ | |
'name' => 'PHPUnit', | |
'start_date' => '2014-10-27 09:00', | |
'end_date' => '2014-10-27 12:00', | |
'description' => 'PHPUnit tutorial XD', | |
], | |
[ | |
'name' => 'Learning Ruby on Rails', | |
'start_date' => '2014-11-02 09:30', | |
'end_date' => '2014-11-02 16:00', | |
'description' => 'RoR basic', | |
], | |
[ | |
'name' => 'Git tutorial', | |
'start_date' => '2014-11-08 14:00', | |
'end_date' => '2014-11-08 17:00', | |
'description' => 'How to use Git in your development?', | |
], | |
] | |
] | |
]; | |
} | |
/** | |
* @dataProvider eventsProvider | |
*/ | |
public function testSetAndGetEvents($eventArray) | |
{ | |
$event = new \PHPUnitEvent\Event(); | |
$event->setEvents($eventArray); | |
$this->assertCount(3, $event->getEvents()); | |
return $event; | |
} | |
/** | |
* @depends testSetAndGetEvents | |
*/ | |
public function testGetValidEvents($event) | |
{ | |
var_dump($event); | |
$expectedValidEvent = [ | |
[ | |
'name' => 'Learning Ruby on Rails', | |
'start_date' => '2014-11-02 09:30', | |
'end_date' => '2014-11-02 16:00', | |
'description' => 'RoR basic', | |
], | |
[ | |
'name' => 'Git tutorial', | |
'start_date' => '2014-11-08 14:00', | |
'end_date' => '2014-11-08 17:00', | |
'description' => 'How to use Git in your development?', | |
] | |
]; | |
$validEvents = $event->getValidEvents(1414421687); | |
$this->assertCount(2, $validEvents); | |
$this->assertSame($expectedValidEvent, $validEvents); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment