Skip to content

Instantly share code, notes, and snippets.

@ymhuang0808
Created October 28, 2014 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ymhuang0808/ed996beee4bed6cf574c to your computer and use it in GitHub Desktop.
Save ymhuang0808/ed996beee4bed6cf574c to your computer and use it in GitHub Desktop.
EventTest
<?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