本文整理汇总了PHP中UnitTester::getMetricDataArray方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitTester::getMetricDataArray方法的具体用法?PHP UnitTester::getMetricDataArray怎么用?PHP UnitTester::getMetricDataArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitTester
的用法示例。
在下文中一共展示了UnitTester::getMetricDataArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRun
public function testRun()
{
/* @var CommandRunner $fakeCmdRunner1 */
$fakeCmdRunner1 = Stub::make('\\AWSCustomMetric\\CommandRunner', ['execute' => function () {
}, 'getReturnValue' => '56']);
/* @var CommandRunner $fakeCmdRunner2 */
$fakeCmdRunner2 = Stub::make('\\AWSCustomMetric\\CommandRunner', ['execute' => function () {
}, 'getReturnCode' => 0, 'getOutput' => ['MemTotal: 10000 kB', 'MemFree: 2000 kB', 'MemAvailable: 419980 kB', 'Buffers: 1000 kB', 'Cached: 1000 kB', 'SwapCached: 0 kB', 'Active: 526652 kB', 'Inactive: 164928 kB', 'SwapTotal: 10000 kB', 'SwapFree: 9000 kB']]);
$diObj1 = new DI();
$diObj1->setCommandRunner($fakeCmdRunner1);
$diObj2 = new DI();
$diObj2->setCommandRunner($fakeCmdRunner2);
$plugin1 = new DiskUsage($diObj1);
$plugin2 = new MemoryUsage($diObj2);
$testObj = new Sender('fakekey', 'fakesecret', 'fakeregion', $fakeCmdRunner1, 'testInstance', 'testns');
$testObj->addPlugin([$plugin1, $plugin2]);
$testObj->run();
$actualStr = file_get_contents(rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'cloud_watch_client.txt');
$exceptedStr = '';
$exceptedStr .= json_encode($this->tester->getMetricDataArray($plugin1->getMetrics(), 'testInstance', 'testns')) . "\n";
$exceptedStr .= json_encode($this->tester->getMetricDataArray($plugin2->getMetrics(), 'testInstance', 'testns')) . "\n";
$this->assertEquals($exceptedStr, $actualStr, 'Sender::run default test failed!');
$plugin3 = new DiskUsage($diObj1, 'Test/System', '* * * * *');
$plugin4 = new MemoryUsage($diObj2, 'Test/System', '*/' . (date('i') + 1) . ' * * * *');
$testObj2 = new Sender('fakekey', 'fakesecret', 'fakeregion', $fakeCmdRunner1, 'testInstance', 'testns');
$testObj2->addPlugin([$plugin3, $plugin4]);
$testObj2->run();
$actualStr = file_get_contents(rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'cloud_watch_client.txt');
$exceptedStr = '';
$exceptedStr .= json_encode($this->tester->getMetricDataArray($plugin3->getMetrics(), 'testInstance', 'Test/System')) . "\n";
$this->assertEquals($exceptedStr, $actualStr, 'Sender::run cron test failed!');
}