<?php
-namespace src\Util;
+namespace Friendica\Test\src\Util;
+use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Configuration;
use Friendica\Test\MockedTest;
use Friendica\Util\Profiler;
use Mockery\MockInterface;
{
parent::setUp();
- $this->logger = \Mockery::mock('Psr\Log\LoggerInterface');
+ $this->logger = \Mockery::mock(LoggerInterface::class);
}
/**
*/
public function testSetUp()
{
- $profiler = new Profiler(true, true);
+ $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache->shouldReceive('get')
+ ->withAnyArgs()
+ ->andReturn(true)
+ ->twice();
+ $profiler = new Profiler($configCache);
}
/**
*/
public function testSaveTimestamp($timestamp, $name, array $functions)
{
- $profiler = new Profiler(true, true);
+ $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache->shouldReceive('get')
+ ->withAnyArgs()
+ ->andReturn(true)
+ ->twice();
+
+ $profiler = new Profiler($configCache);
foreach ($functions as $function) {
$profiler->saveTimestamp($timestamp, $name, $function);
*/
public function testReset($timestamp, $name, array $functions)
{
- $profiler = new Profiler(true, true);
+ $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache->shouldReceive('get')
+ ->withAnyArgs()
+ ->andReturn(true)
+ ->twice();
+
+ $profiler = new Profiler($configCache);
$profiler->saveTimestamp($timestamp, $name);
$profiler->reset();
->shouldReceive('info')
->once();
- $profiler = new Profiler(true, true);
+ $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache->shouldReceive('get')
+ ->withAnyArgs()
+ ->andReturn(true)
+ ->twice();
+
+ $profiler = new Profiler($configCache);
foreach ($data as $perf => $items) {
foreach ($items['functions'] as $function) {
*/
public function testEnableDisable()
{
- $profiler = new Profiler(true, false);
+ $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache->shouldReceive('get')
+ ->with('system', 'profiler')
+ ->andReturn(true)
+ ->once();
+ $configCache->shouldReceive('get')
+ ->with('rendertime', 'callstack')
+ ->andReturn(false)
+ ->once();
+
+ $profiler = new Profiler($configCache);
$this->assertFalse($profiler->isRendertime());
$this->assertEmpty($profiler->getRendertimeString());
$profiler->saveTimestamp(time(), 'network', 'test1');
- $profiler->update(false, false);
+ $config = \Mockery::mock(Configuration::class);
+ $config->shouldReceive('get')
+ ->with('system', 'profiler')
+ ->andReturn(false)
+ ->once();
+ $config->shouldReceive('get')
+ ->with('rendertime', 'callstack')
+ ->andReturn(false)
+ ->once();
+
+ $profiler->update($config);
$this->assertFalse($profiler->isRendertime());
$this->assertEmpty($profiler->getRendertimeString());
- $profiler->update(true, true);
+ $config->shouldReceive('get')
+ ->with('system', 'profiler')
+ ->andReturn(true)
+ ->once();
+ $config->shouldReceive('get')
+ ->with('rendertime', 'callstack')
+ ->andReturn(true)
+ ->once();
+
+ $profiler->update($config);
$profiler->saveTimestamp(time(), 'database', 'test2');