forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDescribeAlarmsForMetricTest.php
More file actions
59 lines (49 loc) · 1.6 KB
/
DescribeAlarmsForMetricTest.php
File metadata and controls
59 lines (49 loc) · 1.6 KB
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
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/*
Relies on PHPUnit to test the functionality in ./DescribeAlarmsForMetric.php.
Related custom constants are defined in ./phpunit.xml.
Example PHPUnit run command from this file's parent directory:
./vendor/bin/phpunit --testsuite cloudwatch-describealarmsformetric
*/
namespace Cloudwatch;
use Aws\CloudWatch\CloudWatchClient;
use Aws\MockHandler;
use Aws\Result;
use PHPUnit\Framework\TestCase;
class DescribeAlarmsForMetricTest extends TestCase
{
public function testDescribesAlarmsForAMetric()
{
require(__DIR__ . '/../DescribeAlarmsForMetric.php');
$metricName = CLOUDWATCH_METRIC_NAME;
$namespace = CLOUDWATCH_METRIC_NAMESPACE;
$dimensions = [
[
'Name' => 'StorageTypes',
'Value' => 'StandardStorage'
],
[
'Name' => 'BucketName',
'Value' => 'amzn-s3-demo-bucket'
]
];
$mock = new MockHandler();
$mock->append(new Result(array(true)));
$cloudWatchClient = new CloudWatchClient([
'profile' => AWS_PROFILE,
'version' => CLOUDWATCH_VERSION,
'region' => AWS_REGION,
'handler' => $mock
]);
$result = describeAlarmsForMetric(
$cloudWatchClient,
$metricName,
$namespace,
$dimensions
);
$this->assertStringContainsString('https://monitoring.' . AWS_REGION .
'.amazonaws.com', $result);
}
}