LibCaldav_basicTest::setUpBeforeClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
require_once dirname(__FILE__).'/mock/functions.php';
4
require_once dirname(__FILE__).'/../programs/caldav.class.php';
5
require_once dirname(__FILE__).'/mock/calendar.php';
6
7
8
9
10
11
class LibCaldav_basicTest extends PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @var LibCaldav_mock
15
     */
16
    static $mock;
17
18
    public static function setUpBeforeClass()
19
    {
20
        self::$mock = bab_getInstance('LibCaldav_mock');
21
    }
22
    
23
    
24
    
25
    public function testStorageBackendValue()
26
    {
27
        $this->assertTrue(self::$mock->getCaldavBackend()->StorageBackend());
28
    }
29
    
30
    
31
    
32
    public function testServer()
33
    {
34
        $id_user = self::$mock->getCaldavUser();
35
        $backend = self::$mock->getCaldavBackend();
36
        $this->assertTrue($backend->checkCalendar($id_user), 'check calendar on localhost:5232');
37
    }
38
    
39
    
40
    public function testEventSave()
41
    {
42
        $id_user = self::$mock->getCaldavUser();
43
        $backend = self::$mock->getCaldavBackend();
44
        
45
        
46
        $calendar = $backend->PersonalCalendar($id_user);
47
        $collection = $backend->CalendarEventCollection($calendar);
48
        
49
        $dtstart = BAB_DateTime::fromIsoDateTime('2015-01-01 00:00:00');
50
        $dtend = BAB_DateTime::fromIsoDateTime('2015-01-02 00:00:00');
51
        
52
        $period = new bab_CalendarPeriod();
53
        $period->setDates($dtstart, $dtend);
54
        $period->setProperty('UID', 'LIBCALDAV_UNITTEST_1');
55
        $period->setProperty('SUMMARY', 'Test event');
56
        
57
        $collection->addPeriod($period);
58
        
59
        $this->assertTrue($backend->savePeriod($period));
60
    }
61
    
62
    
63 View Code Duplication
    public function testEventGet()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
    {
65
        $id_user = self::$mock->getCaldavUser();
66
        $backend = self::$mock->getCaldavBackend();
67
        $calendar = $backend->PersonalCalendar($id_user);
68
        $collection = $backend->CalendarEventCollection($calendar);
69
        
70
        $period = $backend->getPeriod($collection, 'LIBCALDAV_UNITTEST_1');
71
        
72
        $this->assertInstanceOf('caldav_CalendarPeriod', $period);
73
        $this->assertEquals('Test event', $period->getProperty('SUMMARY'));
74
    }
75
}
76