diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-04-04 13:56:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-04 13:56:37 +0300 |
commit | 135bdb3d5830672214149fa0b75fadd29b20b844 (patch) | |
tree | f2c1bc68c733829c90090f71d712f78efbc77083 /tests/lib | |
parent | 498d3aea060ed496e2b5351108718e198b021d00 (diff) | |
parent | 7d272c54d013538746d6731097ec37f360effb5d (diff) |
Merge pull request #30823 from nextcloud/work/profiler
Built-in profiler
This adds the required API for collecting information about requests. This information
can then be displayed with the new 'profiler' app.
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/AppFramework/AppTest.php | 5 | ||||
-rw-r--r-- | tests/lib/Memcache/FactoryTest.php | 15 |
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); } } |