当前位置: 首页>>代码示例>>PHP>>正文


PHP UnitTester::getMetricDataArray方法代码示例

本文整理汇总了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!');
 }
开发者ID:fustundag,项目名称:awscw-custom-metrics,代码行数:32,代码来源:SenderTest.php


注:本文中的UnitTester::getMetricDataArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。