File: ZoneTest.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 (87 lines) | stat: -rw-r--r-- 2,574 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
<?php

namespace OpenCloud\Tests\CloudMonitoring\Resource;

use Guzzle\Http\Message\Response;
use OpenCloud\Tests\CloudMonitoring\CloudMonitoringTestCase;

class ZoneTest extends CloudMonitoringTestCase
{
    
    public function setupObjects()
    {
        $this->service = $this->getClient()->cloudMonitoringService();

        $response = new Response(200, array('Content-Type' => 'application/json'), '{"id":"mzAAAAA","label":"US South (Atlanta) - 5","country_code":"US","source_ips":["1.2.0.0/24"]}');
        $this->addMockSubscriber($response);

        $this->resource = $this->service->getMonitoringZone('mzAAAAA');
    }
    
    public function testResourceClass()
    {
        $this->assertInstanceOf(
            'OpenCloud\\CloudMonitoring\\Resource\\Zone',
            $this->resource
        );
    }
    
    public function testUrl()
    {
        $this->assertEquals(
            'https://monitoring.api.rackspacecloud.com/v1.0/123456/monitoring_zones/mzAAAAA',
            (string) $this->resource->getUrl()
        );
    }
    
    public function testCollection()
    {
        $response = new Response(200, array('Content-Type' => 'application/json'), '{"values":[{"id":"mzAAAAA","label":"US South (Atlanta) - 5","country_code":"US","source_ips":["1.2.0.0/24"]}],"metadata":{"count":1,"limit":50,"marker":null,"next_marker":null,"next_href":null}}');
        $this->addMockSubscriber($response);

        $list = $this->service->getMonitoringZones();

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

        $first = $list->first();
        
        $this->assertEquals('mzAAAAA', $first->getId());
        $this->assertEquals('US', $first->getCountryCode());
    }
    
    public function testGetClass()
    {
        $this->assertEquals('mzAAAAA', $this->resource->getId());
    }

    /**
     * @mockFile Zone_TraceRoute
     */
    public function testTraceroute()
    {
        $object = $this->resource->traceroute(array(
            'target' => 'http://test.com',
            'target_resolver' => 'foo'
        ));

        $this->assertNotNull($object);
    }
    
    /**
     * @expectedException OpenCloud\CloudMonitoring\Exception\ZoneException
     */
    public function testTracerouteFailsWithoutId()
    {
        $this->resource->traceroute(array());
    }
    
    /**
     * @expectedException OpenCloud\CloudMonitoring\Exception\ZoneException
     */
    public function testTracerouteFailsWithoutTarget()
    {
        $this->resource->setId('mzAAAAA');
        $this->resource->traceroute(array());
    }

}