Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testAfterPutNotFoundException(): void {
$this->server->expects($this->once())
->method('on')
->willReturnCallback(
function ($method, $callback) use (&$afterPut) {
function ($method, $callback) use (&$afterPut): void {
$this->assertSame('afterMethod:PUT', $method);
$afterPut = $callback;
});
Expand All @@ -70,7 +70,7 @@ public function testAfterPut(?string $ownerId, bool $expectOwnerIdHeader,
$this->server->expects($this->once())
->method('on')
->willReturnCallback(
function ($method, $callback) use (&$afterPut) {
function ($method, $callback) use (&$afterPut): void {
$this->assertSame('afterMethod:PUT', $method);
$afterPut = $callback;
});
Expand All @@ -92,7 +92,7 @@ function ($method, $callback) use (&$afterPut) {
$expectPermissionsHeader,
$expectOwnerIdHeader,
$matcher,
$ownerId, $permissions) {
$ownerId, $permissions): void {
$invocationNumber = $matcher->numberOfInvocations();
if ($invocationNumber === 0) {
throw new LogicException('No invocations were expected');
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/AppFramework/Http/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected function setUp(): void {

$this->request = $this->createMock(Request::class);

$this->reflector = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$this->reflector = new ControllerMethodReflector(Server::get(LoggerInterface::class));

$this->dispatcher = new Dispatcher(
$this->http,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCP\AppFramework\Http\Response;
use OCP\IRequest;
use OCP\Security\Bruteforce\IThrottler;
use OCP\Server;
use Psr\Log\LoggerInterface;
use Test\AppFramework\Middleware\Security\Mock\BruteForceMiddlewareController;
use Test\TestCase;
Expand All @@ -30,7 +31,7 @@ class BruteForceMiddlewareTest extends TestCase {
protected function setUp(): void {
parent::setUp();

$this->reflector = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$this->reflector = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$this->throttler = $this->createMock(IThrottler::class);
$this->request = $this->createMock(IRequest::class);
$this->logger = $this->createMock(LoggerInterface::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use OCP\IRequest;
use OCP\IRequestId;
use OCP\Security\Bruteforce\IThrottler;
use OCP\Server;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\AppFramework\Middleware\Security\Mock\CORSMiddlewareController;
Expand All @@ -33,7 +34,7 @@ class CORSMiddlewareTest extends \Test\TestCase {

protected function setUp(): void {
parent::setUp();
$this->reflector = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$this->reflector = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$this->session = $this->createMock(Session::class);
$this->throttler = $this->createMock(IThrottler::class);
$this->logger = $this->createMock(LoggerInterface::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use OCP\ISession;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Server;
use Psr\Log\LoggerInterface;
use Test\AppFramework\Middleware\Security\Mock\PasswordConfirmationMiddlewareController;
use Test\TestCase;
Expand Down Expand Up @@ -45,7 +46,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase {
private Manager $userManager;

protected function setUp(): void {
$this->reflector = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$this->reflector = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$this->session = $this->createMock(ISession::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->user = $this->createMock(IUser::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use OCP\ISession;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Server;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\AppFramework\Middleware\Security\Mock\RateLimitingMiddlewareController;
Expand All @@ -45,7 +46,7 @@ protected function setUp(): void {

$this->request = $this->createMock(IRequest::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->reflector = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$this->reflector = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$this->limiter = $this->createMock(Limiter::class);
$this->session = $this->createMock(ISession::class);
$this->appConfig = $this->createMock(IAppConfig::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use OCP\IUser;
use OCP\IUserSession;
use OCP\Security\Ip\IRemoteAddress;
use OCP\Server;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\AppFramework\Middleware\Security\Mock\NormalController;
Expand Down Expand Up @@ -72,7 +73,7 @@ protected function setUp(): void {
'test',
$this->request
);
$this->reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$this->reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$this->logger = $this->createMock(LoggerInterface::class);
$this->navigationManager = $this->createMock(INavigationManager::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
Expand Down
31 changes: 16 additions & 15 deletions tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Test\AppFramework\Utility;

use OC\AppFramework\Utility\ControllerMethodReflector;
use OCP\Server;
use Psr\Log\LoggerInterface;

class BaseController {
Expand Down Expand Up @@ -70,7 +71,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
* @Annotation
*/
public function testReadAnnotation(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadAnnotation'
Expand All @@ -83,7 +84,7 @@ public function testReadAnnotation(): void {
* @Annotation(parameter=value)
*/
public function testGetAnnotationParameterSingle(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
self::class,
__FUNCTION__
Expand All @@ -96,7 +97,7 @@ public function testGetAnnotationParameterSingle(): void {
* @Annotation(parameter1=value1, parameter2=value2,parameter3=value3)
*/
public function testGetAnnotationParameterMultiple(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
self::class,
__FUNCTION__
Expand All @@ -112,7 +113,7 @@ public function testGetAnnotationParameterMultiple(): void {
* @param test
*/
public function testReadAnnotationNoLowercase(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadAnnotationNoLowercase'
Expand All @@ -128,7 +129,7 @@ public function testReadAnnotationNoLowercase(): void {
* @param int $test
*/
public function testReadTypeIntAnnotations(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadTypeIntAnnotations'
Expand All @@ -146,7 +147,7 @@ public function arguments3($a, float $b, int $c, $d) {
}

public function testReadTypeIntAnnotationsScalarTypes(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'arguments3'
Expand All @@ -164,7 +165,7 @@ public function testReadTypeIntAnnotationsScalarTypes(): void {
* @param double $test something special
*/
public function testReadTypeDoubleAnnotations(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadTypeDoubleAnnotations'
Expand All @@ -178,7 +179,7 @@ public function testReadTypeDoubleAnnotations(): void {
* @param string $foo
*/
public function testReadTypeWhitespaceAnnotations(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadTypeWhitespaceAnnotations'
Expand All @@ -191,7 +192,7 @@ public function testReadTypeWhitespaceAnnotations(): void {
public function arguments($arg, $arg2 = 'hi') {
}
public function testReflectParameters(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'arguments'
Expand All @@ -204,7 +205,7 @@ public function testReflectParameters(): void {
public function arguments2($arg) {
}
public function testReflectParameters2(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect(
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'arguments2'
Expand All @@ -215,15 +216,15 @@ public function testReflectParameters2(): void {


public function testInheritance(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect('Test\AppFramework\Utility\EndController', 'test');

$this->assertTrue($reader->hasAnnotation('Annotation'));
}


public function testInheritanceOverride(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect('Test\AppFramework\Utility\EndController', 'test2');

$this->assertTrue($reader->hasAnnotation('NoAnnotation'));
Expand All @@ -232,14 +233,14 @@ public function testInheritanceOverride(): void {


public function testInheritanceOverrideNoDocblock(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect('Test\AppFramework\Utility\EndController', 'test3');

$this->assertFalse($reader->hasAnnotation('Annotation'));
}

public function testRangeDetectionPsalm(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect('Test\AppFramework\Utility\EndController', 'test4');

$rangeInfo1 = $reader->getRange('rangedOne');
Expand All @@ -260,7 +261,7 @@ public function testRangeDetectionPsalm(): void {
}

public function testRangeDetectionNative(): void {
$reader = new ControllerMethodReflector(\OCP\Server::get(LoggerInterface::class));
$reader = new ControllerMethodReflector(Server::get(LoggerInterface::class));
$reader->reflect('Test\AppFramework\Utility\EndController', 'test5');

$rangeInfo1 = $reader->getRange('rangedOne');
Expand Down
Loading