+
+ $output = $profiler->getRendertimeString();
+
+ foreach ($data as $perf => $items) {
+ foreach ($items['functions'] as $function) {
+ // assert that the output contains the functions
+ self::assertMatchesRegularExpression('/' . $function . ': \d+/', $output);
+ }
+ }
+ }
+
+ /**
+ * Test different enable and disable states of the profiler
+ */
+ public function testEnableDisable()
+ {
+ $configCache = \Mockery::mock(Cache::class);
+ $configCache->shouldReceive('get')
+ ->with('system', 'profiler')
+ ->andReturn(true)
+ ->once();
+ $configCache->shouldReceive('get')
+ ->with('rendertime', 'callstack')
+ ->andReturn(false)
+ ->once();
+
+ $profiler = new Profiler($configCache);
+
+ self::assertFalse($profiler->isRendertime());
+ self::assertEmpty($profiler->getRendertimeString());
+
+ $profiler->saveTimestamp(time(), 'network', 'test1');
+
+ $config = \Mockery::mock(IManageConfigValues::class);
+ $config->shouldReceive('get')
+ ->with('system', 'profiler')
+ ->andReturn(false)
+ ->once();
+ $config->shouldReceive('get')
+ ->with('rendertime', 'callstack')
+ ->andReturn(false)
+ ->once();
+
+ $profiler->update($config);
+
+ self::assertFalse($profiler->isRendertime());
+ self::assertEmpty($profiler->getRendertimeString());
+
+ $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');
+
+ self::assertTrue($profiler->isRendertime());
+ $output = $profiler->getRendertimeString();
+ self::assertMatchesRegularExpression('/test1: \d+/', $output);
+ self::assertMatchesRegularExpression('/test2: \d+/', $output);