Merge pull request #24726 from owncloud/tests-psr-4
Tests outside of tests/lib/ to PSR-4
This commit is contained in:
commit
dec3f9ebcb
36 changed files with 55 additions and 42 deletions
|
@ -18,13 +18,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
namespace OC\Core\Controller;
|
||||
|
||||
use OC;
|
||||
namespace Tests\Core\Controller;
|
||||
|
||||
use OC\Core\Application;
|
||||
use OCP\AppFramework\IAppContainer;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\IUser;
|
||||
|
@ -52,7 +51,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
|
||||
/** @var IAppContainer */
|
||||
private $container;
|
||||
/** @var AvatarController */
|
||||
/** @var \OC\Core\Controller\AvatarController */
|
||||
private $avatarController;
|
||||
/** @var IAvatar */
|
||||
private $avatarMock;
|
||||
|
@ -228,7 +227,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
* Fetch tmp avatar
|
||||
*/
|
||||
public function testTmpAvatarValid() {
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
|
||||
$response = $this->avatarController->getTmpAvatar();
|
||||
$this->assertEquals(Http::STATUS_OK, $response->getStatus());
|
||||
|
@ -250,14 +249,14 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
public function testPostAvatarFile() {
|
||||
//Create temp file
|
||||
$fileName = tempnam(null, "avatarTest");
|
||||
$copyRes = copy(OC::$SERVERROOT.'/tests/data/testimage.jpg', $fileName);
|
||||
$copyRes = copy(\OC::$SERVERROOT.'/tests/data/testimage.jpg', $fileName);
|
||||
$this->assertTrue($copyRes);
|
||||
|
||||
//Create file in cache
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
|
||||
//Create request return
|
||||
$reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [filesize(OC::$SERVERROOT.'/tests/data/testimage.jpg')]];
|
||||
$reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [filesize(\OC::$SERVERROOT.'/tests/data/testimage.jpg')]];
|
||||
$this->container['Request']->method('getUploadedFile')->willReturn($reqRet);
|
||||
|
||||
$response = $this->avatarController->postAvatar(null);
|
||||
|
@ -288,14 +287,14 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
public function testPostAvatarFileGif() {
|
||||
//Create temp file
|
||||
$fileName = tempnam(null, "avatarTest");
|
||||
$copyRes = copy(OC::$SERVERROOT.'/tests/data/testimage.gif', $fileName);
|
||||
$copyRes = copy(\OC::$SERVERROOT.'/tests/data/testimage.gif', $fileName);
|
||||
$this->assertTrue($copyRes);
|
||||
|
||||
//Create file in cache
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif'));
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.gif'));
|
||||
|
||||
//Create request return
|
||||
$reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => filesize(OC::$SERVERROOT.'/tests/data/testimage.gif')];
|
||||
$reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => filesize(\OC::$SERVERROOT.'/tests/data/testimage.gif')];
|
||||
$this->container['Request']->method('getUploadedFile')->willReturn($reqRet);
|
||||
|
||||
$response = $this->avatarController->postAvatar(null);
|
||||
|
@ -313,7 +312,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
//Mock node API call
|
||||
$file = $this->getMockBuilder('OCP\Files\File')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$file->method('getContent')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$file->method('getContent')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$this->container['UserFolder']->method('get')->willReturn($file);
|
||||
|
||||
//Create request return
|
||||
|
@ -349,7 +348,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
->will($this->throwException(new \Exception("foo")));
|
||||
$file = $this->getMockBuilder('OCP\Files\File')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$file->method('getContent')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$file->method('getContent')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$this->container['UserFolder']->method('get')->willReturn($file);
|
||||
|
||||
$this->container['Logger']->expects($this->once())
|
||||
|
@ -382,7 +381,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
* Test with non square crop
|
||||
*/
|
||||
public function testPostCroppedAvatarNoSquareCrop() {
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
|
||||
$this->avatarMock->method('set')->will($this->throwException(new \OC\NotSquareException));
|
||||
$this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
|
||||
|
@ -395,7 +394,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
* Check for proper reply on proper crop argument
|
||||
*/
|
||||
public function testPostCroppedAvatarValidCrop() {
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
|
||||
$response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 10]);
|
||||
|
||||
|
@ -407,7 +406,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
* Test what happens if the cropping of the avatar fails
|
||||
*/
|
||||
public function testPostCroppedAvatarException() {
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
$this->container['Cache']->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.jpg'));
|
||||
|
||||
$this->avatarMock->method('set')->will($this->throwException(new \Exception('foo')));
|
||||
$this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
|
||||
|
@ -424,7 +423,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
|||
* Check for proper reply on proper crop argument
|
||||
*/
|
||||
public function testFileTooBig() {
|
||||
$fileName = OC::$SERVERROOT.'/tests/data/testimage.jpg';
|
||||
$fileName = \OC::$SERVERROOT.'/tests/data/testimage.jpg';
|
||||
//Create request return
|
||||
$reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [21*1024*1024]];
|
||||
$this->container['Request']->method('getUploadedFile')->willReturn($reqRet);
|
|
@ -19,8 +19,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OC\Core\Controller;
|
||||
namespace Tests\Core\Controller;
|
||||
|
||||
use OC\Core\Controller\LoginController;
|
||||
use OCP\AppFramework\Http\RedirectResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IConfig;
|
|
@ -19,8 +19,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OC\Core\Controller;
|
||||
namespace Tests\Core\Controller;
|
||||
|
||||
use OC\Core\Controller\LostController;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\IConfig;
|
|
@ -20,9 +20,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OC\Core\Controller;
|
||||
namespace Tests\Core\Controller;
|
||||
|
||||
use OC\AppFramework\Http;
|
||||
use OC\Core\Controller\TokenController;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use Test\TestCase;
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Tests\Core\Templates;
|
||||
|
||||
class Templates extends \Test\TestCase {
|
||||
class TemplatesTest extends \Test\TestCase {
|
||||
|
||||
public function test403() {
|
||||
$template = \OC::$SERVERROOT . '/core/templates/403.php';
|
|
@ -19,8 +19,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OC\Settings\Controller;
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use OC\Settings\Controller\AppSettingsController;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
@ -36,7 +37,7 @@ use OC\OCSClient;
|
|||
/**
|
||||
* Class AppSettingsControllerTest
|
||||
*
|
||||
* @package OC\Settings\Controller
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class AppSettingsControllerTest extends TestCase {
|
||||
/** @var AppSettingsController */
|
|
@ -19,8 +19,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OC\Settings\Controller;
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use OC\Settings\Controller\CertificateController;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
|
@ -31,7 +32,7 @@ use OCP\ICertificateManager;
|
|||
/**
|
||||
* Class CertificateControllerTest
|
||||
*
|
||||
* @package OC\Settings\Controller
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class CertificateControllerTest extends \Test\TestCase {
|
||||
/** @var CertificateController */
|
|
@ -19,8 +19,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OC\Settings\Controller;
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use OC\Settings\Controller\CheckSetupController;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataDisplayResponse;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
|
@ -47,7 +48,7 @@ function version_compare($version1, $version2) {
|
|||
/**
|
||||
* Class CheckSetupControllerTest
|
||||
*
|
||||
* @package OC\Settings\Controller
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class CheckSetupControllerTest extends TestCase {
|
||||
/** @var int */
|
|
@ -19,10 +19,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OC\Settings\Controller;
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use OC\DB\Connection;
|
||||
use OC\Files\View;
|
||||
use OC\Settings\Controller\EncryptionController;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\ILogger;
|
||||
|
@ -33,7 +34,7 @@ use Test\TestCase;
|
|||
/**
|
||||
* Class EncryptionControllerTest
|
||||
*
|
||||
* @package OC\Settings\Controller
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class EncryptionControllerTest extends TestCase {
|
||||
/** @var IRequest */
|
|
@ -7,16 +7,18 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OC\Settings\Controller;
|
||||
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use OC\Group\Group;
|
||||
use OC\Group\MetaData;
|
||||
use \OC\Settings\Application;
|
||||
use OC\Settings\Controller\GroupsController;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
|
||||
/**
|
||||
* @package OC\Settings\Controller
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class GroupsControllerTest extends \Test\TestCase {
|
||||
|
|
@ -7,13 +7,14 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace Test\Settings\Controller;
|
||||
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use \OC\Settings\Application;
|
||||
use OC\Settings\Controller\LogSettingsController;
|
||||
|
||||
/**
|
||||
* @package OC\Settings\Controller
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class LogSettingsControllerTest extends \Test\TestCase {
|
||||
|
|
@ -7,12 +7,13 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OC\Settings\Controller;
|
||||
|
||||
use \OC\Settings\Application;
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use OC\Settings\Application;
|
||||
|
||||
/**
|
||||
* @package OC\Settings\Controller
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class MailSettingsControllerTest extends \Test\TestCase {
|
||||
|
|
@ -7,12 +7,13 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OC\Settings\Controller;
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use \OC\Settings\Application;
|
||||
use OC\Settings\Controller\SecuritySettingsController;
|
||||
|
||||
/**
|
||||
* @package OC\Settings\Controller
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class SecuritySettingsControllerTest extends \PHPUnit_Framework_TestCase {
|
||||
|
|
@ -7,7 +7,8 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OC\Settings\Controller;
|
||||
|
||||
namespace Tests\Settings\Controller;
|
||||
|
||||
use \OC\Settings\Application;
|
||||
use OCP\AppFramework\Http;
|
||||
|
@ -16,7 +17,7 @@ use OCP\AppFramework\Http\DataResponse;
|
|||
/**
|
||||
* @group DB
|
||||
*
|
||||
* @package OC\Settings\Controller
|
||||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class UsersControllerTest extends \Test\TestCase {
|
||||
|
|
@ -8,10 +8,11 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OC\Settings\Middleware;
|
||||
namespace Tests\Settings\Middleware;
|
||||
|
||||
use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException;
|
||||
use OC\AppFramework\Utility\ControllerMethodReflector;
|
||||
use OC\Settings\Middleware\SubadminMiddleware;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
||||
|
@ -19,7 +20,7 @@ use OCP\AppFramework\Http\TemplateResponse;
|
|||
* Verifies whether an user has at least subadmin rights.
|
||||
* To bypass use the `@NoSubadminRequired` annotation
|
||||
*
|
||||
* @package OC\Settings\Middleware
|
||||
* @package Tests\Settings\Middleware
|
||||
*/
|
||||
class SubadminMiddlewareTest extends \Test\TestCase {
|
||||
/** @var SubadminMiddleware */
|
Loading…
Reference in a new issue