Merge pull request #24712 from owncloud/fix-test-namespaces

Fix test namespaces [a-e]
This commit is contained in:
Vincent Petry 2016-05-19 10:30:07 +02:00
commit e36a27d21c
39 changed files with 107 additions and 74 deletions

View file

@ -22,8 +22,9 @@
*/
namespace OC\AppFramework;
namespace Test\AppFramework;
use OC\AppFramework\App;
use OCP\AppFramework\Http\Response;

View file

@ -22,9 +22,10 @@
*/
namespace OCP\AppFramework;
namespace Test\AppFramework\Controller;
use OC\AppFramework\Http\Request;
use OCP\AppFramework\ApiController;
class ChildApiController extends ApiController {};

View file

@ -22,9 +22,10 @@
*/
namespace OCP\AppFramework;
namespace Test\AppFramework\Controller;
use OC\AppFramework\Http\Request;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\DataResponse;

View file

@ -22,10 +22,11 @@
*/
namespace OCP\AppFramework;
namespace Test\AppFramework\Controller;
use OC\AppFramework\Http\Request;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
class ChildOCSController extends OCSController {}

View file

@ -21,7 +21,10 @@
*
*/
namespace OCP\AppFramework\Db;
namespace Test\AppFramework\Db;
use OCP\AppFramework\Db\Entity;
/**

View file

@ -24,11 +24,11 @@
*/
namespace OC\AppFramework\DependencyInjection;
namespace Test\AppFramework\DependencyInjection;
use \OC\AppFramework\Http\Request;
class DIContainerTest extends \Test\TestCase {
private $container;

View file

@ -7,7 +7,7 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\ContentSecurityPolicy;

View file

@ -22,7 +22,7 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;

View file

@ -22,8 +22,10 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OC\AppFramework\Http\Dispatcher;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;

View file

@ -22,9 +22,11 @@
*/
namespace OCP\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http\DownloadResponse;
class ChildDownloadResponse extends DownloadResponse {
};

View file

@ -7,7 +7,7 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\EmptyContentSecurityPolicy;

View file

@ -22,7 +22,7 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OC\AppFramework\Http;

View file

@ -24,7 +24,7 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;

View file

@ -22,7 +22,7 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http\OCSResponse;

View file

@ -22,9 +22,10 @@
*/
namespace OCP\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\RedirectResponse;
class RedirectResponseTest extends \Test\TestCase {

View file

@ -8,8 +8,9 @@
* See the COPYING-README file.
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OC\AppFramework\Http\Request;
use OC\Security\CSRF\CsrfToken;
use OC\Security\CSRF\CsrfTokenManager;
use OCP\Security\ISecureRandom;

View file

@ -22,7 +22,7 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http\Response;

View file

@ -22,10 +22,11 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http\StreamResponse;
use OCP\AppFramework\Http\IOutput;
use OCP\AppFramework\Http;

View file

@ -22,7 +22,7 @@
*/
namespace OC\AppFramework\Http;
namespace Test\AppFramework\Http;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http;

View file

@ -22,7 +22,7 @@
*/
namespace OC\AppFramework;
namespace Test\AppFramework\Middleware;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\MiddlewareDispatcher;

View file

@ -22,7 +22,7 @@
*/
namespace OC\AppFramework;
namespace Test\AppFramework\Middleware;
use OC\AppFramework\Http\Request;
use OCP\AppFramework\Middleware;

View file

@ -10,9 +10,10 @@
*/
namespace OC\AppFramework\Middleware\Security;
namespace Test\AppFramework\Middleware\Security;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\Security\CORSMiddleware;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OC\AppFramework\Middleware\Security\Exceptions\SecurityException;
use OCP\AppFramework\Http;

View file

@ -22,7 +22,7 @@
namespace OC\AppFramework\Middleware\Security;
namespace Test\AppFramework\Middleware\Security;
use OC\AppFramework\Http;
use OC\AppFramework\Http\Request;
@ -31,6 +31,7 @@ use OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryExcept
use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException;
use OC\AppFramework\Middleware\Security\Exceptions\NotLoggedInException;
use OC\AppFramework\Middleware\Security\Exceptions\SecurityException;
use OC\AppFramework\Middleware\Security\SecurityMiddleware;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OC\Security\CSP\ContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;

View file

@ -10,7 +10,7 @@
*/
namespace OC\AppFramework\Middleware\Security;
namespace Test\AppFramework\Middleware;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\SessionMiddleware;

View file

@ -1,8 +1,10 @@
<?php
namespace OC\AppFramework\Routing;
namespace Test\AppFramework\Routing;
use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Routing\RouteActionHandler;
use OC\AppFramework\Routing\RouteConfig;
class RoutingTest extends \Test\TestCase
{

View file

@ -22,9 +22,11 @@
*/
namespace OC\AppFramework\Utility;
namespace Test\AppFramework\Utility;
use OC\AppFramework\Utility\ControllerMethodReflector;
class BaseController {
/**
@ -66,7 +68,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testReadAnnotation(){
$reader = new ControllerMethodReflector();
$reader->reflect(
'\OC\AppFramework\Utility\ControllerMethodReflectorTest',
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadAnnotation'
);
@ -81,7 +83,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testReadAnnotationNoLowercase(){
$reader = new ControllerMethodReflector();
$reader->reflect(
'\OC\AppFramework\Utility\ControllerMethodReflectorTest',
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadAnnotationNoLowercase'
);
@ -97,7 +99,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testReadTypeIntAnnotations(){
$reader = new ControllerMethodReflector();
$reader->reflect(
'\OC\AppFramework\Utility\ControllerMethodReflectorTest',
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadTypeIntAnnotations'
);
@ -117,7 +119,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testReadTypeIntAnnotationsScalarTypes(){
$reader = new ControllerMethodReflector();
$reader->reflect(
'\OC\AppFramework\Utility\ControllerMethodReflectorTest',
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'arguments3'
);
@ -135,7 +137,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testReadTypeDoubleAnnotations(){
$reader = new ControllerMethodReflector();
$reader->reflect(
'\OC\AppFramework\Utility\ControllerMethodReflectorTest',
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadTypeDoubleAnnotations'
);
@ -149,7 +151,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testReadTypeWhitespaceAnnotations(){
$reader = new ControllerMethodReflector();
$reader->reflect(
'\OC\AppFramework\Utility\ControllerMethodReflectorTest',
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'testReadTypeWhitespaceAnnotations'
);
@ -161,7 +163,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testReflectParameters() {
$reader = new ControllerMethodReflector();
$reader->reflect(
'\OC\AppFramework\Utility\ControllerMethodReflectorTest',
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'arguments'
);
@ -173,7 +175,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testReflectParameters2() {
$reader = new ControllerMethodReflector();
$reader->reflect(
'\OC\AppFramework\Utility\ControllerMethodReflectorTest',
'\Test\AppFramework\Utility\ControllerMethodReflectorTest',
'arguments2'
);
@ -183,7 +185,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testInheritance() {
$reader = new ControllerMethodReflector();
$reader->reflect('OC\AppFramework\Utility\EndController', 'test');
$reader->reflect('Test\AppFramework\Utility\EndController', 'test');
$this->assertTrue($reader->hasAnnotation('Annotation'));
}
@ -191,7 +193,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testInheritanceOverride() {
$reader = new ControllerMethodReflector();
$reader->reflect('OC\AppFramework\Utility\EndController', 'test2');
$reader->reflect('Test\AppFramework\Utility\EndController', 'test2');
$this->assertTrue($reader->hasAnnotation('NoAnnotation'));
$this->assertFalse($reader->hasAnnotation('Annotation'));
@ -200,7 +202,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
public function testInheritanceOverrideNoDocblock() {
$reader = new ControllerMethodReflector();
$reader->reflect('OC\AppFramework\Utility\EndController', 'test3');
$reader->reflect('Test\AppFramework\Utility\EndController', 'test3');
$this->assertFalse($reader->hasAnnotation('Annotation'));
}

View file

@ -6,23 +6,26 @@
* See the COPYING-README file.
*/
namespace Test\Archive;
use OC\Archive\TAR;
class Test_Archive_TAR extends Test_Archive {
class TARTest extends TestBase {
protected function setUp() {
parent::setUp();
if (OC_Util::runningOnWindows()) {
if (\OC_Util::runningOnWindows()) {
$this->markTestSkipped('[Windows] tar archives are not supported on Windows');
}
}
protected function getExisting() {
$dir = OC::$SERVERROOT . '/tests/data';
$dir = \OC::$SERVERROOT . '/tests/data';
return new TAR($dir . '/data.tar.gz');
}
protected function getNew() {
return new TAR(OCP\Files::tmpFile('.tar.gz'));
return new TAR(\OCP\Files::tmpFile('.tar.gz'));
}
}

View file

@ -6,20 +6,23 @@
* See the COPYING-README file.
*/
abstract class Test_Archive extends \Test\TestCase {
namespace Test\Archive;
abstract class TestBase extends \Test\TestCase {
/**
* @var OC_Archive
* @var \OC\Archive\Archive
*/
protected $instance;
/**
* get the existing test archive
* @return OC_Archive
* @return \OC\Archive\Archive
*/
abstract protected function getExisting();
/**
* get a new archive for write testing
* @return OC_Archive
* @return \OC\Archive\Archive
*/
abstract protected function getNew();
@ -51,17 +54,17 @@ abstract class Test_Archive extends \Test\TestCase {
public function testContent() {
$this->instance=$this->getExisting();
$dir=OC::$SERVERROOT.'/tests/data';
$dir=\OC::$SERVERROOT.'/tests/data';
$textFile=$dir.'/lorem.txt';
$this->assertEquals(file_get_contents($textFile), $this->instance->getFile('lorem.txt'));
$tmpFile=OCP\Files::tmpFile('.txt');
$tmpFile=\OCP\Files::tmpFile('.txt');
$this->instance->extractFile('lorem.txt', $tmpFile);
$this->assertEquals(file_get_contents($textFile), file_get_contents($tmpFile));
}
public function testWrite() {
$dir=OC::$SERVERROOT.'/tests/data';
$dir=\OC::$SERVERROOT.'/tests/data';
$textFile=$dir.'/lorem.txt';
$this->instance=$this->getNew();
$this->assertEquals(0, count($this->instance->getFiles()));
@ -76,7 +79,7 @@ abstract class Test_Archive extends \Test\TestCase {
}
public function testReadStream() {
$dir=OC::$SERVERROOT.'/tests/data';
$dir=\OC::$SERVERROOT.'/tests/data';
$this->instance=$this->getExisting();
$fh=$this->instance->getStream('lorem.txt', 'r');
$this->assertTrue((bool)$fh);
@ -85,11 +88,11 @@ abstract class Test_Archive extends \Test\TestCase {
$this->assertEquals(file_get_contents($dir.'/lorem.txt'), $content);
}
public function testWriteStream() {
$dir=OC::$SERVERROOT.'/tests/data';
$dir=\OC::$SERVERROOT.'/tests/data';
$this->instance=$this->getNew();
$fh=$this->instance->getStream('lorem.txt', 'w');
$source=fopen($dir.'/lorem.txt', 'r');
OCP\Files::streamCopy($source, $fh);
\OCP\Files::streamCopy($source, $fh);
fclose($source);
fclose($fh);
$this->assertTrue($this->instance->fileExists('lorem.txt'));
@ -107,18 +110,18 @@ abstract class Test_Archive extends \Test\TestCase {
$this->assertFalse($this->instance->fileExists('/test/'));
}
public function testExtract() {
$dir=OC::$SERVERROOT.'/tests/data';
$dir=\OC::$SERVERROOT.'/tests/data';
$this->instance=$this->getExisting();
$tmpDir=OCP\Files::tmpFolder();
$tmpDir=\OCP\Files::tmpFolder();
$this->instance->extract($tmpDir);
$this->assertEquals(true, file_exists($tmpDir.'lorem.txt'));
$this->assertEquals(true, file_exists($tmpDir.'dir/lorem.txt'));
$this->assertEquals(true, file_exists($tmpDir.'logo-wide.png'));
$this->assertEquals(file_get_contents($dir.'/lorem.txt'), file_get_contents($tmpDir.'lorem.txt'));
OCP\Files::rmdirr($tmpDir);
\OCP\Files::rmdirr($tmpDir);
}
public function testMoveRemove() {
$dir=OC::$SERVERROOT.'/tests/data';
$dir=\OC::$SERVERROOT.'/tests/data';
$textFile=$dir.'/lorem.txt';
$this->instance=$this->getNew();
$this->instance->addFile('lorem.txt', $textFile);
@ -131,7 +134,7 @@ abstract class Test_Archive extends \Test\TestCase {
$this->assertFalse($this->instance->fileExists('target.txt'));
}
public function testRecursive() {
$dir=OC::$SERVERROOT.'/tests/data';
$dir=\OC::$SERVERROOT.'/tests/data';
$this->instance=$this->getNew();
$this->instance->addRecursive('/dir', $dir);
$this->assertTrue($this->instance->fileExists('/dir/lorem.txt'));

View file

@ -6,23 +6,26 @@
* See the COPYING-README file.
*/
namespace Test\Archive;
use OC\Archive\ZIP;
class Test_Archive_ZIP extends Test_Archive {
class ZIPTest extends TestBase {
protected function setUp() {
parent::setUp();
if (OC_Util::runningOnWindows()) {
if (\OC_Util::runningOnWindows()) {
$this->markTestSkipped('[Windows] ');
}
}
protected function getExisting() {
$dir = OC::$SERVERROOT . '/tests/data';
$dir = \OC::$SERVERROOT . '/tests/data';
return new ZIP($dir . '/data.zip');
}
protected function getNew() {
return new ZIP(OCP\Files::tmpFile('.zip'));
return new ZIP(\OCP\Files::tmpFile('.zip'));
}
}

View file

@ -29,7 +29,7 @@ namespace Test\Cache;
*
* @package Test\Cache
*/
class CappedMemoryCache extends \Test_Cache {
class CappedMemoryCache extends TestCache {
public function setUp() {
parent::setUp();
$this->instance = new \OC\Cache\CappedMemoryCache();

View file

@ -29,7 +29,7 @@ namespace Test\Cache;
*
* @package Test\Cache
*/
class FileCache extends \Test_Cache {
class FileCache extends TestCache {
/**
* @var string
* */

View file

@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
abstract class Test_Cache extends \Test\TestCase {
namespace Test\Cache;
abstract class TestCache extends \Test\TestCase {
/**
* @var \OCP\ICache cache;
*/

View file

@ -5,8 +5,7 @@ namespace Test\Comments;
use OCP\Comments\IComment;
use Test\TestCase;
class Test_Comments_Comment extends TestCase
{
class CommentTest extends TestCase {
public function testSettersValidInput() {
$comment = new \OC\Comments\Comment();

View file

@ -6,12 +6,11 @@ use OCP\Comments\ICommentsManager;
use Test\TestCase;
/**
* Class Test_Comments_Manager
* Class ManagerTest
*
* @group DB
*/
class Test_Comments_Manager extends TestCase
{
class ManagerTest extends TestCase {
public function setUp() {
parent::setUp();

View file

@ -6,12 +6,14 @@
* See the COPYING-README file.
*/
namespace Test\DB;
/**
* Class TestMySqlMigration
* Class MySqlMigration
*
* @group DB
*/
class TestMySqlMigration extends \Test\TestCase {
class MySqlMigration extends \Test\TestCase {
/** @var \Doctrine\DBAL\Connection */
private $connection;

View file

@ -6,12 +6,14 @@
* See the COPYING-README file.
*/
namespace Test\DB;
/**
* Class TestSqliteMigration
* Class SqliteMigration
*
* @group DB
*/
class TestSqliteMigration extends \Test\TestCase {
class SqliteMigration extends \Test\TestCase {
/** @var \Doctrine\DBAL\Connection */
private $connection;

View file

@ -9,7 +9,7 @@
namespace Test\Memcache;
abstract class Cache extends \Test_Cache {
abstract class Cache extends \Test\Cache\TestCache {
/**
* @var \OCP\IMemcache cache;
*/