-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathIntegUtils.php
More file actions
64 lines (56 loc) · 1.49 KB
/
IntegUtils.php
File metadata and controls
64 lines (56 loc) · 1.49 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
60
61
62
63
64
<?php
namespace Aws\Test\Integ;
use function Aws\getenv;
trait IntegUtils
{
private static $originalCsmEnabled;
private static function getSdk(array $args = [])
{
return new \Aws\Sdk($args + [
'region' => 'us-east-1',
'version' => 'latest',
'ua_append' => 'PHPUnit/Integration'
]);
}
public static function log($message)
{
fwrite(STDERR, date('c') . ': ' . $message . "\n");
}
/**
* Get the resource prefix to add to created resources
*
* @return string
*/
public static function getResourcePrefix()
{
if (!isset($_SERVER['PREFIX']) || $_SERVER['PREFIX'] == 'hostname') {
$_SERVER['PREFIX'] = crc32(gethostname()) . rand(0, 10000);
}
return $_SERVER['PREFIX'];
}
/**
* Disable client-side monitoring if local config has it enabled
*
* @BeforeSuite
*/
public static function disableCsm()
{
self::$originalCsmEnabled = getenv(
\Aws\ClientSideMonitoring\ConfigurationProvider::ENV_ENABLED
);
putenv(\Aws\ClientSideMonitoring\ConfigurationProvider::ENV_ENABLED
. '=false'
);
}
/**
* Restore original client-side monitoring enabled flag
*
* @AfterSuite
*/
public static function restoreCsmConfig()
{
putenv(\Aws\ClientSideMonitoring\ConfigurationProvider::ENV_ENABLED .
'=' . self::$originalCsmEnabled
);
}
}