]> source.dussan.org Git - nextcloud-server.git/commitdiff
kill superfluent classloader from tests - this approach might be of interest within...
authorThomas Müller <thomas.mueller@tmit.eu>
Tue, 20 Aug 2013 22:41:20 +0000 (00:41 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 20 Aug 2013 22:41:20 +0000 (00:41 +0200)
17 files changed:
tests/lib/appframework/AppTest.php
tests/lib/appframework/classloader.php [deleted file]
tests/lib/appframework/controller/ControllerTest.php
tests/lib/appframework/dependencyinjection/DIContainerTest.php
tests/lib/appframework/http/DispatcherTest.php
tests/lib/appframework/http/DownloadResponseTest.php
tests/lib/appframework/http/HttpTest.php
tests/lib/appframework/http/JSONResponseTest.php
tests/lib/appframework/http/RedirectResponseTest.php
tests/lib/appframework/http/RequestTest.php
tests/lib/appframework/http/ResponseTest.php
tests/lib/appframework/http/TemplateResponseTest.php
tests/lib/appframework/middleware/MiddlewareDispatcherTest.php
tests/lib/appframework/middleware/MiddlewareTest.php
tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php
tests/lib/appframework/routing/RoutingTest.php
tests/lib/appframework/utility/MethodAnnotationReaderTest.php

index dcf0e6f77e3ad2e497d5233cd7a15e31e026f3d5..e8ae8c8f673bd8f173929f6105c1963fb62343b1 100644 (file)
@@ -30,7 +30,7 @@ use OC\AppFramework\Middleware\MiddlewareDispatcher;
 
 // FIXME: loading pimpl correctly from 3rdparty repo
 require_once __DIR__ . '/../../../3rdparty/Pimple/Pimple.php';
-require_once __DIR__ . "/classloader.php";
+//require_once __DIR__ . "/classloader.php";
 
 
 class AppTest extends \PHPUnit_Framework_TestCase {
diff --git a/tests/lib/appframework/classloader.php b/tests/lib/appframework/classloader.php
deleted file mode 100644 (file)
index cd9f893..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt nukeawhale@gmail.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/>.
- *
- */
-
-// to execute without ownCloud, we need to create our own class loader
-spl_autoload_register(function ($className){
-       if (strpos($className, 'OC\\AppFramework') === 0) {
-               $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
-               $relPath = __DIR__ . '/../../../lib/' . $path;
-
-               if(file_exists($relPath)){
-                       require_once $relPath;
-               }
-       }
-
-       if (strpos($className, 'OCP\\') === 0) {
-               $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
-               $relPath = __DIR__ . '/../../../lib/public' . $path;
-
-               if(file_exists($relPath)){
-                       require_once $relPath;
-               }
-       }
-
-       // FIXME: this will most probably not work anymore
-       if (strpos($className, 'OCA\\') === 0) {
-
-               $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
-               $relPath = __DIR__ . '/../..' . $path;
-
-               if(file_exists($relPath)){
-                       require_once $relPath;
-               }
-       }
-});
index d8357c2a6852ef1cf4c3a5124d034b0b438bd160..246371d249ccfdd9674e199a130943b888a98795 100644 (file)
 namespace Test\AppFramework\Controller;
 
 use OC\AppFramework\Http\Request;
-use OC\AppFramework\Http\JSONResponse;
-use OC\AppFramework\Http\TemplateResponse;
 use OC\AppFramework\Controller\Controller;
+use OCP\AppFramework\Http\TemplateResponse;
 
 
-require_once(__DIR__ . "/../classloader.php");
+//require_once __DIR__ . "/../classloader.php";
 
 
 class ChildController extends Controller {};
index ce346f0a763b94ade868aaac876e01e60b5e4426..25fdd202839340ad233dff21caff16b8bb01e3b8 100644 (file)
@@ -29,7 +29,7 @@ namespace OC\AppFramework\DependencyInjection;
 use \OC\AppFramework\Http\Request;
 
 
-require_once(__DIR__ . "/../classloader.php");
+//require_once(__DIR__ . "/../classloader.php");
 
 
 class DIContainerTest extends \PHPUnit_Framework_TestCase {
index 2e3db110504bcbd06b40f00f5a884a8eea619b87..849b0ca97a68dcb1bb0456c0c87e1750427065cd 100644 (file)
@@ -27,7 +27,7 @@ namespace OC\AppFramework\Http;
 use OC\AppFramework\Core\API;
 use OC\AppFramework\Middleware\MiddlewareDispatcher;
 
-require_once(__DIR__ . "/../classloader.php");
+//require_once(__DIR__ . "/../classloader.php");
 
 
 class DispatcherTest extends \PHPUnit_Framework_TestCase {
@@ -69,7 +69,7 @@ class DispatcherTest extends \PHPUnit_Framework_TestCase {
                        $this->http, $this->middlewareDispatcher);
                
                $this->response = $this->getMockBuilder(
-                       '\OC\AppFramework\Http\Response')
+                       '\OCP\AppFramework\Http\Response')
                        ->disableOriginalConstructor()
                        ->getMock();
 
@@ -207,7 +207,7 @@ class DispatcherTest extends \PHPUnit_Framework_TestCase {
                $out = 'yo';
                $httpHeaders = 'Http';
                $responseHeaders = array('hell' => 'yeah');
-               $this->setMiddlewareExpections($out, $httpHeaders, $responseHeaders, true, false);              
+               $this->setMiddlewareExpections($out, $httpHeaders, $responseHeaders, true, false);
 
                $this->setExpectedException('\Exception');
                $response = $this->dispatcher->dispatch($this->controller, 
index 103cfe7588cc954d1323fae163efef546c27b15b..64fe7992b6a83d8f50d345ab61d79e1805ac8b9f 100644 (file)
@@ -25,7 +25,7 @@
 namespace OC\AppFramework\Http;
 
 
-require_once(__DIR__ . "/../classloader.php");
+//require_once(__DIR__ . "/../classloader.php");
 
 
 class ChildDownloadResponse extends DownloadResponse {};
index 306bc3caf42a0733924034c6e0c26b6650ca6044..382d511b116449aa0ecda0047db07110ebbd93ad 100644 (file)
@@ -25,7 +25,7 @@
 namespace OC\AppFramework\Http;
 
 
-require_once(__DIR__ . "/../classloader.php");
+//require_once(__DIR__ . "/../classloader.php");
 
 
 
index d15e08f6ce15c5af63ed931dc95eaa78a7379d8a..534c54cbcee726f473c1b55d59162d95b20e01bb 100644 (file)
@@ -27,7 +27,9 @@
 namespace OC\AppFramework\Http;
 
 
-require_once(__DIR__ . "/../classloader.php");
+use OCP\AppFramework\Http\JSONResponse;
+
+//require_once(__DIR__ . "/../classloader.php");
 
 
 
index a8577feed29bc7d92b8fff76c86e1d99d526aca7..1946655b0fa54ea6c95ab9cdb3fff6e0fbefe2a9 100644 (file)
@@ -25,7 +25,7 @@
 namespace OC\AppFramework\Http;
 
 
-require_once(__DIR__ . "/../classloader.php");
+//require_once(__DIR__ . "/../classloader.php");
 
 
 
index c1f56c016360ae2a3af9d5248f988e29769f2716..0371c870cf292682b70a35a35fac70d3020f2468 100644 (file)
@@ -9,8 +9,6 @@
 namespace OC\AppFramework\Http;
 
 
-require_once(__DIR__ . "/../classloader.php");
-
 class RequestTest extends \PHPUnit_Framework_TestCase {
 
        public function testRequestAccessors() {
index 621ba66545f5012c230e0e0fe13983c0a69dcebc..7e09086f80172d3f4bd0a9245434560347b47363 100644 (file)
 namespace OC\AppFramework\Http;
 
 
-require_once(__DIR__ . "/../classloader.php");
-
+use OCP\AppFramework\Http\Response;
 
 
 class ResponseTest extends \PHPUnit_Framework_TestCase {
 
-
+       /**
+        * @var \OCP\AppFramework\Http\Response
+        */
        private $childResponse;
 
        protected function setUp(){
index 30684725b72afffd7e1386829ff6b22be85714cd..3c6d29cd3392bfcb1a7c9b07923a1578a7abe212 100644 (file)
 
 namespace OC\AppFramework\Http;
 
-use OC\AppFramework\Core\API;
-
-
-require_once(__DIR__ . "/../classloader.php");
+use OCP\AppFramework\Http\TemplateResponse;
 
 
 class TemplateResponseTest extends \PHPUnit_Framework_TestCase {
 
+       /**
+        * @var \OCP\AppFramework\Http\TemplateResponse
+        */
        private $tpl;
+
+       /**
+        * @var \OCP\AppFramework\IApi
+        */
        private $api;
 
        protected function setUp() {
index bfa54a48ea396790d740d68794fac2f5a003d31c..d1b2fedee58878f78f6e22f503a8220142550565 100644 (file)
 
 namespace OC\AppFramework;
 
-use OC\AppFramework\Controller\Controller;
 use OC\AppFramework\Http\Request;
-use OC\AppFramework\Http\Response;
 use OC\AppFramework\Middleware\Middleware;
 use OC\AppFramework\Middleware\MiddlewareDispatcher;
-
-
-require_once(__DIR__ . "/../classloader.php");
+use OCP\AppFramework\Http\Response;
 
 
 // needed to test ordering
index 1adce6b3d4f186f71c98c15862763d71b91d9883..5e2930ac6a36a426127e164286ae1093a8006680 100644 (file)
@@ -28,14 +28,14 @@ use OC\AppFramework\Http\Request;
 use OC\AppFramework\Middleware\Middleware;
 
 
-require_once(__DIR__ . "/../classloader.php");
-
-
 class ChildMiddleware extends Middleware {};
 
 
 class MiddlewareTest extends \PHPUnit_Framework_TestCase {
 
+       /**
+        * @var Middleware
+        */
        private $middleware;
        private $controller;
        private $exception;
@@ -50,12 +50,13 @@ class MiddlewareTest extends \PHPUnit_Framework_TestCase {
                $this->controller = $this->getMock('OC\AppFramework\Controller\Controller',
                                array(), array($this->api, new Request()));
                $this->exception = new \Exception();
-               $this->response = $this->getMock('OC\AppFramework\Http\Response');
+               $this->response = $this->getMock('OCP\AppFramework\Http\Response');
        }
 
 
        public function testBeforeController() {
-               $this->middleware->beforeController($this->controller, null, $this->exception);
+               $this->middleware->beforeController($this->controller, null);
+               $this->assertNull(null);
        }
 
 
index 90a19c9999dbe157673591890d96cf42b516ec9c..3ed44282a7b0b3a625fd6ef88a2a67e90464123c 100644 (file)
@@ -27,11 +27,7 @@ namespace OC\AppFramework\Middleware\Security;
 use OC\AppFramework\Http\Http;
 use OC\AppFramework\Http\Request;
 use OC\AppFramework\Http\RedirectResponse;
-use OC\AppFramework\Http\JSONResponse;
-use OC\AppFramework\Middleware\Middleware;
-
-
-require_once(__DIR__ . "/../../classloader.php");
+use OCP\AppFramework\Http\JSONResponse;
 
 
 class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase {
index 92ad461471da742e7faf66524b2cf4e79a10f04a..a7aa922db12becd05a88115ca7608275d466f70f 100644 (file)
@@ -5,7 +5,6 @@ namespace OC\AppFramework\Routing;
 use OC\AppFramework\DependencyInjection\DIContainer;
 use OC\AppFramework\routing\RouteConfig;
 
-require_once(__DIR__ . "/../classloader.php");
 
 class RouteConfigTest extends \PHPUnit_Framework_TestCase
 {
index bcdcf3de37b59b99b69e00d409f478d729a8a9fd..c68812aa5c76dbcb3c76ea4a1d0e50893c368c98 100644 (file)
@@ -25,9 +25,6 @@
 namespace OC\AppFramework\Utility;
 
 
-require_once __DIR__ . "/../classloader.php";
-
-
 class MethodAnnotationReaderTest extends \PHPUnit_Framework_TestCase {