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
|
<?php
namespace OpenCloud\Tests\CloudMonitoring\Resource;
use Guzzle\Http\Message\Response;
use OpenCloud\Tests\CloudMonitoring\CloudMonitoringTestCase;
class NotificationPlanTest extends CloudMonitoringTestCase
{
const NP_ID = 'npAAAA';
public function setupObjects()
{
$this->service = $this->getClient()->cloudMonitoringService();
$this->resource = $this->service->getNotificationPlan();
}
public function testNPClass()
{
$this->assertInstanceOf(
'OpenCloud\\CloudMonitoring\\Resource\\NotificationPlan',
$this->resource
);
}
public function testNPUrl()
{
$this->assertEquals(
'https://monitoring.api.rackspacecloud.com/v1.0/123456/notification_plans',
(string) $this->resource->getUrl()
);
}
/**
* @expectedException OpenCloud\Common\Exceptions\CreateError
*/
public function testCreateFailsWithoutParams()
{
$this->resource->create();
}
public function testListAll()
{
$response = new Response(200, array('Content-Type' => 'application/json'), '{"values":[{"label":"Notification Plan 1","critical_state":["ntAAAA"],"warning_state":["ntCCCCC"],"ok_state":["ntBBBB"]}],"metadata":{"count":1,"limit":50,"marker":null,"next_marker":null,"next_href":null}}');
$this->addMockSubscriber($response);
$list = $this->service->getNotificationPlans();
$this->assertInstanceOf(self::COLLECTION_CLASS, $list);
$first = $list->first();
$this->assertInstanceOf('OpenCloud\CloudMonitoring\Resource\NotificationPlan', $first);
$this->assertObjectHasAttribute('label', $first);
}
public function testGet()
{
$response = new Response(200, array('Content-Type' => 'application/json'), '{"label":"Notification Plan 1","critical_state":["ntAAAA"],"warning_state":["ntCCCCC"],"ok_state":["ntBBBB"]}');
$this->addMockSubscriber($response);
$this->resource->refresh(self::NP_ID);
$this->assertEquals('Notification Plan 1', $this->resource->getLabel());
}
}
|