-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathICalEventsUnitTest.php
More file actions
57 lines (42 loc) · 1.28 KB
/
ICalEventsUnitTest.php
File metadata and controls
57 lines (42 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
use Timegridio\ICalReader\ICalEvents;
use Carbon\Carbon;
use Illuminate\Support\Collection;
class ICalEventsUnitTest extends PackageTestCase
{
/**
* @var ICalEvents
*/
protected $icalevents;
public function setUp()
{
parent::setUp();
$this->icalevents = new ICalEvents();
$this->icalevents->loadString($this->getStub());
}
/**
* @test
*/
public function it_gets_events_from_string()
{
$events = $this->icalevents->get()->all();
$this->assertInstanceOf(Collection::class, $events);
}
/**
* @test
*/
public function it_determines__if_busy_for_timeslot()
{
$busy = $this->icalevents->isBusy(Carbon::parse('2016-07-11 23:10')->timezone('America/Argentina/Buenos_Aires'));
$this->assertTrue($busy);
$busy = $this->icalevents->isBusy(Carbon::parse('2016-07-11 23:30')->timezone('America/Argentina/Buenos_Aires'));
$this->assertFalse($busy);
$busy = $this->icalevents->isBusy(Carbon::parse('2099-12-01 00:30')->timezone('America/Argentina/Buenos_Aires'));
$this->assertFalse($busy);
}
protected function getStub()
{
$contents = file_get_contents(__DIR__.'/stubs/ical-stub.ics');
return $contents;
}
}