diff options
Diffstat (limited to 'tests/lib/AppFramework')
41 files changed, 116 insertions, 116 deletions
diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php index cd3e7c47ad6..ccc694942a1 100644 --- a/tests/lib/AppFramework/AppTest.php +++ b/tests/lib/AppFramework/AppTest.php @@ -56,7 +56,7 @@ class AppTest extends \Test\TestCase { private $controllerMethod; private $appPath; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->container = new \OC\AppFramework\DependencyInjection\DIContainer('test', array()); @@ -121,7 +121,7 @@ class AppTest extends \Test\TestCase { } - protected function tearDown() { + protected function tearDown(): void { rrmdir($this->appPath); parent::tearDown(); } diff --git a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php index 30da40d36b4..8eb76d3cb27 100644 --- a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php +++ b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php @@ -50,7 +50,7 @@ class AuthPublicShareControllerTest extends \Test\TestCase { private $controller; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(IRequest::class); diff --git a/tests/lib/AppFramework/Controller/ControllerTest.php b/tests/lib/AppFramework/Controller/ControllerTest.php index 7831b44b632..b1cb1ceab6f 100644 --- a/tests/lib/AppFramework/Controller/ControllerTest.php +++ b/tests/lib/AppFramework/Controller/ControllerTest.php @@ -62,7 +62,7 @@ class ControllerTest extends \Test\TestCase { private $controller; private $app; - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $request = new Request( @@ -94,10 +94,10 @@ class ControllerTest extends \Test\TestCase { $this->controller = new ChildController($this->app, $request); } - /** - * @expectedException \DomainException - */ + public function testFormatResonseInvalidFormat() { + $this->expectException(\DomainException::class); + $this->controller->buildResponse(null, 'test'); } diff --git a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php index f20f996d5a3..318647ca844 100644 --- a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php +++ b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php @@ -47,7 +47,7 @@ class PublicShareControllerTest extends \Test\TestCase { private $controller; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(IRequest::class); diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php index a49440949e3..c8ebda55a86 100644 --- a/tests/lib/AppFramework/Db/EntityTest.php +++ b/tests/lib/AppFramework/Db/EntityTest.php @@ -66,7 +66,7 @@ class EntityTest extends \Test\TestCase { private $entity; - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $this->entity = new TestEntity(); } @@ -129,25 +129,25 @@ class EntityTest extends \Test\TestCase { } - /** - * @expectedException \BadFunctionCallException - */ + public function testCallShouldOnlyWorkForGetterSetter(){ + $this->expectException(\BadFunctionCallException::class); + $this->entity->something(); } - /** - * @expectedException \BadFunctionCallException - */ + public function testGetterShouldFailIfAttributeNotDefined(){ + $this->expectException(\BadFunctionCallException::class); + $this->entity->getTest(); } - /** - * @expectedException \BadFunctionCallException - */ + public function testSetterShouldFailIfAttributeNotDefined(){ + $this->expectException(\BadFunctionCallException::class); + $this->entity->setTest(); } @@ -245,10 +245,10 @@ class EntityTest extends \Test\TestCase { $this->assertThat($entity->isAnotherBool(), new IsType(IsType::TYPE_BOOL)); } - /** - * @expectedException BadFunctionCallException - */ + public function testIsGetterShoudFailForOtherType() { + $this->expectException(\BadFunctionCallException::class); + $entity = new TestEntity(); $entity->setName('hello'); $this->assertThat($entity->isName(), new IsType(IsType::TYPE_BOOL)); diff --git a/tests/lib/AppFramework/Db/MapperTest.php b/tests/lib/AppFramework/Db/MapperTest.php index 8ca80fe11ca..a69980fbb26 100644 --- a/tests/lib/AppFramework/Db/MapperTest.php +++ b/tests/lib/AppFramework/Db/MapperTest.php @@ -60,7 +60,7 @@ class MapperTest extends MapperTestUtility { */ private $mapper; - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $this->mapper = new ExampleMapper($this->db); } diff --git a/tests/lib/AppFramework/Db/MapperTestUtility.php b/tests/lib/AppFramework/Db/MapperTestUtility.php index 71c21a06632..83156a3932b 100644 --- a/tests/lib/AppFramework/Db/MapperTestUtility.php +++ b/tests/lib/AppFramework/Db/MapperTestUtility.php @@ -40,7 +40,7 @@ abstract class MapperTestUtility extends \Test\TestCase { * Run this function before the actual test to either set or initialize the * db. After this the db can be accessed by using $this->db */ - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $this->db = $this->getMockBuilder( diff --git a/tests/lib/AppFramework/Db/QBMapperTest.php b/tests/lib/AppFramework/Db/QBMapperTest.php index 279c95afaeb..6fa0fe10d88 100644 --- a/tests/lib/AppFramework/Db/QBMapperTest.php +++ b/tests/lib/AppFramework/Db/QBMapperTest.php @@ -105,7 +105,7 @@ class QBMapperTest extends \Test\TestCase { /** * @throws \ReflectionException */ - protected function setUp() { + protected function setUp(): void { $this->db = $this->getMockBuilder(IDBConnection::class) ->disableOriginalConstructor() @@ -127,9 +127,7 @@ class QBMapperTest extends \Test\TestCase { $this->mapper = new QBTestMapper($this->db); } - /** - * - */ + public function testInsertEntityParameterTypeMapping() { $entity = new QBTestEntity(); $entity->setIntProp(123); @@ -166,9 +164,7 @@ class QBMapperTest extends \Test\TestCase { $this->mapper->insert($entity); } - /** - * - */ + public function testUpdateEntityParameterTypeMapping() { $entity = new QBTestEntity(); $entity->setId(789); @@ -214,9 +210,7 @@ class QBMapperTest extends \Test\TestCase { $this->mapper->update($entity); } - /** - * - */ + public function testGetParameterTypeForProperty() { $entity = new QBTestEntity(); diff --git a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php index 03c8265f2c9..95d368a448e 100644 --- a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php +++ b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php @@ -41,7 +41,7 @@ class DIContainerTest extends \Test\TestCase { /** @var DIContainer|\PHPUnit_Framework_MockObject_MockObject */ private $container; - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $this->container = $this->getMockBuilder(DIContainer::class) ->setMethods(['isAdminUser']) diff --git a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php index d3d3f73e872..669063f4d18 100644 --- a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php +++ b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php @@ -56,7 +56,7 @@ class DIIntergrationTests extends TestCase { /** @var ServerContainer */ private $server; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->server = new ServerContainer(); diff --git a/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php b/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php index b6163e90386..6acc21550d1 100644 --- a/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php +++ b/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php @@ -21,7 +21,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase { /** @var ContentSecurityPolicy */ private $contentSecurityPolicy; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->contentSecurityPolicy = new ContentSecurityPolicy(); } diff --git a/tests/lib/AppFramework/Http/DataResponseTest.php b/tests/lib/AppFramework/Http/DataResponseTest.php index 6f81e0d56b4..b629c6d385e 100644 --- a/tests/lib/AppFramework/Http/DataResponseTest.php +++ b/tests/lib/AppFramework/Http/DataResponseTest.php @@ -34,7 +34,7 @@ class DataResponseTest extends \Test\TestCase { */ private $response; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->response = new DataResponse(); } diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php index 404c94abdbd..1c4dc067b5d 100644 --- a/tests/lib/AppFramework/Http/DispatcherTest.php +++ b/tests/lib/AppFramework/Http/DispatcherTest.php @@ -87,7 +87,7 @@ class DispatcherTest extends \Test\TestCase { private $http; private $reflector; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->controllerMethod = 'test'; diff --git a/tests/lib/AppFramework/Http/DownloadResponseTest.php b/tests/lib/AppFramework/Http/DownloadResponseTest.php index 97c7ab75ed9..5f816eaeb76 100644 --- a/tests/lib/AppFramework/Http/DownloadResponseTest.php +++ b/tests/lib/AppFramework/Http/DownloadResponseTest.php @@ -38,7 +38,7 @@ class DownloadResponseTest extends \Test\TestCase { */ protected $response; - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $this->response = new ChildDownloadResponse('file', 'content'); } diff --git a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php index d9bdfccf60b..c19caad23c7 100644 --- a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php +++ b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php @@ -21,7 +21,7 @@ class EmptyContentSecurityPolicyTest extends \Test\TestCase { /** @var EmptyContentSecurityPolicy */ private $contentSecurityPolicy; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->contentSecurityPolicy = new EmptyContentSecurityPolicy(); } diff --git a/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php b/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php index 9150503c632..1cebc9ef0f2 100644 --- a/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php +++ b/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php @@ -31,7 +31,7 @@ class EmptyFeaturePolicyTest extends \Test\TestCase { /** @var EmptyFeaturePolicy */ private $policy; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->policy = new EmptyFeaturePolicy(); } diff --git a/tests/lib/AppFramework/Http/FeaturePolicyTest.php b/tests/lib/AppFramework/Http/FeaturePolicyTest.php index 7c2cc3fa6d5..af21457bf0a 100644 --- a/tests/lib/AppFramework/Http/FeaturePolicyTest.php +++ b/tests/lib/AppFramework/Http/FeaturePolicyTest.php @@ -31,7 +31,7 @@ class FeaturePolicyTest extends \Test\TestCase { /** @var EmptyFeaturePolicy */ private $policy; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->policy = new FeaturePolicy(); } diff --git a/tests/lib/AppFramework/Http/FileDisplayResponseTest.php b/tests/lib/AppFramework/Http/FileDisplayResponseTest.php index 2c91289a5c9..5ca7635614c 100644 --- a/tests/lib/AppFramework/Http/FileDisplayResponseTest.php +++ b/tests/lib/AppFramework/Http/FileDisplayResponseTest.php @@ -34,7 +34,7 @@ class FileDisplayResponseTest extends \Test\TestCase { /** @var FileDisplayResponse */ private $response; - public function setup() { + protected function setUp(): void { $this->file = $this->getMockBuilder('OCP\Files\File') ->getMock(); diff --git a/tests/lib/AppFramework/Http/HttpTest.php b/tests/lib/AppFramework/Http/HttpTest.php index 0a13e1e11e5..79c03ce1ab0 100644 --- a/tests/lib/AppFramework/Http/HttpTest.php +++ b/tests/lib/AppFramework/Http/HttpTest.php @@ -34,7 +34,7 @@ class HttpTest extends \Test\TestCase { */ private $http; - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $this->server = array(); diff --git a/tests/lib/AppFramework/Http/JSONResponseTest.php b/tests/lib/AppFramework/Http/JSONResponseTest.php index a74bd67d1f0..95d2e2a0a4c 100644 --- a/tests/lib/AppFramework/Http/JSONResponseTest.php +++ b/tests/lib/AppFramework/Http/JSONResponseTest.php @@ -36,7 +36,7 @@ class JSONResponseTest extends \Test\TestCase { */ private $json; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->json = new JSONResponse(); } @@ -89,11 +89,11 @@ class JSONResponseTest extends \Test\TestCase { $this->assertEquals($expected, $this->json->render()); } - /** - * @expectedException \Exception - * @expectedExceptionMessage Could not json_encode due to invalid non UTF-8 characters in the array: array ( - */ + public function testRenderWithNonUtf8Encoding() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Could not json_encode due to invalid non UTF-8 characters in the array: array ('); + $params = ['test' => hex2bin('e9')]; $this->json->setData($params); $this->json->render(); diff --git a/tests/lib/AppFramework/Http/RedirectResponseTest.php b/tests/lib/AppFramework/Http/RedirectResponseTest.php index 218f748a88b..fc24f323c6a 100644 --- a/tests/lib/AppFramework/Http/RedirectResponseTest.php +++ b/tests/lib/AppFramework/Http/RedirectResponseTest.php @@ -33,7 +33,7 @@ class RedirectResponseTest extends \Test\TestCase { */ protected $response; - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $this->response = new RedirectResponse('/url'); } diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index 2ad660405f3..000a05f7913 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -31,7 +31,7 @@ class RequestTest extends \Test\TestCase { /** @var CsrfTokenManager */ protected $csrfTokenManager; - protected function setUp() { + protected function setUp(): void { parent::setUp(); if (in_array('fakeinput', stream_get_wrappers())) { @@ -45,7 +45,7 @@ class RequestTest extends \Test\TestCase { ->disableOriginalConstructor()->getMock(); } - protected function tearDown() { + protected function tearDown(): void { stream_wrapper_unregister('fakeinput'); parent::tearDown(); } @@ -103,10 +103,10 @@ class RequestTest extends \Test\TestCase { } - /** - * @expectedException \RuntimeException - */ + public function testImmutableArrayAccess() { + $this->expectException(\RuntimeException::class); + $vars = array( 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'), 'method' => 'GET' @@ -123,10 +123,10 @@ class RequestTest extends \Test\TestCase { $request['nickname'] = 'Janey'; } - /** - * @expectedException \RuntimeException - */ + public function testImmutableMagicAccess() { + $this->expectException(\RuntimeException::class); + $vars = array( 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'), 'method' => 'GET' @@ -143,10 +143,10 @@ class RequestTest extends \Test\TestCase { $request->{'nickname'} = 'Janey'; } - /** - * @expectedException \LogicException - */ + public function testGetTheMethodRight() { + $this->expectException(\LogicException::class); + $vars = array( 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'), 'method' => 'GET', @@ -1246,11 +1246,11 @@ class RequestTest extends \Test\TestCase { $this->assertSame('www.owncloud.org', self::invokePrivate($request, 'getOverwriteHost')); } - /** - * @expectedException \Exception - * @expectedExceptionMessage The requested uri(/foo.php) cannot be processed by the script '/var/www/index.php') - */ + public function testGetPathInfoNotProcessible() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('The requested uri(/foo.php) cannot be processed by the script \'/var/www/index.php\')'); + $request = new Request( [ 'server' => [ @@ -1267,11 +1267,11 @@ class RequestTest extends \Test\TestCase { $request->getPathInfo(); } - /** - * @expectedException \Exception - * @expectedExceptionMessage The requested uri(/foo.php) cannot be processed by the script '/var/www/index.php') - */ + public function testGetRawPathInfoNotProcessible() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('The requested uri(/foo.php) cannot be processed by the script \'/var/www/index.php\')'); + $request = new Request( [ 'server' => [ diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php index 64b9566f8e6..3d76d24496d 100644 --- a/tests/lib/AppFramework/Http/ResponseTest.php +++ b/tests/lib/AppFramework/Http/ResponseTest.php @@ -35,7 +35,7 @@ class ResponseTest extends \Test\TestCase { */ private $childResponse; - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $this->childResponse = new Response(); } diff --git a/tests/lib/AppFramework/Http/StreamResponseTest.php b/tests/lib/AppFramework/Http/StreamResponseTest.php index ef9a37aa81b..ef7132013b6 100644 --- a/tests/lib/AppFramework/Http/StreamResponseTest.php +++ b/tests/lib/AppFramework/Http/StreamResponseTest.php @@ -33,7 +33,7 @@ class StreamResponseTest extends \Test\TestCase { /** @var IOutput */ private $output; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->output = $this->getMockBuilder('OCP\\AppFramework\\Http\\IOutput') ->disableOriginalConstructor() diff --git a/tests/lib/AppFramework/Http/TemplateResponseTest.php b/tests/lib/AppFramework/Http/TemplateResponseTest.php index b5586222257..6672b4d0c1e 100644 --- a/tests/lib/AppFramework/Http/TemplateResponseTest.php +++ b/tests/lib/AppFramework/Http/TemplateResponseTest.php @@ -33,7 +33,7 @@ class TemplateResponseTest extends \Test\TestCase { */ private $tpl; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->tpl = new TemplateResponse('app', 'home'); diff --git a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php index 7f817e03c1e..8971fe4df06 100644 --- a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php @@ -47,7 +47,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase { /** @var AdditionalScriptsMiddleware */ private $middleWare; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->dispatcher = $this->createMock(EventDispatcherInterface::class); diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php index e38aa4525e3..965637cb4c4 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php @@ -113,7 +113,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { */ private $dispatcher; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->dispatcher = new MiddlewareDispatcher(); diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php index 8f9c60b65ff..4ac6fa647f7 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php @@ -43,7 +43,7 @@ class MiddlewareTest extends \Test\TestCase { /** @var Response */ private $response; - protected function setUp(){ + protected function setUp(): void { parent::setUp(); $this->middleware = new ChildMiddleware(); diff --git a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php index cca3b4aecca..e001e48acd2 100644 --- a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php @@ -42,7 +42,7 @@ class OCSMiddlewareTest extends \Test\TestCase { */ private $request; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->request = $this->getMockBuilder(IRequest::class) diff --git a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php index 4ad90b6e874..82f354d127d 100644 --- a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php @@ -49,7 +49,7 @@ class PublicShareMiddlewareTest extends \Test\TestCase { private $middleware; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(IRequest::class); diff --git a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php index ae2345764ff..f6ce5c27b22 100644 --- a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php @@ -40,7 +40,7 @@ class BruteForceMiddlewareTest extends TestCase { /** @var BruteForceMiddleware */ private $bruteForceMiddleware; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->reflector = $this->createMock(ControllerMethodReflector::class); diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php index 0fab8803073..1c12a4aa153 100644 --- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php @@ -34,7 +34,7 @@ class CORSMiddlewareTest extends \Test\TestCase { /** @var Controller */ private $controller; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->reflector = new ControllerMethodReflector(); $this->session = $this->createMock(Session::class); @@ -102,9 +102,10 @@ class CORSMiddlewareTest extends \Test\TestCase { /** * @CORS - * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\SecurityException */ public function testCorsIgnoredIfWithCredentialsHeaderPresent() { + $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\SecurityException::class); + $request = new Request( [ 'server' => [ @@ -171,9 +172,10 @@ class CORSMiddlewareTest extends \Test\TestCase { /** * @CORS - * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\SecurityException */ public function testCORSShouldFailIfPasswordLoginIsForbidden() { + $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\SecurityException::class); + $request = new Request( ['server' => [ 'PHP_AUTH_USER' => 'user', @@ -196,9 +198,10 @@ class CORSMiddlewareTest extends \Test\TestCase { /** * @CORS - * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\SecurityException */ public function testCORSShouldNotAllowCookieAuth() { + $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\SecurityException::class); + $request = new Request( ['server' => [ 'PHP_AUTH_USER' => 'user', @@ -251,11 +254,11 @@ class CORSMiddlewareTest extends \Test\TestCase { $this->assertEquals($expected, $response); } - /** - * @expectedException \Exception - * @expectedExceptionMessage A regular exception - */ + public function testAfterExceptionWithRegularException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('A regular exception'); + $request = new Request( ['server' => [ 'PHP_AUTH_USER' => 'user', diff --git a/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php index 9f2b4e399fb..6d089e3880d 100644 --- a/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php @@ -48,7 +48,7 @@ class CSPMiddlewareTest extends \Test\TestCase { /** @var ContentSecurityPolicyNonceManager|MockObject */ private $cspNonceManager; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->controller = $this->createMock(Controller::class); diff --git a/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php index d2ab8d05919..e136d783616 100644 --- a/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php @@ -44,7 +44,7 @@ class FeaturePolicyMiddlewareTest extends \Test\TestCase { /** @var FeaturePolicyManager|MockObject */ private $manager; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->controller = $this->createMock(Controller::class); diff --git a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php index c981e840d70..7a64b6cbcad 100644 --- a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php @@ -49,7 +49,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase { /** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */ private $timeFactory; - protected function setUp() { + protected function setUp(): void { $this->reflector = new ControllerMethodReflector(); $this->session = $this->createMock(ISession::class); $this->userSession = $this->createMock(IUserSession::class); diff --git a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php index 1317a07447d..3a06531eefd 100644 --- a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php @@ -45,7 +45,7 @@ class RateLimitingMiddlewareTest extends TestCase { /** @var RateLimitingMiddleware */ private $rateLimitingMiddleware; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(IRequest::class); @@ -229,11 +229,11 @@ class RateLimitingMiddlewareTest extends TestCase { $this->rateLimitingMiddleware->beforeController($controller, 'testMethod'); } - /** - * @expectedException \Exception - * @expectedExceptionMessage My test exception - */ + public function testAfterExceptionWithOtherException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('My test exception'); + /** @var Controller|\PHPUnit_Framework_MockObject_MockObject $controller */ $controller = $this->createMock(Controller::class); diff --git a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php index c92c131780e..6f3c3f32adc 100644 --- a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php @@ -43,7 +43,7 @@ class SameSiteCookieMiddlewareTest extends TestCase { /** @var ControllerMethodReflector|\PHPUnit_Framework_MockObject_MockObject */ private $reflector; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(Request::class); diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index 00bb1a0bb3c..ae0e6ff484d 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -77,7 +77,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */ private $l10n; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->controller = $this->createMock(Controller::class); @@ -256,9 +256,10 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @PublicPage - * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException */ public function testCsrfCheck(){ + $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class); + $this->request->expects($this->once()) ->method('passesCSRFCheck') ->will($this->returnValue(false)); @@ -300,9 +301,10 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @PublicPage - * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException */ public function testFailCsrfCheck(){ + $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class); + $this->request->expects($this->once()) ->method('passesCSRFCheck') ->will($this->returnValue(false)); @@ -317,9 +319,10 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @PublicPage * @StrictCookieRequired - * @expectedException \OC\Appframework\Middleware\Security\Exceptions\StrictCookieMissingException */ public function testStrictCookieRequiredCheck() { + $this->expectException(\OC\Appframework\Middleware\Security\Exceptions\StrictCookieMissingException::class); + $this->request->expects($this->never()) ->method('passesCSRFCheck'); $this->request->expects($this->once()) diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php index 2cd61c73c71..db2a9d5b625 100644 --- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php @@ -26,7 +26,7 @@ class SessionMiddlewareTest extends \Test\TestCase { /** @var Controller */ private $controller; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->reflector = new ControllerMethodReflector(); diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php index 559561a8ccd..1b7ab054a0f 100644 --- a/tests/lib/AppFramework/Routing/RoutingTest.php +++ b/tests/lib/AppFramework/Routing/RoutingTest.php @@ -122,11 +122,11 @@ class RoutingTest extends \Test\TestCase $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something'); } - /** - * @expectedException \UnexpectedValueException - */ + public function testSimpleRouteWithBrokenName() { + $this->expectException(\UnexpectedValueException::class); + $routes = array('routes' => array( array('name' => 'folders_open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete') )); @@ -144,10 +144,10 @@ class RoutingTest extends \Test\TestCase $config->register(); } - /** - * @expectedException \UnexpectedValueException - */ + public function testSimpleOCSRouteWithBrokenName() { + $this->expectException(\UnexpectedValueException::class); + $routes = ['ocs' => [ ['name' => 'folders_open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete'] ]]; diff --git a/tests/lib/AppFramework/Utility/SimpleContainerTest.php b/tests/lib/AppFramework/Utility/SimpleContainerTest.php index b2f6c6ad8d0..0341be14af9 100644 --- a/tests/lib/AppFramework/Utility/SimpleContainerTest.php +++ b/tests/lib/AppFramework/Utility/SimpleContainerTest.php @@ -61,7 +61,7 @@ class SimpleContainerTest extends \Test\TestCase { private $container; - public function setUp() { + protected function setUp(): void { $this->container = new SimpleContainer(); } @@ -72,18 +72,18 @@ class SimpleContainerTest extends \Test\TestCase { } - /** - * @expectedException \OCP\AppFramework\QueryException - */ + public function testNothingRegistered() { + $this->expectException(\OCP\AppFramework\QueryException::class); + $this->container->query('something really hard'); } - /** - * @expectedException \OCP\AppFramework\QueryException - */ + public function testNotAClass() { + $this->expectException(\OCP\AppFramework\QueryException::class); + $this->container->query('Test\AppFramework\Utility\TestInterface'); } @@ -189,10 +189,10 @@ class SimpleContainerTest extends \Test\TestCase { $this->assertEquals('abc', $this->container->query($query)); } - /** - * @expectedException \OCP\AppFramework\QueryException - */ + public function testConstructorComplexNoTestParameterFound() { + $this->expectException(\OCP\AppFramework\QueryException::class); + $object = $this->container->query( 'Test\AppFramework\Utility\ClassComplexConstructor' ); |