Move tests/ to PSR-4 (#24731)

* Move a-b to PSR-4

* Move c-d to PSR-4

* Move e+g to PSR-4

* Move h-l to PSR-4

* Move m-r to PSR-4

* Move s-u to PSR-4

* Move files/ to PSR-4

* Move remaining tests to PSR-4

* Remove Test\ from old autoloader
This commit is contained in:
Joas Schilling 2016-05-20 15:38:20 +02:00 committed by Thomas Müller
parent 2ef751b1ec
commit 94ad54ec9b
257 changed files with 171 additions and 180 deletions

View File

@ -117,8 +117,6 @@ class Autoloader {
// This File is considered public API, so we make sure that the class
// can still be loaded, although the PSR-4 paths have not been loaded.
$paths[] = \OC::$SERVERROOT . '/tests/lib/TestCase.php';
} elseif (strpos($class, 'Test\\') === 0) {
$paths[] = \OC::$SERVERROOT . '/tests/lib/' . strtolower(str_replace('\\', '/', substr($class, 5)) . '.php');
}
return $paths;
}

View File

@ -10,7 +10,6 @@ require_once __DIR__ . '/../lib/base.php';
\OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true);
\OC::$composerAutoloader->addPsr4('Tests\\', OC::$SERVERROOT . '/tests/', true);
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
// load all enabled apps
\OC_App::loadApps();

View File

@ -19,13 +19,14 @@
*
*/
namespace OC\App\CodeChecker;
namespace Test\App\CodeChecker;
use OC\App\CodeChecker\InfoChecker;
use OC\App\InfoParser;
use Test\TestCase;
class InfoCheckerTest extends TestCase {
/** @var InfoChecker */
/** @var InfoChecker */
protected $infoChecker;
public static function setUpBeforeClass() {

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
namespace Test\AppCodeChecker;
namespace Test\App\CodeChecker;
use OC\App\CodeChecker\CodeChecker;
use OC\App\CodeChecker\EmptyCheck;

View File

@ -14,7 +14,7 @@ use OC\App\Platform;
use OCP\IL10N;
use Test\TestCase;
class DependencyAnalyzer extends TestCase {
class DependencyAnalyzerTest extends TestCase {
/** @var Platform */
private $platformMock;

View File

@ -13,7 +13,7 @@ use OC;
use OCP\IURLGenerator;
use Test\TestCase;
class InfoParser extends TestCase {
class InfoParserTest extends TestCase {
/** @var \OC\App\InfoParser */
private $parser;

View File

@ -19,7 +19,7 @@ use Test\TestCase;
* @package Test\App
* @group DB
*/
class Manager extends TestCase {
class ManagerTest extends TestCase {
/**
* @return \OCP\IAppConfig | \PHPUnit_Framework_MockObject_MockObject
*/

View File

@ -11,7 +11,7 @@ namespace Test\App;
use OC;
class PlatformRepository extends \Test\TestCase {
class PlatformRepositoryTest extends \Test\TestCase {
/**
* @dataProvider providesVersions

View File

@ -10,13 +10,13 @@
namespace Test;
/**
* Class AppConfig
* Class AppConfigTest
*
* @group DB
*
* @package Test
*/
class AppConfig extends TestCase {
class AppConfigTest extends TestCase {
/** @var \OCP\IAppConfig */
protected $appConfig;

View File

@ -1,4 +1,7 @@
<?php
namespace Test\AppFramework\Http;
/**
* Copy of http://dk1.php.net/manual/en/stream.streamwrapper.example-1.php
* Used to simulate php://input for Request tests

View File

@ -34,11 +34,10 @@ class RequestTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
require_once __DIR__ . '/requeststream.php';
if (in_array('fakeinput', stream_get_wrappers())) {
stream_wrapper_unregister('fakeinput');
}
stream_wrapper_register('fakeinput', 'RequestStream');
stream_wrapper_register('fakeinput', 'Test\AppFramework\Http\RequestStream');
$this->secureRandom = $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock();
$this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();

View File

@ -8,7 +8,7 @@
namespace Test;
class AutoLoader extends TestCase {
class AutoLoaderTest extends TestCase {
/**
* @var \OC\Autoloader $loader
*/
@ -43,12 +43,6 @@ class AutoLoader extends TestCase {
], $this->loader->findClass('Test\TestCase'));
}
public function testLoadTestNamespace() {
$this->assertEquals([
\OC::$SERVERROOT . '/tests/lib/foo/bar.php'
], $this->loader->findClass('Test\Foo\Bar'));
}
public function testLoadCore() {
$this->assertEquals([
\OC::$SERVERROOT . '/lib/private/legacy/foo/bar.php',

View File

@ -18,7 +18,7 @@ use Test\TestCase;
* @group DB
* @package Test\BackgroundJob
*/
class JobList extends TestCase {
class JobListTest extends TestCase {
/** @var \OC\BackgroundJob\JobList */
protected $instance;

View File

@ -8,7 +8,7 @@
namespace Test\BackgroundJob;
class Job extends \Test\TestCase {
class JobTest extends \Test\TestCase {
private $run = false;
protected function setUp() {

View File

@ -12,7 +12,7 @@ class TestQueuedJob extends \OC\BackgroundJob\QueuedJob {
private $testCase;
/**
* @param QueuedJob $testCase
* @param QueuedJobTest $testCase
*/
public function __construct($testCase) {
$this->testCase = $testCase;
@ -23,7 +23,7 @@ class TestQueuedJob extends \OC\BackgroundJob\QueuedJob {
}
}
class QueuedJob extends \Test\TestCase {
class QueuedJobTest extends \Test\TestCase {
/**
* @var DummyJobList $jobList
*/

View File

@ -18,7 +18,7 @@ class TestJob extends \OC\BackgroundJob\Job {
private $callback;
/**
* @param Job $testCase
* @param JobTest $testCase
* @param callable $callback
*/
public function __construct($testCase = null, $callback = null) {

View File

@ -12,7 +12,7 @@ class TestTimedJob extends \OC\BackgroundJob\TimedJob {
private $testCase;
/**
* @param TimedJob $testCase
* @param TimedJobTest $testCase
*/
public function __construct($testCase) {
$this->setInterval(10);
@ -24,7 +24,7 @@ class TestTimedJob extends \OC\BackgroundJob\TimedJob {
}
}
class TimedJob extends \Test\TestCase {
class TimedJobTest extends \Test\TestCase {
/**
* @var DummyJobList $jobList
*/

View File

@ -23,13 +23,13 @@
namespace Test\Cache;
/**
* Class FileCache
* Class CappedMemoryCacheTest
*
* @group DB
*
* @package Test\Cache
*/
class CappedMemoryCache extends TestCache {
class CappedMemoryCacheTest extends TestCache {
public function setUp() {
parent::setUp();
$this->instance = new \OC\Cache\CappedMemoryCache();

View File

@ -23,13 +23,13 @@
namespace Test\Cache;
/**
* Class FileCache
* Class FileCacheTest
*
* @group DB
*
* @package Test\Cache
*/
class FileCache extends TestCache {
class FileCacheTest extends TestCache {
/**
* @var string
* */

View File

@ -17,7 +17,7 @@ use Test\TestCase;
class SimpleCommand implements ICommand {
public function handle() {
AsyncBus::$lastCommand = 'SimpleCommand';
AsyncBusTest::$lastCommand = 'SimpleCommand';
}
}
@ -29,7 +29,7 @@ class StateFullCommand implements ICommand {
}
public function handle() {
AsyncBus::$lastCommand = $this->state;
AsyncBusTest::$lastCommand = $this->state;
}
}
@ -37,18 +37,18 @@ class FilesystemCommand implements ICommand {
use FileAccess;
public function handle() {
AsyncBus::$lastCommand = 'FileAccess';
AsyncBusTest::$lastCommand = 'FileAccess';
}
}
function basicFunction() {
AsyncBus::$lastCommand = 'function';
AsyncBusTest::$lastCommand = 'function';
}
// clean class to prevent phpunit putting closure in $this
class ThisClosureTest {
private function privateMethod() {
AsyncBus::$lastCommand = 'closure-this';
AsyncBusTest::$lastCommand = 'closure-this';
}
public function test(IBus $bus) {
@ -58,7 +58,7 @@ class ThisClosureTest {
}
}
class AsyncBus extends TestCase {
class AsyncBusTest extends TestCase {
/**
* Basic way to check output from a command
*
@ -101,7 +101,7 @@ class AsyncBus extends TestCase {
}
public function testStaticCallable() {
$this->bus->push(['\Test\Command\AsyncBus', 'DummyCommand']);
$this->bus->push(['\Test\Command\AsyncBusTest', 'DummyCommand']);
$this->runJobs();
$this->assertEquals('static', self::$lastCommand);
}
@ -121,7 +121,7 @@ class AsyncBus extends TestCase {
public function testClosure() {
$this->bus->push(function () {
AsyncBus::$lastCommand = 'closure';
AsyncBusTest::$lastCommand = 'closure';
});
$this->runJobs();
$this->assertEquals('closure', self::$lastCommand);

View File

@ -33,7 +33,7 @@ use OC\Core\Command\Background\Cron;
use OC\Core\Command\Background\WebCron;
use OC\Core\Command\Background\Ajax;
class BackgroundJobs extends TestCase {
class BackgroundJobsTest extends TestCase {
public function testCronCommand() {
$config = \OC::$server->getConfig();

View File

@ -20,7 +20,7 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
*
* @package Test\DB
*/
class Connection extends \Test\TestCase {
class ConnectionTest extends \Test\TestCase {
/**
* @var \OCP\IDBConnection
*/

View File

@ -18,7 +18,7 @@ use Doctrine\DBAL\Platforms\OraclePlatform;
*
* @package Test\DB
*/
class MDB2SchemaManager extends \Test\TestCase {
class MDB2SchemaManagerTest extends \Test\TestCase {
protected function tearDown() {
// do not drop the table for Oracle as it will create a bogus transaction

View File

@ -11,7 +11,7 @@ namespace Test\DB;
use Doctrine\DBAL\Platforms\MySqlPlatform;
class MDB2SchemaReader extends \Test\TestCase {
class MDB2SchemaReaderTest extends \Test\TestCase {
/**
* @var \OC\DB\MDB2SchemaReader $reader
*/

View File

@ -16,13 +16,13 @@ use \Doctrine\DBAL\Schema\SchemaConfig;
use OCP\IConfig;
/**
* Class Migrator
* Class MigratorTest
*
* @group DB
*
* @package Test\DB
*/
class Migrator extends \Test\TestCase {
class MigratorTest extends \Test\TestCase {
/**
* @var \Doctrine\DBAL\Connection $connection
*/

View File

@ -13,7 +13,7 @@ namespace Test\DB;
*
* @group DB
*/
class MySqlMigration extends \Test\TestCase {
class MySqlMigrationTest extends \Test\TestCase {
/** @var \Doctrine\DBAL\Connection */
private $connection;

View File

@ -13,7 +13,7 @@ namespace Test\DB;
*
* @group DB
*/
class SqliteMigration extends \Test\TestCase {
class SqliteMigrationTest extends \Test\TestCase {
/** @var \Doctrine\DBAL\Connection */
private $connection;

View File

@ -8,7 +8,7 @@
namespace Test;
class DateTimeFormatter extends TestCase {
class DateTimeFormatterTest extends TestCase {
/** @var \OC\DateTimeFormatter */
protected $formatter;
static protected $oneMinute = 60;

View File

@ -20,7 +20,7 @@
*/
namespace Test;
class FileChunking extends \Test\TestCase {
class FileChunkingTest extends \Test\TestCase {
public function dataIsComplete() {
return [

View File

@ -16,13 +16,13 @@ class LongId extends \OC\Files\Storage\Temporary {
}
/**
* Class Cache
* Class CacheTest
*
* @group DB
*
* @package Test\Files\Cache
*/
class Cache extends \Test\TestCase {
class CacheTest extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Temporary $storage ;
*/

View File

@ -44,13 +44,13 @@ class DummyUser extends \OC\User\User {
}
/**
* Class HomeCache
* Class HomeCacheTest
*
* @group DB
*
* @package Test\Files\Cache
*/
class HomeCache extends \Test\TestCase {
class HomeCacheTest extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Home $storage
*/

View File

@ -15,11 +15,11 @@ class FallBackCrossCacheMoveCache extends \OC\Files\Cache\Cache {
}
/**
* Class Cache
* Class MoveFromCacheTraitTest
*
* @group DB
*/
class MoveFromCacheTraitTest extends Cache {
class MoveFromCacheTraitTest extends CacheTest {
protected function setUp() {
parent::setUp();

View File

@ -10,13 +10,13 @@ namespace Test\Files\Cache;
use OC\Files\Cache\CacheEntry;
/**
* Class Scanner
* Class ScannerTest
*
* @group DB
*
* @package Test\Files\Cache
*/
class Scanner extends \Test\TestCase {
class ScannerTest extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Storage $storage
*/

View File

@ -13,13 +13,13 @@ use OC\Files\Storage\Temporary;
use OC\Files\View;
/**
* Class UpdaterLegacy
* Class UpdaterLegacyTest
*
* @group DB
*
* @package Test\Files\Cache
*/
class UpdaterLegacy extends \Test\TestCase {
class UpdaterLegacyTest extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Storage $storage
*/

View File

@ -13,13 +13,13 @@ use OC\Files\Storage\Temporary;
use OC\Files\View;
/**
* Class Updater
* Class UpdaterTest
*
* @group DB
*
* @package Test\Files\Cache
*/
class Updater extends \Test\TestCase {
class UpdaterTest extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Storage
*/

View File

@ -9,13 +9,13 @@
namespace Test\Files\Cache;
/**
* Class Watcher
* Class WatcherTest
*
* @group DB
*
* @package Test\Files\Cache
*/
class Watcher extends \Test\TestCase {
class WatcherTest extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Storage[] $storages

View File

@ -8,7 +8,7 @@
namespace Test\Files\Cache\Wrapper;
use Test\Files\Cache\Cache;
use Test\Files\Cache\CacheTest;
/**
* Class CacheJail
@ -17,7 +17,7 @@ use Test\Files\Cache\Cache;
*
* @package Test\Files\Cache\Wrapper
*/
class CacheJail extends Cache {
class CacheJailTest extends CacheTest {
/**
* @var \OC\Files\Cache\Cache $sourceCache
*/

Some files were not shown because too many files have changed in this diff Show More