Пример #1
0
 /**
  * Register profiler driver to involve it into the results processing
  */
 protected function _registerDriver()
 {
     if (!$this->_isDriverRegistered) {
         $this->_isDriverRegistered = true;
         \Magento\Framework\Profiler::add($this->_driver);
     }
 }
Пример #2
0
 /**
  * @param string $method
  * @param array $params
  * @param \Zend_Cache_Backend $cacheBackend
  * @param \Zend_Cache_Core $cacheFrontend
  * @param string $expectedProfileId
  * @param array $expectedProfilerTags
  * @param mixed $expectedResult
  * @dataProvider proxyMethodDataProvider
  */
 public function testProxyMethod($method, $params, $cacheBackend, $cacheFrontend, $expectedProfileId, $expectedProfilerTags, $expectedResult)
 {
     // Cache frontend setup
     $frontendMock = $this->getMock('Magento\\Framework\\Cache\\FrontendInterface');
     $frontendMock->expects($this->any())->method('getBackend')->will($this->returnValue($cacheBackend));
     $frontendMock->expects($this->any())->method('getLowLevelFrontend')->will($this->returnValue($cacheFrontend));
     // Profiler setup
     $driver = $this->getMock('Magento\\Framework\\Profiler\\DriverInterface');
     $driver->expects($this->once())->method('start')->with($expectedProfileId, $expectedProfilerTags);
     $driver->expects($this->once())->method('stop')->with($expectedProfileId);
     \Magento\Framework\Profiler::add($driver);
     // Test
     $object = new \Magento\Framework\Cache\Frontend\Decorator\Profiler($frontendMock, ['Zend_Cache_Backend_']);
     $helper = new \Magento\TestFramework\Helper\ProxyTesting();
     $result = $helper->invokeWithExpectations($object, $frontendMock, $method, $params, $expectedResult);
     $this->assertSame($expectedResult, $result);
 }
Пример #3
0
 /**
  * @param string $timerName
  * @param array $tags
  * @dataProvider passedFilterDataProvider
  */
 public function testTagFilterPass($timerName, array $tags = null)
 {
     $driver = $this->_getDriverMock();
     $driver->expects($this->once())->method('start')->with($timerName, $tags);
     \Magento\Framework\Profiler::add($driver);
     \Magento\Framework\Profiler::addTagFilter('type', 'test');
     \Magento\Framework\Profiler::start($timerName, $tags);
 }