19 $this->_output = $this->getMockForAbstractClass(
29 $this->assertAttributeEmpty(
'_filterPattern', $this->_output);
30 $filterPattern =
'/test/';
31 $this->_output->setFilterPattern($filterPattern);
32 $this->assertEquals($filterPattern, $this->_output->getFilterPattern());
40 $thresholdKey = \Magento\Framework\Profiler\Driver\Standard\Stat::TIME;
41 $this->_output->setThreshold($thresholdKey, 100);
43 ? \PHPUnit_Util_Class::getObjectAttribute($this->_output,
'_thresholds')
44 : \PHPUnit\Framework\Assert::readAttribute($this->_output,
'_thresholds');
45 $this->assertArrayHasKey($thresholdKey, $thresholds);
46 $this->assertEquals(100, $thresholds[$thresholdKey]);
48 $this->_output->setThreshold($thresholdKey,
null);
49 $this->assertArrayNotHasKey($thresholdKey, $this->_output->getThresholds());
55 public function testConstructor()
57 $configuration = [
'filterPattern' =>
'/filter pattern/',
'thresholds' => [
'fetchKey' => 100]];
59 $output = $this->getMockForAbstractClass(
63 $this->assertEquals(
'/filter pattern/',
$output->getFilterPattern());
64 $thresholds =
$output->getThresholds();
65 $this->assertArrayHasKey(
'fetchKey', $thresholds);
66 $this->assertEquals(100, $thresholds[
'fetchKey']);
79 $method = new \ReflectionMethod($this->_output,
'_renderColumnValue');
81 $this->assertEquals($expectedValue,
$method->invoke($this->_output,
$value, $columnKey));
90 [
'someTimerId', \Magento\Framework\Profiler\Driver\Standard\Stat::ID,
'someTimerId'],
91 [10000.123, \Magento\Framework\Profiler\Driver\Standard\Stat::TIME,
'10,000.123000'],
92 [200000.123456789, \Magento\Framework\Profiler\Driver\Standard\Stat::AVG,
'200,000.123457'],
93 [1000000000.12345678, \Magento\Framework\Profiler\Driver\Standard\Stat::EMALLOC,
'1,000,000,000'],
94 [2000000000.12345678, \Magento\Framework\Profiler\Driver\Standard\Stat::REALMEM,
'2,000,000,000']
103 $method = new \ReflectionMethod($this->_output,
'_renderCaption');
106 '/Code Profiler \(Memory usage: real - \d+, emalloc - \d+\)/',
107 $method->invoke($this->_output)
116 $this->_output->setFilterPattern(
'/filter pattern/');
118 $mockStat = $this->createMock(\
Magento\Framework\
Profiler\Driver\Standard\Stat::class);
119 $expectedTimerIds = [
'test'];
123 'getFilteredTimerIds' 125 $this->_output->getThresholds(),
126 $this->_output->getFilterPattern()
128 $this->returnValue($expectedTimerIds)
131 $method = new \ReflectionMethod($this->_output,
'_getTimerIds');
133 $this->assertEquals($expectedTimerIds,
$method->invoke($this->_output, $mockStat));
141 $method = new \ReflectionMethod($this->_output,
'_renderTimerId');
143 $this->assertEquals(
'someTimerId',
$method->invoke($this->_output,
'someTimerId'));
renderColumnValueDataProvider()
testRenderColumnValue($value, $columnKey, $expectedValue)