File: AgentTest.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 (125 lines) | stat: -rw-r--r-- 3,217 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php

namespace OpenCloud\Tests\CloudMonitoring\Resource;

use OpenCloud\Tests\CloudMonitoring\CloudMonitoringTestCase;

class AgentTest extends CloudMonitoringTestCase
{

    const AGENT_ID      = '00-agent.example.com';
    const CONNECTION_ID = 'cntl4qsIbA';

    public function setupObjects()
    {
        $this->service = $this->getClient()->cloudMonitoringService();
        $this->resource = $this->service->getAgent();
    }
    
    public function testResourceClass()
    {
        $this->assertInstanceOf(
            'OpenCloud\\CloudMonitoring\\Resource\\Agent',
            $this->resource
        );
    }
    
    public function testUrl()
    {
        $this->assertEquals(
            'https://monitoring.api.rackspacecloud.com/v1.0/123456/agents',
            (string)$this->resource->getUrl()
        );
    }
    
    /**
     * @expectedException OpenCloud\Common\Exceptions\CreateError
     */
    public function testCreateFailsWithNoParams()
    {
        $this->resource->create();
    }
    
    /**
     * @expectedException OpenCloud\Common\Exceptions\UpdateError
     */
    public function testUpdateFailsWithNoParams()
    {
        $this->resource->update();
    }

    /**
     * @mockFile Agent_List
     */
    public function testCollection()
    {
        $this->assertInstanceOf(
            self::COLLECTION_CLASS,
            $this->resource->listAll()
        );
    }

    /**
     * @mockFile Agent
     */
    public function testGet()
    {
        $this->resource->refresh(self::AGENT_ID);
        $this->assertEquals($this->resource->getId(), '1d29b4f9-87ca-4b22-b5a2-4e40a07bf068');
        $this->assertEquals($this->resource->getLastConnected(), 1383616760309);
    }

    /**
     * @mockFile Agent_Connection_List
     */
    public function testGetConnections()
    {  
        $this->resource->setId(self::AGENT_ID);
        $list = $this->resource->getConnections();
        
        $this->assertInstanceOf(self::COLLECTION_CLASS, $list);
        
        $first = $list->first();
        
        $this->assertInstanceOf(
            'OpenCloud\\CloudMonitoring\\Resource\\AgentConnection',
            $first
        );
        
        $this->assertEquals('cntl4qsIbA', $first->getId());
        $this->assertEquals('0b49b96d-24c9-45ca-c585-4040707f4880', $first->getGuid());
    }
    
    /**
     * @expectedException OpenCloud\CloudMonitoring\Exception\AgentException
     */
    public function testGetConnectionsFailsWithoutId()
    {
        $this->resource->setId(null);
        $this->resource->getConnections();
    }

    /**
     * @mockFile Agent_Connection
     */
    public function testGetConnection()
    {
        $this->resource->setId(self::AGENT_ID);
        $connection = $this->resource->getConnection(self::CONNECTION_ID);
        
        $this->assertInstanceOf(
            'OpenCloud\\CloudMonitoring\\Resource\\AgentConnection',
            $connection
        );
    }
    
    /**
     * @expectedException OpenCloud\CloudMonitoring\Exception\AgentException
     */
    public function testGetConnectionFailsWithoutId()
    {
        $this->resource->setId(null);
        $this->resource->getConnection(null);
    }
    
}