File: NotificationHistoryTest.php

package info (click to toggle)
owncloud 7.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 104,192 kB
  • sloc: php: 403,584; xml: 5,843; perl: 630; cs: 504; sh: 453; sql: 271; python: 221; makefile: 104
file content (72 lines) | stat: -rw-r--r-- 2,051 bytes parent folder | download
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php

namespace OpenCloud\Tests\CloudMonitoring\Resource;

use OpenCloud\Tests\CloudMonitoring\CloudMonitoringTestCase;

class NotificationHistoryTest extends CloudMonitoringTestCase
{
    
    const ENTITY_ID = 'enAAAAA';
    const ALARM_ID  = 'alAAAA';
    const CHECK_ID  = 'chAAAA';
    const NH_ID     = '646ac7b0-0b34-11e1-a0a1-0ff89fa2fa26';

    private $alarm;

    public function setupObjects()
    {
        parent::setupObjects();

        $this->addMockSubscriber($this->getTestFilePath('Alarm'));
        $this->alarm = $this->entity->getAlarm(self::ALARM_ID);
    }

    public function test_Record_Checks()
    {
        $response = new \Guzzle\Http\Message\Response(200, array('Content-Type' => 'application/json'), '{"check_ids": ["chOne","chTwo"]}');
        $this->addMockSubscriber($response);

        $checks = $this->alarm->getRecordedChecks();

        $this->assertCount(2, $checks);
        $this->assertEquals('chOne', $checks[0]);
    }

    /**
     * @mockFile NH_List
     */
    public function test_Check_History()
    {
        $list = $this->alarm->getNotificationHistoryForCheck(self::CHECK_ID);

        $this->assertInstanceOf(self::COLLECTION_CLASS, $list);

        $first = $list->first();
        $this->assertInstanceOf(
            'OpenCloud\\CloudMonitoring\\Resource\\NotificationHistory',
            $first
        );
        
        $this->assertEquals('sometransaction', $first->getTransactionId());
        $this->assertEquals('matched return statement on line 6', $first->getStatus());
    }

    /**
     * @mockFile NH_Item
     */
    public function test_Single()
    {
        $item = $this->alarm->getNotificationHistoryItem(self::CHECK_ID, self::NH_ID);

        $this->assertInstanceOf(
            'OpenCloud\\CloudMonitoring\\Resource\\NotificationHistory',
            $item
        );

        $this->assertEquals(self::NH_ID, $item->getId());
        $this->assertEquals(1320885544875, $item->getTimestamp());
        $this->assertEquals('WARNING', $item->getState());
    }
    
}