Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-01-20 01:30:34 +0300
committerCarl Schwan <carl@carlschwan.eu>2022-04-04 11:28:26 +0300
commit7d272c54d013538746d6731097ec37f360effb5d (patch)
treed754c4184926ea8011bd2b0fe276adebaf4082f6 /tests
parentcf4c77e064fd52d891bc842d78431cceb2f34952 (diff)
Add a built-in profiler inside Nextcloud
The webui is provided by a seperate application named profiler Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/AppFramework/AppTest.php5
-rw-r--r--tests/lib/Memcache/FactoryTest.php15
2 files changed, 13 insertions, 7 deletions
diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php
index 595a556a9a8..3dc62246e97 100644
--- a/tests/lib/AppFramework/AppTest.php
+++ b/tests/lib/AppFramework/AppTest.php
@@ -71,7 +71,7 @@ class AppTest extends \Test\TestCase {
$this->container[$this->controllerName] = $this->controller;
$this->container['Dispatcher'] = $this->dispatcher;
$this->container['OCP\\AppFramework\\Http\\IOutput'] = $this->io;
- $this->container['urlParams'] = [];
+ $this->container['urlParams'] = ['_route' => 'not-profiler'];
$this->appPath = __DIR__ . '/../../../apps/namespacetestapp';
$infoXmlPath = $this->appPath . '/appinfo/info.xml';
@@ -183,6 +183,7 @@ class AppTest extends \Test\TestCase {
public function testCoreApp() {
$this->container['AppName'] = 'core';
$this->container['OC\Core\Controller\Foo'] = $this->controller;
+ $this->container['urlParams'] = ['_route' => 'not-profiler'];
$return = ['HTTP/2.0 200 OK', [], [], null, new Response()];
$this->dispatcher->expects($this->once())
@@ -200,6 +201,7 @@ class AppTest extends \Test\TestCase {
public function testSettingsApp() {
$this->container['AppName'] = 'settings';
$this->container['OCA\Settings\Controller\Foo'] = $this->controller;
+ $this->container['urlParams'] = ['_route' => 'not-profiler'];
$return = ['HTTP/2.0 200 OK', [], [], null, new Response()];
$this->dispatcher->expects($this->once())
@@ -217,6 +219,7 @@ class AppTest extends \Test\TestCase {
public function testApp() {
$this->container['AppName'] = 'bar';
$this->container['OCA\Bar\Controller\Foo'] = $this->controller;
+ $this->container['urlParams'] = ['_route' => 'not-profiler'];
$return = ['HTTP/2.0 200 OK', [], [], null, new Response()];
$this->dispatcher->expects($this->once())
diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php
index 0e995865b5d..f16f70eddc2 100644
--- a/tests/lib/Memcache/FactoryTest.php
+++ b/tests/lib/Memcache/FactoryTest.php
@@ -23,12 +23,13 @@ namespace Test\Memcache;
use OC\Memcache\NullCache;
use Psr\Log\LoggerInterface;
+use OCP\Profiler\IProfiler;
class Test_Factory_Available_Cache1 extends NullCache {
public function __construct($prefix = '') {
}
- public static function isAvailable() {
+ public static function isAvailable(): bool {
return true;
}
}
@@ -37,7 +38,7 @@ class Test_Factory_Available_Cache2 extends NullCache {
public function __construct($prefix = '') {
}
- public static function isAvailable() {
+ public static function isAvailable(): bool {
return true;
}
}
@@ -46,7 +47,7 @@ class Test_Factory_Unavailable_Cache1 extends NullCache {
public function __construct($prefix = '') {
}
- public static function isAvailable() {
+ public static function isAvailable(): bool {
return false;
}
}
@@ -55,7 +56,7 @@ class Test_Factory_Unavailable_Cache2 extends NullCache {
public function __construct($prefix = '') {
}
- public static function isAvailable() {
+ public static function isAvailable(): bool {
return false;
}
}
@@ -119,7 +120,8 @@ class FactoryTest extends \Test\TestCase {
public function testCacheAvailability($localCache, $distributedCache, $lockingCache,
$expectedLocalCache, $expectedDistributedCache, $expectedLockingCache) {
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
- $factory = new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache, $lockingCache);
+ $profiler = $this->getMockBuilder(IProfiler::class)->getMock();
+ $factory = new \OC\Memcache\Factory('abc', $logger, $profiler, $localCache, $distributedCache, $lockingCache);
$this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache));
$this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache));
$this->assertTrue(is_a($factory->createLocking(), $expectedLockingCache));
@@ -132,6 +134,7 @@ class FactoryTest extends \Test\TestCase {
$this->expectException(\OCP\HintException::class);
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
- new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache);
+ $profiler = $this->getMockBuilder(IProfiler::class)->getMock();
+ new \OC\Memcache\Factory('abc', $logger, $profiler, $localCache, $distributedCache);
}
}