X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2Fsrc%2FUtil%2FProfilerTest.php;h=25d044354c6534a59367a7ae8a50f55432066cc3;hb=2292263780000a50e1e7583bc170cca619d86f42;hp=ba47858a0939cbcd8baa744d24f732d1ed671c95;hpb=3c76826793feeb933dab7a07dab7cc7eb2efc451;p=friendica.git diff --git a/tests/src/Util/ProfilerTest.php b/tests/src/Util/ProfilerTest.php index ba47858a09..25d044354c 100644 --- a/tests/src/Util/ProfilerTest.php +++ b/tests/src/Util/ProfilerTest.php @@ -1,9 +1,28 @@ . + * + */ namespace Friendica\Test\src\Util; -use Friendica\Core\Config\Cache\ConfigCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\ValueObject\Cache; +use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Test\MockedTest; use Friendica\Util\Profiler; use Mockery\MockInterface; @@ -16,7 +35,7 @@ class ProfilerTest extends MockedTest */ private $logger; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -28,12 +47,14 @@ class ProfilerTest extends MockedTest */ public function testSetUp() { - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->withAnyArgs() ->andReturn(true) ->twice(); $profiler = new Profiler($configCache); + + self::assertInstanceOf(Profiler::class, $profiler); } /** @@ -78,14 +99,14 @@ class ProfilerTest extends MockedTest 'name' => 'rendering', 'functions' => ['test', 'it7'], ], - 'parser' => [ + 'session' => [ 'timestamp' => time(), - 'name' => 'parser', + 'name' => 'session', 'functions' => ['test', 'it8'], ], 'marktime' => [ 'timestamp' => time(), - 'name' => 'parser', + 'name' => 'session', 'functions' => ['test'], ], // This one isn't set during reset @@ -103,7 +124,7 @@ class ProfilerTest extends MockedTest */ public function testSaveTimestamp($timestamp, $name, array $functions) { - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->withAnyArgs() ->andReturn(true) @@ -115,16 +136,16 @@ class ProfilerTest extends MockedTest $profiler->saveTimestamp($timestamp, $name, $function); } - $this->assertGreaterThanOrEqual(0, $profiler->get($name)); + self::assertGreaterThanOrEqual(0, $profiler->get($name)); } /** * Test the Profiler reset * @dataProvider dataPerformance */ - public function testReset($timestamp, $name, array $functions) + public function testReset($timestamp, $name) { - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->withAnyArgs() ->andReturn(true) @@ -135,7 +156,7 @@ class ProfilerTest extends MockedTest $profiler->saveTimestamp($timestamp, $name); $profiler->reset(); - $this->assertEquals(0, $profiler->get($name)); + self::assertEquals(0, $profiler->get($name)); } public function dataBig() @@ -187,7 +208,7 @@ class ProfilerTest extends MockedTest ->shouldReceive('info') ->once(); - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->withAnyArgs() ->andReturn(true) @@ -208,7 +229,7 @@ class ProfilerTest extends MockedTest foreach ($data as $perf => $items) { foreach ($items['functions'] as $function) { // assert that the output contains the functions - $this->assertRegExp('/' . $function . ': \d+/', $output); + self::assertMatchesRegularExpression('/' . $function . ': \d+/', $output); } } } @@ -218,7 +239,7 @@ class ProfilerTest extends MockedTest */ public function testEnableDisable() { - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->with('system', 'profiler') ->andReturn(true) @@ -230,12 +251,12 @@ class ProfilerTest extends MockedTest $profiler = new Profiler($configCache); - $this->assertFalse($profiler->isRendertime()); - $this->assertEmpty($profiler->getRendertimeString()); + self::assertFalse($profiler->isRendertime()); + self::assertEmpty($profiler->getRendertimeString()); $profiler->saveTimestamp(time(), 'network', 'test1'); - $config = \Mockery::mock(IConfiguration::class); + $config = \Mockery::mock(IManageConfigValues::class); $config->shouldReceive('get') ->with('system', 'profiler') ->andReturn(false) @@ -247,8 +268,8 @@ class ProfilerTest extends MockedTest $profiler->update($config); - $this->assertFalse($profiler->isRendertime()); - $this->assertEmpty($profiler->getRendertimeString()); + self::assertFalse($profiler->isRendertime()); + self::assertEmpty($profiler->getRendertimeString()); $config->shouldReceive('get') ->with('system', 'profiler') @@ -263,9 +284,9 @@ class ProfilerTest extends MockedTest $profiler->saveTimestamp(time(), 'database', 'test2'); - $this->assertTrue($profiler->isRendertime()); + self::assertTrue($profiler->isRendertime()); $output = $profiler->getRendertimeString(); - $this->assertRegExp('/test1: \d+/', $output); - $this->assertRegExp('/test2: \d+/', $output); + self::assertMatchesRegularExpression('/test1: \d+/', $output); + self::assertMatchesRegularExpression('/test2: \d+/', $output); } }