aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/AppFramework/AppTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/AppFramework/AppTest.php')
-rw-r--r--tests/lib/AppFramework/AppTest.php76
1 files changed, 30 insertions, 46 deletions
diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php
index 3dc62246e97..f9b7cf50675 100644
--- a/tests/lib/AppFramework/AppTest.php
+++ b/tests/lib/AppFramework/AppTest.php
@@ -1,32 +1,18 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework;
use OC\AppFramework\App;
+use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Http\Dispatcher;
use OCP\AppFramework\Controller;
-use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\IOutput;
use OCP\AppFramework\Http\Response;
function rrmdir($directory) {
@@ -43,7 +29,7 @@ function rrmdir($directory) {
class AppTest extends \Test\TestCase {
- private $container;
+ private DIContainer $container;
private $io;
private $api;
private $controller;
@@ -58,10 +44,10 @@ class AppTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
- $this->container = new \OC\AppFramework\DependencyInjection\DIContainer('test', []);
+ $this->container = new DIContainer('test', []);
$this->controller = $this->createMock(Controller::class);
$this->dispatcher = $this->createMock(Dispatcher::class);
- $this->io = $this->createMock(Http\IOutput::class);
+ $this->io = $this->createMock(IOutput::class);
$this->headers = ['key' => 'value'];
$this->output = 'hi';
@@ -69,24 +55,24 @@ class AppTest extends \Test\TestCase {
$this->controllerMethod = 'method';
$this->container[$this->controllerName] = $this->controller;
- $this->container['Dispatcher'] = $this->dispatcher;
- $this->container['OCP\\AppFramework\\Http\\IOutput'] = $this->io;
+ $this->container[Dispatcher::class] = $this->dispatcher;
+ $this->container[IOutput::class] = $this->io;
$this->container['urlParams'] = ['_route' => 'not-profiler'];
$this->appPath = __DIR__ . '/../../../apps/namespacetestapp';
$infoXmlPath = $this->appPath . '/appinfo/info.xml';
mkdir($this->appPath . '/appinfo', 0777, true);
- $xml = '<?xml version="1.0" encoding="UTF-8"?>' .
- '<info>' .
- '<id>namespacetestapp</id>' .
- '<namespace>NameSpaceTestApp</namespace>' .
- '</info>';
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>'
+ . '<info>'
+ . '<id>namespacetestapp</id>'
+ . '<namespace>NameSpaceTestApp</namespace>'
+ . '</info>';
file_put_contents($infoXmlPath, $xml);
}
- public function testControllerNameAndMethodAreBeingPassed() {
+ public function testControllerNameAndMethodAreBeingPassed(): void {
$return = ['HTTP/2.0 200 OK', [], [], null, new Response()];
$this->dispatcher->expects($this->once())
->method('dispatch')
@@ -102,19 +88,19 @@ class AppTest extends \Test\TestCase {
}
- public function testBuildAppNamespace() {
+ public function testBuildAppNamespace(): void {
$ns = App::buildAppNamespace('someapp');
$this->assertEquals('OCA\Someapp', $ns);
}
- public function testBuildAppNamespaceCore() {
+ public function testBuildAppNamespaceCore(): void {
$ns = App::buildAppNamespace('someapp', 'OC\\');
$this->assertEquals('OC\Someapp', $ns);
}
- public function testBuildAppNamespaceInfoXml() {
+ public function testBuildAppNamespaceInfoXml(): void {
$ns = App::buildAppNamespace('namespacetestapp', 'OCA\\');
$this->assertEquals('OCA\NameSpaceTestApp', $ns);
}
@@ -126,7 +112,7 @@ class AppTest extends \Test\TestCase {
}
- public function testOutputIsPrinted() {
+ public function testOutputIsPrinted(): void {
$return = ['HTTP/2.0 200 OK', [], [], $this->output, new Response()];
$this->dispatcher->expects($this->once())
->method('dispatch')
@@ -139,17 +125,15 @@ class AppTest extends \Test\TestCase {
App::main($this->controllerName, $this->controllerMethod, $this->container, []);
}
- public function dataNoOutput() {
+ public static function dataNoOutput(): array {
return [
['HTTP/2.0 204 No content'],
['HTTP/2.0 304 Not modified'],
];
}
- /**
- * @dataProvider dataNoOutput
- */
- public function testNoOutput(string $statusCode) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataNoOutput')]
+ public function testNoOutput(string $statusCode): void {
$return = [$statusCode, [], [], $this->output, new Response()];
$this->dispatcher->expects($this->once())
->method('dispatch')
@@ -165,7 +149,7 @@ class AppTest extends \Test\TestCase {
}
- public function testCallbackIsCalled() {
+ public function testCallbackIsCalled(): void {
$mock = $this->getMockBuilder('OCP\AppFramework\Http\ICallbackResponse')
->getMock();
@@ -180,8 +164,8 @@ class AppTest extends \Test\TestCase {
App::main($this->controllerName, $this->controllerMethod, $this->container, []);
}
- public function testCoreApp() {
- $this->container['AppName'] = 'core';
+ public function testCoreApp(): void {
+ $this->container['appName'] = 'core';
$this->container['OC\Core\Controller\Foo'] = $this->controller;
$this->container['urlParams'] = ['_route' => 'not-profiler'];
@@ -198,8 +182,8 @@ class AppTest extends \Test\TestCase {
App::main('Foo', $this->controllerMethod, $this->container);
}
- public function testSettingsApp() {
- $this->container['AppName'] = 'settings';
+ public function testSettingsApp(): void {
+ $this->container['appName'] = 'settings';
$this->container['OCA\Settings\Controller\Foo'] = $this->controller;
$this->container['urlParams'] = ['_route' => 'not-profiler'];
@@ -216,8 +200,8 @@ class AppTest extends \Test\TestCase {
App::main('Foo', $this->controllerMethod, $this->container);
}
- public function testApp() {
- $this->container['AppName'] = 'bar';
+ public function testApp(): void {
+ $this->container['appName'] = 'bar';
$this->container['OCA\Bar\Controller\Foo'] = $this->controller;
$this->container['urlParams'] = ['_route' => 'not-profiler'];