31 $expected = [
'some_key' =>
'some_value'];
33 $this->assertAttributeEquals($expected,
'_defaultTags', \
Magento\Framework\Profiler::class);
42 $expected = [
'tag1' => [
'value_1.1',
'value_1.2'],
'tag2' => [
'value_2.1']];
43 $this->assertAttributeEquals($expected,
'_tagFilters', \
Magento\Framework\Profiler::class);
44 $this->assertAttributeEquals(
true,
'_hasTagFilters', \
Magento\Framework\Profiler::class);
55 $this->assertAttributeEquals($expected,
'_drivers', \
Magento\Framework\Profiler::class);
63 return $this->getMockBuilder(
66 [
'start',
'stop',
'clear']
67 )->getMockForAbstractClass();
83 $driver->expects($this->never())->method(
'start');
84 $driver->expects($this->never())->method(
'stop');
88 \Magento\Framework\Profiler::start(
'test');
89 \Magento\Framework\Profiler::stop(
'test');
95 $driver->expects($this->once())->method(
'start')->with(
'root_level_timer',
null);
96 $driver->expects($this->once())->method(
'stop')->with(
'root_level_timer');
99 \Magento\Framework\Profiler::start(
'root_level_timer');
100 \Magento\Framework\Profiler::stop(
'root_level_timer');
106 $driver->expects($this->at(0))->method(
'start')->with(
'root_level_timer',
null);
107 $driver->expects($this->at(1))->method(
'start')->with(
'root_level_timer->some_other_timer',
null);
109 $driver->expects($this->at(2))->method(
'stop')->with(
'root_level_timer->some_other_timer');
110 $driver->expects($this->at(3))->method(
'stop')->with(
'root_level_timer');
113 \Magento\Framework\Profiler::start(
'root_level_timer');
114 \Magento\Framework\Profiler::start(
'some_other_timer');
115 \Magento\Framework\Profiler::stop(
'some_other_timer');
116 \Magento\Framework\Profiler::stop(
'root_level_timer');
126 \Magento\Framework\Profiler::start(
'timer');
127 \Magento\Framework\Profiler::stop(
'unknown');
133 $driver->expects($this->at(0))->method(
'start')->with(
'timer1',
null);
134 $driver->expects($this->at(1))->method(
'start')->with(
'timer1->timer2',
null);
135 $driver->expects($this->at(2))->method(
'start')->with(
'timer1->timer2->timer1',
null);
136 $driver->expects($this->at(3))->method(
'start')->with(
'timer1->timer2->timer1->timer3',
null);
138 $driver->expects($this->at(4))->method(
'stop')->with(
'timer1->timer2->timer1->timer3');
139 $driver->expects($this->at(5))->method(
'stop')->with(
'timer1->timer2->timer1');
141 $driver->expects($this->exactly(4))->method(
'start');
142 $driver->expects($this->exactly(2))->method(
'stop');
145 \Magento\Framework\Profiler::start(
'timer1');
146 \Magento\Framework\Profiler::start(
'timer2');
147 \Magento\Framework\Profiler::start(
'timer1');
148 \Magento\Framework\Profiler::start(
'timer3');
149 \Magento\Framework\Profiler::stop(
'timer1');
155 $driver->expects($this->at(0))->method(
'start')->with(
'timer1',
null);
156 $driver->expects($this->at(1))->method(
'start')->with(
'timer1->timer1',
null);
158 $driver->expects($this->at(2))->method(
'stop')->with(
'timer1->timer1');
159 $driver->expects($this->at(3))->method(
'stop')->with(
'timer1');
162 \Magento\Framework\Profiler::start(
'timer1');
163 \Magento\Framework\Profiler::start(
'timer1');
164 \Magento\Framework\Profiler::stop(
'timer1');
165 \Magento\Framework\Profiler::stop(
'timer1');
171 $driver->expects($this->at(0))->method(
'start')->with(
'root_level_timer',
null);
173 $driver->expects($this->at(1))->method(
'stop')->with(
'root_level_timer');
176 \Magento\Framework\Profiler::start(
'root_level_timer');
177 \Magento\Framework\Profiler::stop();
183 $driver->expects($this->at(0))->method(
'start')->with(
'root_level_timer', [
'default_tag' =>
'default']);
189 'root_level_timer->some_other_timer',
190 [
'default_tag' =>
'default',
'type' =>
'test']
195 \Magento\Framework\Profiler::start(
'root_level_timer');
196 \Magento\Framework\Profiler::start(
'some_other_timer', [
'type' =>
'test']);
202 $driver->expects($this->at(0))->method(
'clear')->with(
'timer');
205 \Magento\Framework\Profiler::clear(
'timer');
221 $driver->expects($this->once())->method(
'clear')->with(
null);
226 $this->assertAttributeEquals([],
'_currentPath', \
Magento\Framework\Profiler::class);
227 $this->assertAttributeEquals([],
'_tagFilters', \
Magento\Framework\Profiler::class);
228 $this->assertAttributeEquals([],
'_defaultTags', \
Magento\Framework\Profiler::class);
229 $this->assertAttributeEquals([],
'_drivers', \
Magento\Framework\Profiler::class);
230 $this->assertAttributeEquals(
false,
'_hasTagFilters', \
Magento\Framework\Profiler::class);
231 $this->assertAttributeEquals(0,
'_pathCount', \
Magento\Framework\Profiler::class);
232 $this->assertAttributeEquals([],
'_pathIndex', \
Magento\Framework\Profiler::class);
243 $driver->expects($this->never())->method(
'start');
247 \Magento\Framework\Profiler::start($timerName, $tags);
256 'no tags' => [
'timer',
null],
257 'no expected tags' => [
'timer', [
'tag' =>
'value']],
258 'no expected tag value' => [
'timer', [
'type' =>
'db']]
270 $driver->expects($this->once())->method(
'start')->with($timerName, $tags);
274 \Magento\Framework\Profiler::start($timerName, $tags);
283 'one expected tag' => [
'timer', [
'type' =>
'test']],
284 'more than one tag with expected' => [
'timer', [
'tag' =>
'value',
'type' =>
'test']]
290 $mockDriver = $this->createMock(\
Magento\Framework\
Profiler\DriverInterface::class);
291 $driverConfig = [
'type' =>
'foo'];
292 $mockDriverFactory = $this->getMockBuilder(
294 )->disableOriginalConstructor()->getMock();
296 'drivers' => [$driverConfig],
297 'driverFactory' => $mockDriverFactory,
298 'tagFilters' => [
'tagName' =>
'tagValue'],
301 $mockDriverFactory->expects(
308 $this->returnValue($mockDriver)
312 $this->assertAttributeEquals([$mockDriver],
'_drivers', \
Magento\Framework\Profiler::class);
313 $this->assertAttributeEquals(
314 [
'tagName' => [
'tagValue']],
316 \
Magento\Framework\Profiler::class
318 $this->assertAttributeEquals(
true,
'_enabled', \
Magento\Framework\Profiler::class);
329 $method = new \ReflectionMethod(\
Magento\Framework\Profiler::class,
'_parseConfig');
331 $this->assertEquals($expected,
$method->invoke(
null,
$data,
'', $isAjax));
340 $driverFactory = new \Magento\Framework\Profiler\Driver\Factory();
341 $otherDriverFactory = $this->createMock(\
Magento\Framework\
Profiler\Driver\Factory::class);
343 'Empty configuration' => [
347 'driverConfigs' => [],
348 'driverFactory' => $driverFactory,
353 'Full configuration' => [
355 'drivers' => [[
'type' =>
'foo']],
356 'driverFactory' => $otherDriverFactory,
357 'tagFilters' => [
'key' =>
'value'],
358 'baseDir' =>
'/custom/base/dir',
362 'driverConfigs' => [[
'type' =>
'foo',
'baseDir' =>
'/custom/base/dir']],
363 'driverFactory' => $otherDriverFactory,
364 'tagFilters' => [
'key' =>
'value'],
365 'baseDir' =>
'/custom/base/dir' 368 'Driver configuration with type in index' => [
369 [
'drivers' => [
'foo' => 1]],
372 'driverConfigs' => [[
'type' =>
'foo']],
373 'driverFactory' => $driverFactory,
378 'Driver configuration with type in value' => [
379 [
'drivers' => [
'foo']],
382 'driverConfigs' => [[
'type' =>
'foo']],
383 'driverFactory' => $driverFactory,
388 'Driver ignored configuration' => [
389 [
'drivers' => [
'foo' => 0]],
392 'driverConfigs' => [],
393 'driverFactory' => $driverFactory,
402 'driverConfigs' => [[
'output' =>
'html']],
403 'driverFactory' => $driverFactory,
static add(DriverInterface $driver)
skippedFilterDataProvider()
testTagFilterSkip($timerName, array $tags=null)
static setDefaultTags(array $tags)
passedFilterDataProvider()
parseConfigDataProvider()
static applyConfig($config, $baseDir, $isAjax=false)
testStopExceptionUnknown()
static addTagFilter($tagName, $tagValue)
testTagFilterPass($timerName, array $tags=null)
testParseConfig($data, $isAjax, $expected)