當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。