Migrate PHP to PSR-4

Signed-off-by: Olivier Paroz (oparoz) <github@oparoz.com>
This commit is contained in:
Olivier Paroz (oparoz) 2017-04-23 17:36:45 +02:00
parent 8f58bc5772
commit a2671c8223
No known key found for this signature in database
GPG Key ID: 165E66587C7FE8B1
99 changed files with 1355 additions and 608 deletions

View File

@ -1,6 +1,6 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -8,8 +8,8 @@
* @author Olivier Paroz <galleryapps@oparoz.com>
* @author Robin Appelman <robin@icewind.nl>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Robin Appelman 2014-2015
* @copyright Olivier Paroz 2017
* @copyright Robin Appelman 2017
*/
namespace OCA\Gallery\AppInfo;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\AppInfo;

View File

@ -23,13 +23,13 @@ coverage:
enabled: true
include:
- appinfo/*.php
- config/*
- controller/*
- environment/*
- http/*
- middleware/*
- preview/*
- service/*
- lib/AppInfo/*.php
- lib/Config/*
- lib/Controller/*
- lib/Environment/*
- lib/Http/*
- lib/Middleware/*
- lib/Service/*
exclude:
- build/*
- css/*

View File

@ -1,24 +1,24 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\AppInfo;
ini_set("gd.jpeg_ignore_warning", true);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
// A production environment will not have xdebug enabled and
// a development environment should have the dev packages installed
$c3 = __DIR__ . '/../c3.php';
$c3 = __DIR__ . '/../../c3.php';
if (extension_loaded('xdebug') && file_exists($c3)) {
include_once $c3;
}
@ -40,7 +40,6 @@ use OCA\Gallery\Controller\PreviewController;
use OCA\Gallery\Controller\PreviewPublicController;
use OCA\Gallery\Controller\PreviewApiController;
use OCA\Gallery\Environment\Environment;
use OCA\Gallery\Preview\Preview;
use OCA\Gallery\Service\SearchFolderService;
use OCA\Gallery\Service\ConfigService;
use OCA\Gallery\Service\SearchMediaService;
@ -52,8 +51,6 @@ use OCA\Gallery\Middleware\EnvCheckMiddleware;
use OCA\Gallery\Utility\EventSource;
use OCA\OcUtility\AppInfo\Application as OcUtility;
use OCA\OcUtility\Service\SmarterLogger as SmarterLogger;
use OCP\IPreview;
/**
* Class Application
@ -246,13 +243,6 @@ class Application extends App {
return new ConfigParser();
}
);
$container->registerService(
'CustomPreviewManager', function (IContainer $c) {
return new Preview(
$c->query(IPreview::class)
);
}
);
$container->registerService(
'Environment', function (IContainer $c) {
return new Environment(
@ -293,14 +283,6 @@ class Application extends App {
->query('OCA\OcUtility\Service\Helper');
}
);
$container->registerService(
'Logger', function (IContainer $c) {
return new SmarterLogger(
$c->query('AppName'),
$c->query('OCP\ILogger')
);
}
);
} else {
// @codeCoverageIgnoreEnd
$container->registerService(
@ -327,7 +309,7 @@ class Application extends App {
$c->query('AppName'),
$c->query('Environment'),
$c->query('ConfigParser'),
$c->query('CustomPreviewManager'),
$c->query('OCP\IPreview'),
$c->query('Logger')
);
}
@ -351,7 +333,7 @@ class Application extends App {
return new PreviewService(
$c->query('AppName'),
$c->query('Environment'),
$c->query('CustomPreviewManager'),
$c->query('OCP\IPreview'),
$c->query('Logger')
);
}

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Config;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Config;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Config;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,6 +1,6 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -8,8 +8,8 @@
* @author Olivier Paroz <galleryapps@oparoz.com>
* @author Robin Appelman <robin@icewind.nl>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Robin Appelman 2012-2014
* @copyright Olivier Paroz 2017
* @copyright Robin Appelman 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,6 +1,6 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -8,8 +8,8 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Bernhard Posselt 2014-2015
* @copyright Olivier Paroz 2014-2016
* @copyright Bernhard Posselt 2017
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,6 +1,6 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -8,8 +8,8 @@
* @author Robin Appelman <robin@icewind.nl>
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Robin Appelman 2012-2015
* @copyright Olivier Paroz 2014-2016
* @copyright Robin Appelman 2017
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,6 +1,6 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -8,8 +8,8 @@
* @author Olivier Paroz <galleryapps@oparoz.com>
* @author Robin Appelman <robin@icewind.nl>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Robin Appelman 2012-2014
* @copyright Olivier Paroz 2017
* @copyright Robin Appelman 2017
*/
namespace OCA\Gallery\Controller;
@ -156,7 +156,7 @@ trait Preview {
* @param bool $keepAspect
* @param bool $base64Encode
*
* @return array
* @return array<\OC_Image|string, int>
*/
private function getPreviewData(
$file, $animatedPreview, $width, $height, $keepAspect, $base64Encode
@ -181,7 +181,7 @@ trait Preview {
*
* @param $status
*
* @return array<null|int>
* @return array<null,int>
*/
private function getErrorData($status = Http::STATUS_INTERNAL_SERVER_ERROR) {
return [null, $status];

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;

View File

@ -1,6 +1,6 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -8,7 +8,7 @@
* @author Olivier Paroz <galleryapps@oparoz.com>
* @author Authors of \OCA\Files_Sharing\Helper
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
* @copyright Authors of \OCA\Files_Sharing\Helper 2014-2016
*/

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Environment;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Environment;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Http;

View File

@ -1,14 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Middleware;

View File

@ -1,6 +1,6 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -8,8 +8,8 @@
* @author Olivier Paroz <galleryapps@oparoz.com>
* @author Bernhard Posselt <dev@bernhard-posselt.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Bernhard Posselt 2012-2015
* @copyright Olivier Paroz 2017
* @copyright Bernhard Posselt 2017
*/
namespace OCA\Gallery\Middleware;

View File

@ -1,6 +1,6 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -9,9 +9,9 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @author Authors of \OCA\Files_Sharing\Helper
*
* @copyright Olivier Paroz 2014-2016
* @copyright Bernhard Posselt 2012-2015
* @copyright Authors of \OCA\Files_Sharing\Helper 2014-2016
* @copyright Olivier Paroz 2017
* @copyright Bernhard Posselt 2017
* @copyright Authors of \OCA\Files_Sharing\Helper 2017
*/
namespace OCA\Gallery\Middleware;

View File

@ -1,15 +1,15 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Lukas Reschke <lukas@owncloud.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Lukas Reschke 2014-2015
* @copyright Olivier Paroz 2014-2016
* @copyright Lukas Reschke 2017
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Middleware;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,24 +1,24 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;
use OCP\Files\Folder;
use OCP\IPreview;
use OCP\ILogger;
use OCA\Gallery\Config\ConfigParser;
use OCA\Gallery\Config\ConfigException;
use OCA\Gallery\Environment\Environment;
use OCA\Gallery\Preview\Preview;
/**
* Finds configurations files and returns a configuration array
@ -37,7 +37,7 @@ class ConfigService extends FilesService {
private $completionStatus = ['design' => false, 'information' => false, 'sorting' => false];
/** @var ConfigParser */
private $configParser;
/** @var Preview */
/** @var IPreview */
private $previewManager;
/**
* @todo This hard-coded array could be replaced by admin settings
@ -73,14 +73,14 @@ class ConfigService extends FilesService {
* @param string $appName
* @param Environment $environment
* @param ConfigParser $configParser
* @param Preview $previewManager
* @param IPreview $previewManager
* @param ILogger $logger
*/
public function __construct(
$appName,
Environment $environment,
ConfigParser $configParser,
Preview $previewManager,
IPreview $previewManager,
ILogger $logger
) {
parent::__construct($appName, $environment, $logger);

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,22 +1,23 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;
use OCP\Files\File;
use OCP\Image;
use OCP\IPreview;
use OCP\ILogger;
use OCA\Gallery\Environment\Environment;
use OCA\Gallery\Preview\Preview;
/**
* Generates previews
@ -27,7 +28,7 @@ class PreviewService extends Service {
use Base64Encode;
/** @var Preview */
/** @var IPreview */
private $previewManager;
/**
@ -35,13 +36,13 @@ class PreviewService extends Service {
*
* @param string $appName
* @param Environment $environment
* @param Preview $previewManager
* @param IPreview $previewManager
* @param ILogger $logger
*/
public function __construct(
$appName,
Environment $environment,
Preview $previewManager,
IPreview $previewManager,
ILogger $logger
) {
parent::__construct($appName, $environment, $logger);
@ -95,19 +96,24 @@ class PreviewService extends Service {
* @param bool $keepAspect
* @param bool $base64Encode
*
* @return array <string,\OC_Image|string>|false preview data
* @return string|\OC_Image|string|false preview data
* @throws InternalServerErrorServiceException
*/
public function createPreview(
$file, $maxX = 0, $maxY = 0, $keepAspect = true, $base64Encode = false
) {
try {
$preview = $this->previewManager->getPreview($file, $maxX, $maxY, $keepAspect);
if ($preview && $base64Encode) {
$preview['preview'] = $this->encode($preview['preview']);
$preview = $this->previewManager->getPreview($file, $maxX, $maxY, !$keepAspect);
$img = new Image($preview->getContent());
$mimeType = $img->mimeType();
if ($img && $base64Encode) {
$img = $this->encode($img);
}
return $preview;
return [
'preview' => $img,
'mimetype' => $mimeType
];
} catch (\Exception $exception) {
throw new InternalServerErrorServiceException('Preview generation has failed');
}

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,13 +1,13 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;

View File

@ -1,6 +1,6 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -14,7 +14,7 @@
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Utility;

View File

@ -1,75 +0,0 @@
<?php
/**
* Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2014-2016
*/
namespace OCA\Gallery\Preview;
use OCP\Files\File;
use OCP\Files\NotFoundException;
use OCP\Image;
use OCP\IPreview;
/**
* Generates previews
*
* @package OCA\Gallery\Preview
*/
class Preview {
/**
* @var IPreview
*/
private $previewManager;
/**
* Constructor
*
* @param IPreview $previewManager
*/
public function __construct(
IPreview $previewManager
) {
$this->previewManager = $previewManager;
}
/**
* Returns true if the passed mime type is supported
*
* @param string $mimeType
*
* @return boolean
*/
public function isMimeSupported($mimeType = '*') {
return $this->previewManager->isMimeSupported($mimeType);
}
/**
* @param File $file
* @param int $maxX
* @param int $maxY
* @param bool $keepAspect
* @return false|array<string,string|\OC_Image>
*/
public function getPreview(File $file, $maxX, $maxY, $keepAspect) {
try {
$preview = $this->previewManager->getPreview($file, $maxX, $maxY, !$keepAspect);
} catch (NotFoundException $e) {
return false;
}
$img = new Image($preview->getContent());
return [
'preview' => $img,
'mimetype' => $img->mimeType()
];
}
}

View File

@ -6,9 +6,9 @@ Read more about automated testing in [the wiki](https://github.com/nextcloud/gal
* PHP tidy enabled
* PHP imagick extension
* `core` cloned via git
* `core` submodule initialised
* `core` has to be installed
* `server` cloned via git
* `server` submodule initialised
* `server` has to be installed
* Gallery app enabled (`sudo -u<myuser> ./occ app:enable gallery`)
* composer installed (see below)
* vendor folder and composer.lock file removed
@ -71,7 +71,7 @@ Refer to the Codeception [quick guide](http://codeception.com/quickstart) if you
In order to be able to test the Javascript in acceptance tests, we need to install one more component: PhantomJS. Use your distribution installer to get it or download a binary for Windows or Mac from the [official website](http://phantomjs.org/download.html).
*Note: It's also required for Javascript tests in `core`, so this is not specific to this repository.*
*Note: It's also required for Javascript tests in `server`, so this is not specific to this repository.*
### Running tests

View File

@ -1,18 +1,20 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Codeception\Util\Autoload;
define('PHPUNIT_RUN', 1);
if (!defined('PHPUNIT_RUN')) {
define('PHPUNIT_RUN', 1);
}
// Add core
require_once __DIR__ . '/../../../lib/base.php';
@ -21,7 +23,9 @@ require_once __DIR__ . '/../../../lib/base.php';
OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
// Give access to core tests to Codeception
Autoload::addNamespace('Test', '/../../../tests/lib');
Autoload::addNamespace('Test', OC::$SERVERROOT . '/tests/lib');
Autoload::addNamespace('OCA\Gallery\Tests', 'tests/unit');
Autoload::addNamespace('OCA\Gallery\Tests\Integration', 'tests/integration');
// Load all apps
OC_App::loadApps();

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Helper;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Helper;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Page\Acceptance;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Page;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Page;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Page;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Step\Api;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Step\Api;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Step\Api;

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 0f2a47ed0d13e8e09ab23f0015cde7f9
<?php //[STAMP] d0668a78e08efaa6754b7410cfc57129
namespace _generated;
// This class was automatically generated by build task
@ -26,8 +26,6 @@ trait ApiTesterActions
* @param $expected
* @param $actual
* @param string $message
*
* @return mixed
* @see \Codeception\Module\Asserts::assertEquals()
*/
public function assertEquals($expected, $actual, $message = null) {
@ -58,8 +56,7 @@ trait ApiTesterActions
* @param $expected
* @param $actual
* @param string $message
*
* @return mixed
* @return mixed|void
* @see \Codeception\Module\Asserts::assertSame()
*/
public function assertSame($expected, $actual, $message = null) {
@ -97,17 +94,6 @@ trait ApiTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @deprecated
* @see \Codeception\Module\Asserts::assertGreaterThen()
*/
public function assertGreaterThen($expected, $actual, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -123,17 +109,6 @@ trait ApiTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @deprecated
* @see \Codeception\Module\Asserts::assertGreaterThenOrEqual()
*/
public function assertGreaterThenOrEqual($expected, $actual, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -312,7 +287,7 @@ trait ApiTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if file exists
*
*
* @param string $filename
* @param string $message
* @see \Codeception\Module\Asserts::assertFileExists()
@ -326,7 +301,7 @@ trait ApiTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if file doesn't exist
*
*
* @param string $filename
* @param string $message
* @see \Codeception\Module\Asserts::assertFileNotExists()
@ -336,6 +311,122 @@ trait ApiTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expected
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertGreaterOrEquals()
*/
public function assertGreaterOrEquals($expected, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expected
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertLessOrEquals()
*/
public function assertLessOrEquals($expected, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertIsEmpty()
*/
public function assertIsEmpty($actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $key
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertArrayHasKey()
*/
public function assertArrayHasKey($key, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $key
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertArrayNotHasKey()
*/
public function assertArrayNotHasKey($key, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expectedCount
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertCount()
*/
public function assertCount($expectedCount, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $class
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertInstanceOf()
*/
public function assertInstanceOf($class, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $class
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertNotInstanceOf()
*/
public function assertNotInstanceOf($class, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $type
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertInternalType()
*/
public function assertInternalType($type, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInternalType', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -349,6 +440,40 @@ trait ApiTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Handles and checks exception called inside callback function.
* Either exception class name or exception instance should be provided.
*
* ```php
* <?php
* $I->expectException(MyException::class, function() {
* $this->doSomethingBad();
* });
*
* $I->expectException(new MyException(), function() {
* $this->doSomethingBad();
* });
* ```
* If you want to check message or exception code, you can pass them with exception instance:
* ```php
* <?php
* // will check that exception MyException is thrown with "Don't do bad things" message
* $I->expectException(new MyException("Don't do bad things"), function() {
* $this->doSomethingBad();
* });
* ```
*
* @param $exception string or \Exception
* @param $callback
* @see \Codeception\Module\Asserts::expectException()
*/
public function expectException($exception, $callback) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -402,6 +527,18 @@ trait ApiTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @return mixed
* @throws \Codeception\Exception\ModuleException
* @see \Helper\Api::getPrivateFile()
*/
public function getPrivateFile() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('getPrivateFile', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -461,7 +598,14 @@ trait ApiTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Sets HTTP header
* Sets HTTP header valid for all next requests. Use `deleteHeader` to unset it
*
* ```php
* <?php
* $I->haveHttpHeader('Content-Type', 'application/json');
* // all next requests will contain this header
* ?>
* ```
*
* @param $name
* @param $value
@ -474,6 +618,33 @@ trait ApiTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Deletes the header with the passed name. Subsequent requests
* will not have the deleted header in its request.
*
* Example:
* ```php
* <?php
* $I->haveHttpHeader('X-Requested-With', 'Codeception');
* $I->sendGET('test-headers.php');
* // ...
* $I->deleteHeader('X-Requested-With');
* $I->sendPOST('some-other-page.php');
* ?>
* ```
*
* @param string $name the name of the header to delete.
* @part json
* @part xml
* @see \Codeception\Module\REST::deleteHeader()
*/
public function deleteHeader($name) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -983,7 +1154,8 @@ trait ApiTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Returns data from the current JSON response using [JSONPath](http://goessner.net/articles/JsonPath/) as selector.
* JsonPath is XPath equivalent for querying Json structures. Try your JsonPath expressions [online](http://jsonpath.curiousconcept.com/).
* JsonPath is XPath equivalent for querying Json structures.
* Try your JsonPath expressions [online](http://jsonpath.curiousconcept.com/).
* Even for a single value an array is returned.
*
* This method **require [`flow/jsonpath` > 0.2](https://github.com/FlowCommunications/JSONPath/) library to be installed**.
@ -993,13 +1165,13 @@ trait ApiTesterActions
* ``` php
* <?php
* // match the first `user.id` in json
* $firstUser = $I->grabDataFromJsonResponse('$..users[0].id');
* $I->sendPUT('/user', array('id' => $firstUser[0], 'name' => 'davert'));
* $firstUserId = $I->grabDataFromResponseByJsonPath('$..users[0].id');
* $I->sendPUT('/user', array('id' => $firstUserId[0], 'name' => 'davert'));
* ?>
* ```
*
* @param $jsonPath
* @return array
* @param string $jsonPath
* @return array Array of matching items
* @version 2.0.9
* @throws \Exception
* @part json
@ -1049,6 +1221,7 @@ trait ApiTesterActions
* $I->seeResponseJsonMatchesXpath('/store//price');
* ?>
* ```
* @param string $xpath
* @part json
* @version 2.0.9
* Conditional Assertion: Test won't be stopped on fail
@ -1096,6 +1269,7 @@ trait ApiTesterActions
* $I->seeResponseJsonMatchesXpath('/store//price');
* ?>
* ```
* @param string $xpath
* @part json
* @version 2.0.9
* @see \Codeception\Module\REST::seeResponseJsonMatchesXpath()
@ -1105,11 +1279,39 @@ trait ApiTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Opposite to seeResponseJsonMatchesXpath
*
* @param string $xpath
* @part json
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\REST::dontSeeResponseJsonMatchesXpath()
*/
public function cantSeeResponseJsonMatchesXpath($xpath) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeResponseJsonMatchesXpath', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Opposite to seeResponseJsonMatchesXpath
*
* @param string $xpath
* @part json
* @see \Codeception\Module\REST::dontSeeResponseJsonMatchesXpath()
*/
public function dontSeeResponseJsonMatchesXpath($xpath) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeResponseJsonMatchesXpath', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if json structure in response matches [JsonPath](http://goessner.net/articles/JsonPath/).
* JsonPath is XPath equivalent for querying Json structures. Try your JsonPath expressions [online](http://jsonpath.curiousconcept.com/).
* JsonPath is XPath equivalent for querying Json structures.
* Try your JsonPath expressions [online](http://jsonpath.curiousconcept.com/).
* This assertion allows you to check the structure of response json.
*
* This method **require [`flow/jsonpath` > 0.2](https://github.com/FlowCommunications/JSONPath/) library to be installed**.
@ -1147,6 +1349,7 @@ trait ApiTesterActions
* ?>
* ```
*
* @param string $jsonPath
* @part json
* @version 2.0.9
* Conditional Assertion: Test won't be stopped on fail
@ -1159,7 +1362,8 @@ trait ApiTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if json structure in response matches [JsonPath](http://goessner.net/articles/JsonPath/).
* JsonPath is XPath equivalent for querying Json structures. Try your JsonPath expressions [online](http://jsonpath.curiousconcept.com/).
* JsonPath is XPath equivalent for querying Json structures.
* Try your JsonPath expressions [online](http://jsonpath.curiousconcept.com/).
* This assertion allows you to check the structure of response json.
*
* This method **require [`flow/jsonpath` > 0.2](https://github.com/FlowCommunications/JSONPath/) library to be installed**.
@ -1197,6 +1401,7 @@ trait ApiTesterActions
* ?>
* ```
*
* @param string $jsonPath
* @part json
* @version 2.0.9
* @see \Codeception\Module\REST::seeResponseJsonMatchesJsonPath()
@ -1211,7 +1416,7 @@ trait ApiTesterActions
*
* Opposite to seeResponseJsonMatchesJsonPath
*
* @param array $jsonPath
* @param string $jsonPath
* @part json
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\REST::dontSeeResponseJsonMatchesJsonPath()
@ -1224,7 +1429,7 @@ trait ApiTesterActions
*
* Opposite to seeResponseJsonMatchesJsonPath
*
* @param array $jsonPath
* @param string $jsonPath
* @part json
* @see \Codeception\Module\REST::dontSeeResponseJsonMatchesJsonPath()
*/
@ -1260,6 +1465,214 @@ trait ApiTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that Json matches provided types.
* In case you don't know the actual values of JSON data returned you can match them by type.
* Starts check with a root element. If JSON data is array it will check the first element of an array.
* You can specify the path in the json which should be checked with JsonPath
*
* Basic example:
*
* ```php
* <?php
* // {'user_id': 1, 'name': 'davert', 'is_active': false}
* $I->seeResponseMatchesJsonType([
* 'user_id' => 'integer',
* 'name' => 'string|null',
* 'is_active' => 'boolean'
* ]);
*
* // narrow down matching with JsonPath:
* // {"users": [{ "name": "davert"}, {"id": 1}]}
* $I->seeResponseMatchesJsonType(['name' => 'string'], '$.users[0]');
* ?>
* ```
*
* In this case you can match that record contains fields with data types you expected.
* The list of possible data types:
*
* * string
* * integer
* * float
* * array (json object is array as well)
* * boolean
*
* You can also use nested data type structures:
*
* ```php
* <?php
* // {'user_id': 1, 'name': 'davert', 'company': {'name': 'Codegyre'}}
* $I->seeResponseMatchesJsonType([
* 'user_id' => 'integer|string', // multiple types
* 'company' => ['name' => 'string']
* ]);
* ?>
* ```
*
* You can also apply filters to check values. Filter can be applied with `:` char after the type declatation.
*
* Here is the list of possible filters:
*
* * `integer:>{val}` - checks that integer is greater than {val} (works with float and string types too).
* * `integer:<{val}` - checks that integer is lower than {val} (works with float and string types too).
* * `string:url` - checks that value is valid url.
* * `string:date` - checks that value is date in JavaScript format: https://weblog.west-wind.com/posts/2014/Jan/06/JavaScript-JSON-Date-Parsing-and-real-Dates
* * `string:email` - checks that value is a valid email according to http://emailregex.com/
* * `string:regex({val})` - checks that string matches a regex provided with {val}
*
* This is how filters can be used:
*
* ```php
* <?php
* // {'user_id': 1, 'email' => 'davert@codeception.com'}
* $I->seeResponseMatchesJsonType([
* 'user_id' => 'string:>0:<1000', // multiple filters can be used
* 'email' => 'string:regex(~\@~)' // we just check that @ char is included
* ]);
*
* // {'user_id': '1'}
* $I->seeResponseMatchesJsonType([
* 'user_id' => 'string:>0', // works with strings as well
* }
* ?>
* ```
*
* You can also add custom filters y accessing `JsonType::addCustomFilter` method.
* See [JsonType reference](http://codeception.com/docs/reference/JsonType).
*
* @part json
* @version 2.1.3
* @param array $jsonType
* @param string $jsonPath
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\REST::seeResponseMatchesJsonType()
*/
public function canSeeResponseMatchesJsonType($jsonType, $jsonPath = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseMatchesJsonType', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that Json matches provided types.
* In case you don't know the actual values of JSON data returned you can match them by type.
* Starts check with a root element. If JSON data is array it will check the first element of an array.
* You can specify the path in the json which should be checked with JsonPath
*
* Basic example:
*
* ```php
* <?php
* // {'user_id': 1, 'name': 'davert', 'is_active': false}
* $I->seeResponseMatchesJsonType([
* 'user_id' => 'integer',
* 'name' => 'string|null',
* 'is_active' => 'boolean'
* ]);
*
* // narrow down matching with JsonPath:
* // {"users": [{ "name": "davert"}, {"id": 1}]}
* $I->seeResponseMatchesJsonType(['name' => 'string'], '$.users[0]');
* ?>
* ```
*
* In this case you can match that record contains fields with data types you expected.
* The list of possible data types:
*
* * string
* * integer
* * float
* * array (json object is array as well)
* * boolean
*
* You can also use nested data type structures:
*
* ```php
* <?php
* // {'user_id': 1, 'name': 'davert', 'company': {'name': 'Codegyre'}}
* $I->seeResponseMatchesJsonType([
* 'user_id' => 'integer|string', // multiple types
* 'company' => ['name' => 'string']
* ]);
* ?>
* ```
*
* You can also apply filters to check values. Filter can be applied with `:` char after the type declatation.
*
* Here is the list of possible filters:
*
* * `integer:>{val}` - checks that integer is greater than {val} (works with float and string types too).
* * `integer:<{val}` - checks that integer is lower than {val} (works with float and string types too).
* * `string:url` - checks that value is valid url.
* * `string:date` - checks that value is date in JavaScript format: https://weblog.west-wind.com/posts/2014/Jan/06/JavaScript-JSON-Date-Parsing-and-real-Dates
* * `string:email` - checks that value is a valid email according to http://emailregex.com/
* * `string:regex({val})` - checks that string matches a regex provided with {val}
*
* This is how filters can be used:
*
* ```php
* <?php
* // {'user_id': 1, 'email' => 'davert@codeception.com'}
* $I->seeResponseMatchesJsonType([
* 'user_id' => 'string:>0:<1000', // multiple filters can be used
* 'email' => 'string:regex(~\@~)' // we just check that @ char is included
* ]);
*
* // {'user_id': '1'}
* $I->seeResponseMatchesJsonType([
* 'user_id' => 'string:>0', // works with strings as well
* }
* ?>
* ```
*
* You can also add custom filters y accessing `JsonType::addCustomFilter` method.
* See [JsonType reference](http://codeception.com/docs/reference/JsonType).
*
* @part json
* @version 2.1.3
* @param array $jsonType
* @param string $jsonPath
* @see \Codeception\Module\REST::seeResponseMatchesJsonType()
*/
public function seeResponseMatchesJsonType($jsonType, $jsonPath = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseMatchesJsonType', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Opposite to `seeResponseMatchesJsonType`.
*
* @part json
* @see seeResponseMatchesJsonType
* @param $jsonType jsonType structure
* @param null $jsonPath optionally set specific path to structure with JsonPath
* @version 2.1.3
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\REST::dontSeeResponseMatchesJsonType()
*/
public function cantSeeResponseMatchesJsonType($jsonType, $jsonPath = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeResponseMatchesJsonType', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Opposite to `seeResponseMatchesJsonType`.
*
* @part json
* @see seeResponseMatchesJsonType
* @param $jsonType jsonType structure
* @param null $jsonPath optionally set specific path to structure with JsonPath
* @version 2.1.3
* @see \Codeception\Module\REST::dontSeeResponseMatchesJsonType()
*/
public function dontSeeResponseMatchesJsonType($jsonType, $jsonPath = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeResponseMatchesJsonType', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -1271,7 +1684,7 @@ trait ApiTesterActions
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\REST::seeResponseEquals()
*/
public function canSeeResponseEquals($response) {
public function canSeeResponseEquals($expected) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseEquals', func_get_args()));
}
/**
@ -1284,7 +1697,7 @@ trait ApiTesterActions
* @param $response
* @see \Codeception\Module\REST::seeResponseEquals()
*/
public function seeResponseEquals($response) {
public function seeResponseEquals($expected) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseEquals', func_get_args()));
}
@ -1294,6 +1707,14 @@ trait ApiTesterActions
*
* Checks response code equals to provided value.
*
* ```php
* <?php
* $I->seeResponseCodeIs(200);
*
* // preferred to use \Codeception\Util\HttpCode
* $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
* ```
*
* @part json
* @part xml
* @param $code
@ -1308,6 +1729,14 @@ trait ApiTesterActions
*
* Checks response code equals to provided value.
*
* ```php
* <?php
* $I->seeResponseCodeIs(200);
*
* // preferred to use \Codeception\Util\HttpCode
* $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
* ```
*
* @part json
* @part xml
* @param $code
@ -1323,6 +1752,14 @@ trait ApiTesterActions
*
* Checks that response code is not equal to provided value.
*
* ```php
* <?php
* $I->dontSeeResponseCodeIs(200);
*
* // preferred to use \Codeception\Util\HttpCode
* $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK);
* ```
*
* @part json
* @part xml
* @param $code
@ -1337,6 +1774,14 @@ trait ApiTesterActions
*
* Checks that response code is not equal to provided value.
*
* ```php
* <?php
* $I->dontSeeResponseCodeIs(200);
*
* // preferred to use \Codeception\Util\HttpCode
* $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK);
* ```
*
* @part json
* @part xml
* @param $code
@ -1470,10 +1915,10 @@ trait ApiTesterActions
* @param $attribute
* @return string
* @part xml
* @see \Codeception\Module\REST::grabAttributeFrom()
* @see \Codeception\Module\REST::grabAttributeFromXmlElement()
*/
public function grabAttributeFrom($cssOrXPath, $attribute) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args()));
public function grabAttributeFromXmlElement($cssOrXPath, $attribute) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFromXmlElement', func_get_args()));
}
@ -1559,6 +2004,7 @@ trait ApiTesterActions
* ```
*
* @param $xml
* @part xml
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\REST::seeXmlResponseIncludes()
*/
@ -1581,6 +2027,7 @@ trait ApiTesterActions
* ```
*
* @param $xml
* @part xml
* @see \Codeception\Module\REST::seeXmlResponseIncludes()
*/
public function seeXmlResponseIncludes($xml) {
@ -1622,6 +2069,138 @@ trait ApiTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if the hash of a binary response is exactly the same as provided.
* Parameter can be passed as any hash string supported by hash(), with an
* optional second parameter to specify the hash type, which defaults to md5.
*
* Example: Using md5 hash key
*
* ```php
* <?php
* $I->seeBinaryResponseEquals("8c90748342f19b195b9c6b4eff742ded");
* ?>
* ```
*
* Example: Using md5 for a file contents
*
* ```php
* <?php
* $fileData = file_get_contents("test_file.jpg");
* $I->seeBinaryResponseEquals(md5($fileData));
* ?>
* ```
* Example: Using sha256 hsah
*
* ```php
* <?php
* $fileData = '/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k='; // very small jpeg
* $I->seeBinaryResponseEquals(hash("sha256", base64_decode($fileData)), 'sha256');
* ?>
* ```
*
* @param $hash the hashed data response expected
* @param $algo the hash algorithm to use. Default md5.
* @part json
* @part xml
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\REST::seeBinaryResponseEquals()
*/
public function canSeeBinaryResponseEquals($hash, $algo = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeBinaryResponseEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if the hash of a binary response is exactly the same as provided.
* Parameter can be passed as any hash string supported by hash(), with an
* optional second parameter to specify the hash type, which defaults to md5.
*
* Example: Using md5 hash key
*
* ```php
* <?php
* $I->seeBinaryResponseEquals("8c90748342f19b195b9c6b4eff742ded");
* ?>
* ```
*
* Example: Using md5 for a file contents
*
* ```php
* <?php
* $fileData = file_get_contents("test_file.jpg");
* $I->seeBinaryResponseEquals(md5($fileData));
* ?>
* ```
* Example: Using sha256 hsah
*
* ```php
* <?php
* $fileData = '/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k='; // very small jpeg
* $I->seeBinaryResponseEquals(hash("sha256", base64_decode($fileData)), 'sha256');
* ?>
* ```
*
* @param $hash the hashed data response expected
* @param $algo the hash algorithm to use. Default md5.
* @part json
* @part xml
* @see \Codeception\Module\REST::seeBinaryResponseEquals()
*/
public function seeBinaryResponseEquals($hash, $algo = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeBinaryResponseEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if the hash of a binary response is not the same as provided.
*
* ```php
* <?php
* $I->dontSeeBinaryResponseEquals("8c90748342f19b195b9c6b4eff742ded");
* ?>
* ```
* Opposite to `seeBinaryResponseEquals`
*
* @param $hash the hashed data response expected
* @param $algo the hash algorithm to use. Default md5.
* @part json
* @part xml
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\REST::dontSeeBinaryResponseEquals()
*/
public function cantSeeBinaryResponseEquals($hash, $algo = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeBinaryResponseEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if the hash of a binary response is not the same as provided.
*
* ```php
* <?php
* $I->dontSeeBinaryResponseEquals("8c90748342f19b195b9c6b4eff742ded");
* ?>
* ```
* Opposite to `seeBinaryResponseEquals`
*
* @param $hash the hashed data response expected
* @param $algo the hash algorithm to use. Default md5.
* @part json
* @part xml
* @see \Codeception\Module\REST::dontSeeBinaryResponseEquals()
*/
public function dontSeeBinaryResponseEquals($hash, $algo = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeBinaryResponseEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Deprecated since 2.0.9 and removed since 2.1.0
*
* @param $path
* @throws ModuleException
* @deprecated
@ -1630,4 +2209,42 @@ trait ApiTesterActions
public function grabDataFromJsonResponse($path) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('grabDataFromJsonResponse', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Prevents automatic redirects to be followed by the client
*
* ```php
* <?php
* $I->stopFollowingRedirects();
* ```
*
* @part xml
* @part json
* @see \Codeception\Module\REST::stopFollowingRedirects()
*/
public function stopFollowingRedirects() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('stopFollowingRedirects', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Enables automatic redirects to be followed by the client
*
* ```php
* <?php
* $I->startFollowingRedirects();
* ```
*
* @part xml
* @part json
* @see \Codeception\Module\REST::startFollowingRedirects()
*/
public function startFollowingRedirects() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('startFollowingRedirects', func_get_args()));
}
}

View File

@ -1,4 +1,4 @@
<?php //[STAMP] aaa131e2f3cfca66f5f79cc2d0aa3031
<?php //[STAMP] 13a5b66fee55d97ab7c3c249cb5bcee6
namespace _generated;
// This class was automatically generated by build task
@ -25,8 +25,6 @@ trait IntegrationTesterActions
* @param $expected
* @param $actual
* @param string $message
*
* @return mixed
* @see \Codeception\Module\Asserts::assertEquals()
*/
public function assertEquals($expected, $actual, $message = null) {
@ -57,8 +55,7 @@ trait IntegrationTesterActions
* @param $expected
* @param $actual
* @param string $message
*
* @return mixed
* @return mixed|void
* @see \Codeception\Module\Asserts::assertSame()
*/
public function assertSame($expected, $actual, $message = null) {
@ -96,17 +93,6 @@ trait IntegrationTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @deprecated
* @see \Codeception\Module\Asserts::assertGreaterThen()
*/
public function assertGreaterThen($expected, $actual, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -122,17 +108,6 @@ trait IntegrationTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @deprecated
* @see \Codeception\Module\Asserts::assertGreaterThenOrEqual()
*/
public function assertGreaterThenOrEqual($expected, $actual, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -311,7 +286,7 @@ trait IntegrationTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if file exists
*
*
* @param string $filename
* @param string $message
* @see \Codeception\Module\Asserts::assertFileExists()
@ -325,7 +300,7 @@ trait IntegrationTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if file doesn't exist
*
*
* @param string $filename
* @param string $message
* @see \Codeception\Module\Asserts::assertFileNotExists()
@ -335,6 +310,122 @@ trait IntegrationTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expected
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertGreaterOrEquals()
*/
public function assertGreaterOrEquals($expected, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expected
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertLessOrEquals()
*/
public function assertLessOrEquals($expected, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertIsEmpty()
*/
public function assertIsEmpty($actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $key
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertArrayHasKey()
*/
public function assertArrayHasKey($key, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $key
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertArrayNotHasKey()
*/
public function assertArrayNotHasKey($key, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expectedCount
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertCount()
*/
public function assertCount($expectedCount, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $class
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertInstanceOf()
*/
public function assertInstanceOf($class, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $class
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertNotInstanceOf()
*/
public function assertNotInstanceOf($class, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $type
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertInternalType()
*/
public function assertInternalType($type, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInternalType', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -348,6 +439,40 @@ trait IntegrationTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Handles and checks exception called inside callback function.
* Either exception class name or exception instance should be provided.
*
* ```php
* <?php
* $I->expectException(MyException::class, function() {
* $this->doSomethingBad();
* });
*
* $I->expectException(new MyException(), function() {
* $this->doSomethingBad();
* });
* ```
* If you want to check message or exception code, you can pass them with exception instance:
* ```php
* <?php
* // will check that exception MyException is thrown with "Don't do bad things" message
* $I->expectException(new MyException("Don't do bad things"), function() {
* $this->doSomethingBad();
* });
* ```
*
* @param $exception string or \Exception
* @param $callback
* @see \Codeception\Module\Asserts::expectException()
*/
public function expectException($exception, $callback) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*

View File

@ -1,4 +1,4 @@
<?php //[STAMP] aaa131e2f3cfca66f5f79cc2d0aa3031
<?php //[STAMP] 7c6f60dc410e5d25ed45093900c9e742
namespace _generated;
// This class was automatically generated by build task
@ -7,7 +7,6 @@ namespace _generated;
use Codeception\Module\Asserts;
use Helper\Unit;
use Helper\DataSetup;
trait UnitTesterActions
{
@ -25,8 +24,6 @@ trait UnitTesterActions
* @param $expected
* @param $actual
* @param string $message
*
* @return mixed
* @see \Codeception\Module\Asserts::assertEquals()
*/
public function assertEquals($expected, $actual, $message = null) {
@ -57,8 +54,7 @@ trait UnitTesterActions
* @param $expected
* @param $actual
* @param string $message
*
* @return mixed
* @return mixed|void
* @see \Codeception\Module\Asserts::assertSame()
*/
public function assertSame($expected, $actual, $message = null) {
@ -96,17 +92,6 @@ trait UnitTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @deprecated
* @see \Codeception\Module\Asserts::assertGreaterThen()
*/
public function assertGreaterThen($expected, $actual, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -122,17 +107,6 @@ trait UnitTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @deprecated
* @see \Codeception\Module\Asserts::assertGreaterThenOrEqual()
*/
public function assertGreaterThenOrEqual($expected, $actual, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -311,7 +285,7 @@ trait UnitTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if file exists
*
*
* @param string $filename
* @param string $message
* @see \Codeception\Module\Asserts::assertFileExists()
@ -325,7 +299,7 @@ trait UnitTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks if file doesn't exist
*
*
* @param string $filename
* @param string $message
* @see \Codeception\Module\Asserts::assertFileNotExists()
@ -335,6 +309,122 @@ trait UnitTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expected
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertGreaterOrEquals()
*/
public function assertGreaterOrEquals($expected, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expected
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertLessOrEquals()
*/
public function assertLessOrEquals($expected, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertIsEmpty()
*/
public function assertIsEmpty($actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $key
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertArrayHasKey()
*/
public function assertArrayHasKey($key, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $key
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertArrayNotHasKey()
*/
public function assertArrayNotHasKey($key, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $expectedCount
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertCount()
*/
public function assertCount($expectedCount, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $class
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertInstanceOf()
*/
public function assertInstanceOf($class, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $class
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertNotInstanceOf()
*/
public function assertNotInstanceOf($class, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $type
* @param $actual
* @param $description
* @see \Codeception\Module\Asserts::assertInternalType()
*/
public function assertInternalType($type, $actual, $description = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInternalType', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -351,58 +441,33 @@ trait UnitTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Returns a list of ids available in the given folder
*
* @param string $folderPath
*
* @return array<string,int|string>
* @see \Helper\DataSetup::getFilesDataForFolder()
* Handles and checks exception called inside callback function.
* Either exception class name or exception instance should be provided.
*
* ```php
* <?php
* $I->expectException(MyException::class, function() {
* $this->doSomethingBad();
* });
*
* $I->expectException(new MyException(), function() {
* $this->doSomethingBad();
* });
* ```
* If you want to check message or exception code, you can pass them with exception instance:
* ```php
* <?php
* // will check that exception MyException is thrown with "Don't do bad things" message
* $I->expectException(new MyException("Don't do bad things"), function() {
* $this->doSomethingBad();
* });
* ```
*
* @param $exception string or \Exception
* @param $callback
* @see \Codeception\Module\Asserts::expectException()
*/
public function getFilesDataForFolder($folderPath) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('getFilesDataForFolder', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
*
* @see \Helper\DataSetup::createBrokenConfig()
*/
public function createBrokenConfig() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('createBrokenConfig', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
*
* @see \Helper\DataSetup::createConfigWithBom()
*/
public function createConfigWithBom() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('createConfigWithBom', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
*
* @see \Helper\DataSetup::emptyConfig()
*/
public function emptyConfig() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('emptyConfig', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
*
* @see \Helper\DataSetup::restoreValidConfig()
*/
public function restoreValidConfig() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('restoreValidConfig', func_get_args()));
public function expectException($exception, $callback) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args()));
}
}

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Page\Login as LoginPage;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use \Page\Acceptance\Login;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Helper\DataSetup;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Page\Gallery as GalleryApp;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Page\Gallery as GalleryApp;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Page\Gallery as GalleryApp;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Page\Gallery as GalleryApp;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Page\Gallery as GalleryApp;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Page\Gallery as GalleryApp;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Page\Gallery as GalleryApp;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
use Codeception\Util\Xml as XmlUtils;

View File

@ -1,13 +1,14 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Tests\Integration;

View File

@ -1,27 +1,26 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\AppInfo;
namespace OCA\Gallery\Tests\Integration\AppInfo;
use \OCP\App;
use OCA\Gallery\Tests\Integration\GalleryIntegrationTest;
/**
* Class AppTest
*
* @package OCA\Gallery\Tests\Integration
* @package OCA\Gallery\Tests\Integration\AppInfo
*/
class AppTest extends GalleryIntegrationTest {
class AppTest extends \OCA\Gallery\Tests\Integration\GalleryIntegrationTest {
public function testAppInstalled() {
$appManager = $this->container->query('OCP\App\IAppManager');

View File

@ -1,25 +1,24 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\AppInfo;
use OCA\Gallery\Tests\Integration\GalleryIntegrationTest;
namespace OCA\Gallery\Tests\Integration\AppInfo;
/**
* Class ApplicationTest
*
* @package OCA\Gallery\Tests\Integration
* @package OCA\Gallery\Tests\Integration\AppInfo
*/
class ApplicationTest extends GalleryIntegrationTest {
class ApplicationTest extends \OCA\Gallery\Tests\Integration\GalleryIntegrationTest {
public function providesServiceData() {
return [

View File

@ -1,28 +1,29 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Environment;
namespace OCA\Gallery\Tests\Integration\Environment;
use OCP\Files\Folder;
use OCP\Files\Node;
use OCA\Gallery\Tests\Integration\GalleryIntegrationTest;
use OCA\Gallery\Environment\Environment;
/**
* Class EnvironmentSetupTest
*
* @package OCA\Gallery\Tests\Integration
* @package OCA\Gallery\Tests\Integration\Environment
*/
class EnvironmentSetupTest extends GalleryIntegrationTest {
class EnvironmentSetupTest extends \OCA\Gallery\Tests\Integration\GalleryIntegrationTest {
/**
* Tests is setting up the environment using a normal user works

View File

@ -1,16 +1,19 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Config;
namespace OCA\Gallery\Tests\Config;
use OCA\Gallery\Config\ConfigParser;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Dumper;
@ -19,9 +22,9 @@ use Symfony\Component\Yaml\Exception\ParseException;
/**
* Class ConfigParserTest
*
* @package OCA\Gallery\Config
* @package OCA\Gallery\Tests\Config
*/
class ConfigParserTest extends \Test\GalleryUnitTest {
class ConfigParserTest extends \OCA\Gallery\Tests\GalleryUnitTest {
/** @var string */
protected $configName = 'gallery.cnf';

View File

@ -1,23 +1,26 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Config;
namespace OCA\Gallery\Tests\Config;
use OCA\Gallery\Config\ConfigValidator;
/**
* Class ConfigValidatorTest
*
* @package OCA\Gallery\Config
* @package OCA\Gallery\Tests\Config
*/
class ConfigValidatorTest extends \Test\GalleryUnitTest {
class ConfigValidatorTest extends \OCA\Gallery\Tests\GalleryUnitTest {
/** @var ConfigValidator */
protected $configValidator;

View File

@ -1,18 +1,19 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
namespace OCA\Gallery\Tests\Controller;
require_once __DIR__ . '/ConfigControllerTest.php';
use OCA\Gallery\Controller\ConfigApiController;
/**
* Class ConfigApiControllerTest

View File

@ -1,16 +1,17 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
namespace OCA\Gallery\Tests\Controller;
use OCP\IRequest;
use OCP\ILogger;
@ -18,6 +19,7 @@ use OCP\ILogger;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http;
use OCA\Gallery\Controller\ConfigController;
use OCA\Gallery\Service\ConfigService;
use OCA\Gallery\Service\PreviewService;
use OCA\Gallery\Service\ServiceException;

View File

@ -1,18 +1,19 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
namespace OCA\Gallery\Tests\Controller;
require_once __DIR__ . '/ConfigControllerTest.php';
use OCA\Gallery\Controller\ConfigPublicController;
/**
* Class ConfigPublicControllerTest

View File

@ -1,22 +1,22 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
require_once __DIR__ . '/FilesControllerTest.php';
namespace OCA\Gallery\Tests\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\RedirectResponse;
use OCA\Gallery\Controller\FilesApiController;
use OCA\Gallery\Service\NotFoundServiceException;
/**

View File

@ -1,18 +1,18 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
namespace OCA\Gallery\Tests\Controller;
use OCA\Gallery\Service\ServiceException;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\Files\File;
@ -26,10 +26,13 @@ use OCP\AppFramework\Http\JSONResponse;
use OCA\Gallery\AppInfo\Application;
use OCA\Gallery\Http\ImageResponse;
use OCA\Gallery\Controller\PathManipulation;
use OCA\Gallery\Controller\FilesController;
use OCA\Gallery\Service\SearchFolderService;
use OCA\Gallery\Service\ConfigService;
use OCA\Gallery\Service\SearchMediaService;
use OCA\Gallery\Service\DownloadService;
use OCA\Gallery\Service\ServiceException;
use OCA\Gallery\Service\NotFoundServiceException;
/**
@ -37,7 +40,7 @@ use OCA\Gallery\Service\NotFoundServiceException;
*
* @package OCA\Gallery\Controller
*/
class FilesControllerTest extends \Test\GalleryUnitTest {
class FilesControllerTest extends \OCA\Gallery\Tests\GalleryUnitTest {
use PathManipulation;

View File

@ -1,18 +1,19 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
namespace OCA\Gallery\Tests\Controller;
require_once __DIR__ . '/FilesControllerTest.php';
use OCA\Gallery\Controller\FilesPublicController;
/**
* Class FilesPublicControllerTest

View File

@ -1,21 +1,23 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
namespace OCA\Gallery\Tests\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCA\Gallery\Controller\HttpError;
use OCA\Gallery\Environment\NotFoundEnvException;
use OCA\Gallery\Service\NotFoundServiceException;
use OCA\Gallery\Service\ForbiddenServiceException;

View File

@ -1,16 +1,17 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
namespace OCA\Gallery\Tests\Controller;
use OCP\IConfig;
use OCP\IRequest;
@ -20,6 +21,7 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCA\Gallery\Controller\PageController;
use OCA\Gallery\Environment\Environment;
/**

View File

@ -1,23 +1,23 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
require_once __DIR__ . '/PreviewControllerTest.php';
namespace OCA\Gallery\Tests\Controller;
use OCP\Files\File;
use OCP\AppFramework\Http;
use OCA\Gallery\Controller\PreviewApiController;
use OCA\Gallery\Http\ImageResponse;
/**

View File

@ -1,16 +1,17 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
namespace OCA\Gallery\Tests\Controller;
use OCP\IRequest;
use OCP\IURLGenerator;
@ -22,6 +23,7 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCA\Gallery\AppInfo\Application;
use OCA\Gallery\Controller\PreviewController;
use OCA\Gallery\Http\ImageResponse;
use OCA\Gallery\Service\ConfigService;
use OCA\Gallery\Service\ThumbnailService;
@ -36,7 +38,7 @@ use OCA\Gallery\Service\InternalServerErrorServiceException;
*
* @package OCA\Gallery\Controller
*/
class PreviewControllerTest extends \Test\GalleryUnitTest {
class PreviewControllerTest extends \OCA\Gallery\Tests\GalleryUnitTest {
/** @var IAppContainer */
protected $container;

View File

@ -1,18 +1,19 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Controller;
namespace OCA\Gallery\Tests\Controller;
require_once __DIR__ . '/PreviewControllerTest.php';
use OCA\Gallery\Controller\PreviewPublicController;
/**
* Class PreviewPublicControllerTest

View File

@ -1,16 +1,17 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Environment;
namespace OCA\Gallery\Tests\Environment;
use OCP\IUserManager;
use OCP\ILogger;
@ -19,11 +20,12 @@ use OCP\Files\IRootFolder;
use OCP\AppFramework\IAppContainer;
use OCA\Gallery\AppInfo\Application;
use OCA\Gallery\Environment\Environment;
/**
* Class Environment
* Class EnvironmentTest
*
* @package OCA\Gallery\Environment
* @package OCA\Gallery\Tests\Environment
*/
class EnvironmentTest extends \Test\TestCase {

View File

@ -1,16 +1,17 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace Test;
namespace OCA\Gallery\Tests;
use OCP\ILogger;
use OCP\Files\File;

View File

@ -1,22 +1,26 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Http;
namespace OCA\Gallery\Tests\Http;
use OCP\AppFramework\Http;
use OCA\Gallery\Http\ImageResponse;
/**
* Class ImageResponseTest
*
* @package OCA\Gallery\Controller
* @package OCA\Gallery\Tests\Http
*/
class ImageResponseTest extends \Test\TestCase {

View File

@ -1,16 +1,17 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Middleware;
namespace OCA\Gallery\Tests\Middleware;
use OC\AppFramework\Utility\ControllerMethodReflector;
@ -31,11 +32,16 @@ use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCA\Gallery\Environment\EnvironmentException;
use OCA\Gallery\Middleware\SharingCheckMiddleware;
use OCA\Gallery\Middleware\EnvCheckMiddleware;
use OCA\Gallery\Middleware\CheckException;
/**
* @package OCA\Gallery\Middleware\EnvCheckMiddlewareTest
* Class EnvCheckMiddlewareTest
*
* @package OCA\Gallery\Tests\Middleware
*/
class EnvCheckMiddlewareTest extends \Test\GalleryUnitTest {
class EnvCheckMiddlewareTest extends \OCA\Gallery\Tests\GalleryUnitTest {
/** @var IRequest */
private $request;

View File

@ -1,6 +1,7 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
@ -9,11 +10,11 @@
* @author Lukas Reschke
* @author Bernhard Posselt
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
* @copyright ownCloud Inc. 2015
*/
namespace OCA\Gallery\Middleware;
namespace OCA\Gallery\Tests\Middleware;
use OC\AppFramework\Utility\ControllerMethodReflector;
@ -26,11 +27,16 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Utility\IControllerMethodReflector;
use OCA\Gallery\Middleware\SharingCheckMiddleware;
/**
* @package OCA\Gallery\Middleware\SharingCheckMiddleware
* Class SharingCheckMiddlewareTest
*
* @todo It's not possible to test if beforeController still works as expected when sharing is
* disabled without creating a full working environment or by refactoring isSharingEnabled
*
* @package OCA\Gallery\Tests\Middleware
*/
class SharingCheckMiddlewareTest extends \Test\TestCase {

View File

@ -4,7 +4,7 @@
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*
* @license AGPL-3.0
*
@ -21,10 +21,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\Gallery\Service;
namespace OCA\Gallery\Tests\Service;
/**
* Class Base64EncodeTest
*
* @package OCA\Gallery\Tests\Service
*/
class Base64EncodeTest extends \Test\TestCase {

View File

@ -1,34 +1,36 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;
namespace OCA\Gallery\Tests\Service;
use OCP\IPreview;
use OCA\Gallery\Config\ConfigParser;
use OCA\Gallery\Config\ConfigException;
use OCA\Gallery\Preview\Preview;
use OCA\Gallery\Service\ConfigService;
/**
* Class ConfigServiceTest
*
* @package OCA\Gallery\Controller
* @package OCA\Gallery\Tests\Service
*/
class ConfigServiceTest extends \Test\GalleryUnitTest {
class ConfigServiceTest extends \OCA\Gallery\Tests\GalleryUnitTest {
/** @var ConfigService */
protected $service;
/** @var ConfigParser */
protected $configParser;
/** @var Preview */
/** @var IPreview */
protected $previewManager;
/**
@ -40,7 +42,7 @@ class ConfigServiceTest extends \Test\GalleryUnitTest {
$this->configParser = $this->getMockBuilder('\OCA\Gallery\Config\ConfigParser')
->disableOriginalConstructor()
->getMock();
$this->previewManager = $this->getMockBuilder('\OCA\Gallery\Preview\Preview')
$this->previewManager = $this->getMockBuilder('OCP\IPreview')
->disableOriginalConstructor()
->getMock();
$this->service = new ConfigService (

View File

@ -1,25 +1,30 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;
namespace OCA\Gallery\Tests\Service;
use OCP\Files\File;
use OCA\Gallery\Service\Base64Encode;
use OCA\Gallery\Service\DownloadService;
/**
* Class DownloadServiceTest
*
* @package OCA\Gallery\Controller
* @package OCA\Gallery\Tests\Service
*/
class DownloadServiceTest extends \Test\GalleryUnitTest {
class DownloadServiceTest extends \OCA\Gallery\Tests\GalleryUnitTest {
use Base64Encode;

View File

@ -1,33 +1,36 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;
namespace OCA\Gallery\Tests\Service;
use OCP\Files\File;
use OCP\IPreview;
use OCA\Gallery\Preview\Preview;
use OCA\Gallery\Service\Base64Encode;
use OCA\Gallery\Service\PreviewService;
/**
* Class PreviewServiceTest
*
* @package OCA\Gallery\Controller
* @package OCA\Gallery\Tests\Service
*/
class PreviewServiceTest extends \Test\GalleryUnitTest {
class PreviewServiceTest extends \OCA\Gallery\Tests\GalleryUnitTest {
use Base64Encode;
/** @var PreviewService */
protected $service;
/** @var Preview|\PHPUnit_Framework_MockObject_MockObject */
/** @var IPreview|\PHPUnit_Framework_MockObject_MockObject */
protected $previewManager;
/**
@ -36,7 +39,7 @@ class PreviewServiceTest extends \Test\GalleryUnitTest {
public function setUp() {
parent::setUp();
$this->previewManager = $this->getMockBuilder('\OCA\Gallery\Preview\Preview')
$this->previewManager = $this->getMockBuilder('\OCP\IPreview')
->disableOriginalConstructor()
->getMock();

View File

@ -1,23 +1,28 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;
namespace OCA\Gallery\Tests\Service;
use OCA\Gallery\Service\SearchFolderService;
use OCA\Gallery\Service\ForbiddenServiceException;
use OCA\Gallery\Service\NotFoundServiceException;
/**
* Class SearchFolderServiceTest
*
* @package OCA\Gallery\Controller
* @package OCA\Gallery\Tests\Service
*/
class SearchFolderServiceTest extends \Test\GalleryUnitTest {
class SearchFolderServiceTest extends \OCA\Gallery\Tests\GalleryUnitTest {
/** @var SearchFolderService */
protected $service;

View File

@ -1,25 +1,29 @@
<?php
/**
* Gallery
* Nextcloud - Gallery
*
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
* @copyright Olivier Paroz 2017
*/
namespace OCA\Gallery\Service;
namespace OCA\Gallery\Tests\Service;
use OCP\Files\Folder;
use OCA\Gallery\Service\SearchMediaService;
/**
* Class SearchMediaServiceTest
*
* @package OCA\Gallery\Controller
* @package OCA\Gallery\Tests\Service
*/
class SearchMediaServiceTest extends \Test\GalleryUnitTest {
class SearchMediaServiceTest extends \OCA\Gallery\Tests\GalleryUnitTest {
/** @var SearchMediaService */
protected $service;

View File

@ -1,58 +0,0 @@
<?php
/**
* Gallery
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Olivier Paroz <galleryapps@oparoz.com>
*
* @copyright Olivier Paroz 2016
*/
namespace OCA\Gallery\Preview;
use OCP\Files\File;
use OCP\IPreview;
/**
* Class PreviewTest
*
* @package OCA\Gallery\Environment
*/
class PreviewTest extends \Test\GalleryUnitTest {
/** @var IPreview|\PHPUnit_Framework_MockObject_MockObject */
private $corePreviewManager;
/** @var Preview */
private $previewManager;
/**
* Test set up
*/
public function setUp() {
parent::setUp();
$this->corePreviewManager = $this->getMockBuilder(IPreview::class)
->disableOriginalConstructor()
->getMock();
$this->previewManager = new Preview($this->corePreviewManager);
}
/**
* @expectedException \Exception
*/
public function testGetPreviewFromCoreWithBrokenSystem() {
$keepAspect = true; // Doesn't matter
$exception = new \Exception('Encryption ate your file');
$this->corePreviewManager->method('getPreview')
->willThrowException($exception);
$this->previewManager->getPreview(
$this->createMock(File::class),
42,
42,
$keepAspect
);
}
}