public static function setUpBeforeClass() { Magento_Profiler::enable(); /* Profiler measurements fixture */ $timersProperty = new ReflectionProperty('Magento_Profiler', '_timers'); $timersProperty->setAccessible(true); $timersProperty->setValue(include __DIR__ . '/_files/timers.php'); $timersProperty->setAccessible(false); }
public function testEnableDisable() { Magento_Profiler::start('another_root_level_timer'); Magento_Profiler::stop('another_root_level_timer'); Magento_Profiler::disable(); Magento_Profiler::start('this_timer_should_be_ignored'); Magento_Profiler::stop('this_timer_should_be_ignored'); Magento_Profiler::enable(); Magento_Profiler::start('another_root_level_timer'); Magento_Profiler::start('another_nested_timer'); Magento_Profiler::stop('another_nested_timer'); Magento_Profiler::stop('another_root_level_timer'); $expectedTimers = array('some_root_timer', 'some_root_timer->some_nested_timer', 'some_root_timer->some_nested_timer->some_deeply_nested_timer', 'one_more_root_timer', 'another_root_level_timer', 'another_root_level_timer->another_nested_timer'); $actualTimers = Magento_Profiler::getTimers(); $this->assertEquals($expectedTimers, $actualTimers); }
/** * @expectedException InvalidArgumentException * @expectedExceptionMessage Timer name must not contain a nesting separator. */ public function testClearException() { Magento_Profiler::enable(); Magento_Profiler::clear('timer ' . Magento_Profiler::NESTING_SEPARATOR . ' name'); }
/** * Test display method */ public function testDisplayAndRegisterOutput() { $outputOne = $this->getMock('Magento_Profiler_Driver_Standard_OutputInterface'); $outputOne->expects($this->once())->method('display')->with($this->_stat); $outputTwo = $this->getMock('Magento_Profiler_Driver_Standard_OutputInterface'); $outputTwo->expects($this->once())->method('display')->with($this->_stat); $this->_driver->registerOutput($outputOne); $this->_driver->registerOutput($outputTwo); Magento_Profiler::enable(); $this->_driver->display(); Magento_Profiler::disable(); $this->_driver->display(); }
public static function setUpBeforeClass() { self::$_testResourceName = 'testtest_' . mt_rand(1000, 9999) . '_setup'; Magento_Profiler::enable(); }