From a2671c82233899376752a92cfe0fb45523832039 Mon Sep 17 00:00:00 2001 From: "Olivier Paroz (oparoz)" Date: Sun, 23 Apr 2017 17:36:45 +0200 Subject: [PATCH] Migrate PHP to PSR-4 Signed-off-by: Olivier Paroz (oparoz) --- appinfo/app.php | 6 +- appinfo/routes.php | 4 +- codeception.yml | 14 +- .../AppInfo/Application.php | 30 +- .../Config/ConfigException.php | 4 +- .../Config/ConfigParser.php | 4 +- .../Config/ConfigValidator.php | 4 +- .../config.php => lib/Controller/Config.php | 4 +- .../Controller/ConfigApiController.php | 4 +- .../Controller/ConfigController.php | 4 +- .../Controller/ConfigPublicController.php | 4 +- .../files.php => lib/Controller/Files.php | 6 +- .../Controller/FilesApiController.php | 4 +- .../Controller/FilesController.php | 4 +- .../Controller/FilesPublicController.php | 4 +- .../Controller/HttpError.php | 6 +- .../Controller/PageController.php | 6 +- .../Controller/PathManipulation.php | 4 +- .../preview.php => lib/Controller/Preview.php | 10 +- .../Controller/PreviewApiController.php | 4 +- .../Controller/PreviewController.php | 4 +- .../Controller/PreviewPublicController.php | 4 +- .../Environment/Environment.php | 4 +- .../Environment/EnvironmentException.php | 4 +- .../Environment/NotFoundEnvException.php | 4 +- .../Http/ImageResponse.php | 4 +- .../Middleware/CheckException.php | 5 +- .../Middleware/CheckMiddleware.php | 6 +- .../Middleware/EnvCheckMiddleware.php | 8 +- .../Middleware/SharingCheckMiddleware.php | 8 +- .../Service/Base64Encode.php | 4 +- .../Service/ConfigService.php | 12 +- .../Service/DownloadService.php | 4 +- .../Service/FilesService.php | 4 +- .../Service/ForbiddenServiceException.php | 4 +- .../InternalServerErrorServiceException.php | 4 +- .../Service/NotFoundServiceException.php | 4 +- .../Service/PreviewService.php | 28 +- .../Service/SearchFolderService.php | 4 +- .../Service/SearchMediaService.php | 4 +- .../service.php => lib/Service/Service.php | 4 +- .../Service/ServiceException.php | 4 +- .../Service/ThumbnailService.php | 4 +- .../Utility/EventSource.php | 4 +- preview/preview.php | 75 -- tests/README.MD | 8 +- tests/_bootstrap.php | 12 +- tests/_support/Helper/CoreTestCase.php | 5 +- tests/_support/Helper/DataSetup.php | 5 +- tests/_support/Page/Acceptance/Login.php | 5 +- tests/_support/Page/Files.php | 5 +- tests/_support/Page/Gallery.php | 5 +- tests/_support/Page/Login.php | 5 +- tests/_support/Step/Api/Anonymous.php | 5 +- tests/_support/Step/Api/TokenUser.php | 5 +- tests/_support/Step/Api/User.php | 5 +- .../_support/_generated/ApiTesterActions.php | 705 ++++++++++++++++-- .../_generated/IntegrationTesterActions.php | 183 ++++- .../_support/_generated/UnitTesterActions.php | 229 ++++-- tests/acceptance/LoginCept.php | 5 +- tests/acceptance/SignInAsUserCept.php | 5 +- tests/api/CheckTestUsersCest.php | 5 +- tests/api/ConnectWithTokenCest.php | 5 +- tests/api/DownloadCest.php | 5 +- tests/api/DownloadWithTokenCest.php | 5 +- tests/api/GetConfigCest.php | 5 +- tests/api/GetFilesCest.php | 5 +- tests/api/GetPreviewCest.php | 5 +- tests/api/GetThumbnailsCest.php | 5 +- tests/api/OcsCreateUserCest.php | 5 +- tests/integration/GalleryIntegrationTest.php | 5 +- tests/integration/appinfo/AppTest.php | 13 +- tests/integration/appinfo/ApplicationTest.php | 13 +- .../environment/EnvironmentSetupTest.php | 13 +- .../{config => Config}/ConfigParserTest.php | 13 +- .../ConfigValidatorTest.php | 13 +- .../ConfigApiControllerTest.php | 9 +- .../ConfigControllerTest.php | 8 +- .../ConfigPublicControllerTest.php | 9 +- .../FilesApiControllerTest.php | 10 +- .../FilesControllerTest.php | 13 +- .../FilesPublicControllerTest.php | 9 +- .../HttpErrorTest.php | 8 +- .../PageControllerTest.php | 8 +- .../PreviewApiControllerTest.php | 10 +- .../PreviewControllerTest.php | 10 +- .../PreviewPublicControllerTest.php | 9 +- .../EnvironmentTest.php | 12 +- tests/unit/GalleryUnitTest.php | 7 +- .../unit/{http => Http}/ImageResponseTest.php | 12 +- .../EnvCheckMiddlewareTest.php | 16 +- .../SharingCheckMiddlewareTest.php | 14 +- .../{service => Service}/Base64EncodeTest.php | 7 +- .../ConfigServiceTest.php | 20 +- .../DownloadServiceTest.php | 15 +- .../PreviewServiceTest.php | 19 +- .../SearchFolderServiceTest.php | 15 +- .../SearchMediaServiceTest.php | 14 +- tests/unit/preview/PreviewTest.php | 58 -- 99 files changed, 1355 insertions(+), 608 deletions(-) rename appinfo/application.php => lib/AppInfo/Application.php (93%) rename config/configexception.php => lib/Config/ConfigException.php (91%) rename config/configparser.php => lib/Config/ConfigParser.php (99%) rename config/configvalidator.php => lib/Config/ConfigValidator.php (97%) rename controller/config.php => lib/Controller/Config.php (96%) rename controller/configapicontroller.php => lib/Controller/ConfigApiController.php (95%) rename controller/configcontroller.php => lib/Controller/ConfigController.php (95%) rename controller/configpubliccontroller.php => lib/Controller/ConfigPublicController.php (92%) rename controller/files.php => lib/Controller/Files.php (97%) rename controller/filesapicontroller.php => lib/Controller/FilesApiController.php (98%) rename controller/filescontroller.php => lib/Controller/FilesController.php (98%) rename controller/filespubliccontroller.php => lib/Controller/FilesPublicController.php (95%) rename controller/httperror.php => lib/Controller/HttpError.php (96%) rename controller/pagecontroller.php => lib/Controller/PageController.php (98%) rename controller/pathmanipulation.php => lib/Controller/PathManipulation.php (95%) rename controller/preview.php => lib/Controller/Preview.php (97%) rename controller/previewapicontroller.php => lib/Controller/PreviewApiController.php (98%) rename controller/previewcontroller.php => lib/Controller/PreviewController.php (98%) rename controller/previewpubliccontroller.php => lib/Controller/PreviewPublicController.php (96%) rename environment/environment.php => lib/Environment/Environment.php (99%) rename environment/environmentexception.php => lib/Environment/EnvironmentException.php (91%) rename environment/notfoundenvexception.php => lib/Environment/NotFoundEnvException.php (86%) rename http/imageresponse.php => lib/Http/ImageResponse.php (95%) rename middleware/checkexception.php => lib/Middleware/CheckException.php (92%) rename middleware/checkmiddleware.php => lib/Middleware/CheckMiddleware.php (97%) rename middleware/envcheckmiddleware.php => lib/Middleware/EnvCheckMiddleware.php (98%) rename middleware/sharingcheckmiddleware.php => lib/Middleware/SharingCheckMiddleware.php (94%) rename service/base64encode.php => lib/Service/Base64Encode.php (93%) rename service/configservice.php => lib/Service/ConfigService.php (98%) rename service/downloadservice.php => lib/Service/DownloadService.php (95%) rename service/filesservice.php => lib/Service/FilesService.php (99%) rename service/forbiddenserviceexception.php => lib/Service/ForbiddenServiceException.php (85%) rename service/internalservererrorserviceexception.php => lib/Service/InternalServerErrorServiceException.php (86%) rename service/notfoundserviceexception.php => lib/Service/NotFoundServiceException.php (85%) rename service/previewservice.php => lib/Service/PreviewService.php (91%) rename service/searchfolderservice.php => lib/Service/SearchFolderService.php (98%) rename service/searchmediaservice.php => lib/Service/SearchMediaService.php (99%) rename service/service.php => lib/Service/Service.php (97%) rename service/serviceexception.php => lib/Service/ServiceException.php (90%) rename service/thumbnailservice.php => lib/Service/ThumbnailService.php (94%) rename utility/eventsource.php => lib/Utility/EventSource.php (97%) delete mode 100644 preview/preview.php rename tests/unit/{config => Config}/ConfigParserTest.php (97%) rename tests/unit/{config => Config}/ConfigValidatorTest.php (90%) rename tests/unit/{controller => Controller}/ConfigApiControllerTest.php (77%) rename tests/unit/{controller => Controller}/ConfigControllerTest.php (97%) rename tests/unit/{controller => Controller}/ConfigPublicControllerTest.php (77%) rename tests/unit/{controller => Controller}/FilesApiControllerTest.php (90%) rename tests/unit/{controller => Controller}/FilesControllerTest.php (97%) rename tests/unit/{controller => Controller}/FilesPublicControllerTest.php (80%) rename tests/unit/{controller => Controller}/HttpErrorTest.php (97%) rename tests/unit/{controller => Controller}/PageControllerTest.php (98%) rename tests/unit/{controller => Controller}/PreviewApiControllerTest.php (92%) rename tests/unit/{controller => Controller}/PreviewControllerTest.php (98%) rename tests/unit/{controller => Controller}/PreviewPublicControllerTest.php (81%) rename tests/unit/{environment => Environment}/EnvironmentTest.php (90%) rename tests/unit/{http => Http}/ImageResponseTest.php (86%) rename tests/unit/{middleware => Middleware}/EnvCheckMiddlewareTest.php (97%) rename tests/unit/{middleware => Middleware}/SharingCheckMiddlewareTest.php (94%) rename tests/unit/{service => Service}/Base64EncodeTest.php (92%) rename tests/unit/{service => Service}/ConfigServiceTest.php (95%) rename tests/unit/{service => Service}/DownloadServiceTest.php (84%) rename tests/unit/{service => Service}/PreviewServiceTest.php (90%) rename tests/unit/{service => Service}/SearchFolderServiceTest.php (96%) rename tests/unit/{service => Service}/SearchMediaServiceTest.php (98%) delete mode 100644 tests/unit/preview/PreviewTest.php diff --git a/appinfo/app.php b/appinfo/app.php index f28abd0a..7dacacb4 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -1,6 +1,6 @@ * @author Robin Appelman * - * @copyright Olivier Paroz 2014-2016 - * @copyright Robin Appelman 2014-2015 + * @copyright Olivier Paroz 2017 + * @copyright Robin Appelman 2017 */ namespace OCA\Gallery\AppInfo; diff --git a/appinfo/routes.php b/appinfo/routes.php index b66c9843..7c968905 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\AppInfo; diff --git a/codeception.yml b/codeception.yml index cfa3519b..f687200d 100644 --- a/codeception.yml +++ b/codeception.yml @@ -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/* diff --git a/appinfo/application.php b/lib/AppInfo/Application.php similarity index 93% rename from appinfo/application.php rename to lib/AppInfo/Application.php index 882121da..b4c55e9a 100644 --- a/appinfo/application.php +++ b/lib/AppInfo/Application.php @@ -1,24 +1,24 @@ * - * @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') ); } diff --git a/config/configexception.php b/lib/Config/ConfigException.php similarity index 91% rename from config/configexception.php rename to lib/Config/ConfigException.php index 0171140e..1d5a08fa 100644 --- a/config/configexception.php +++ b/lib/Config/ConfigException.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Config; diff --git a/config/configparser.php b/lib/Config/ConfigParser.php similarity index 99% rename from config/configparser.php rename to lib/Config/ConfigParser.php index 5338d11d..5f9e0f28 100644 --- a/config/configparser.php +++ b/lib/Config/ConfigParser.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Config; diff --git a/config/configvalidator.php b/lib/Config/ConfigValidator.php similarity index 97% rename from config/configvalidator.php rename to lib/Config/ConfigValidator.php index 2cfc171c..386ef246 100644 --- a/config/configvalidator.php +++ b/lib/Config/ConfigValidator.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Config; diff --git a/controller/config.php b/lib/Controller/Config.php similarity index 96% rename from controller/config.php rename to lib/Controller/Config.php index 02b26fbb..0a5e41b6 100644 --- a/controller/config.php +++ b/lib/Controller/Config.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/configapicontroller.php b/lib/Controller/ConfigApiController.php similarity index 95% rename from controller/configapicontroller.php rename to lib/Controller/ConfigApiController.php index 1ed00636..21e4dd45 100644 --- a/controller/configapicontroller.php +++ b/lib/Controller/ConfigApiController.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/configcontroller.php b/lib/Controller/ConfigController.php similarity index 95% rename from controller/configcontroller.php rename to lib/Controller/ConfigController.php index b5354886..ce949442 100644 --- a/controller/configcontroller.php +++ b/lib/Controller/ConfigController.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/configpubliccontroller.php b/lib/Controller/ConfigPublicController.php similarity index 92% rename from controller/configpubliccontroller.php rename to lib/Controller/ConfigPublicController.php index b6b204b3..8f76729f 100644 --- a/controller/configpubliccontroller.php +++ b/lib/Controller/ConfigPublicController.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/files.php b/lib/Controller/Files.php similarity index 97% rename from controller/files.php rename to lib/Controller/Files.php index 5302bddc..7e9cf60b 100644 --- a/controller/files.php +++ b/lib/Controller/Files.php @@ -1,6 +1,6 @@ * @author Robin Appelman * - * @copyright Olivier Paroz 2014-2016 - * @copyright Robin Appelman 2012-2014 + * @copyright Olivier Paroz 2017 + * @copyright Robin Appelman 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/filesapicontroller.php b/lib/Controller/FilesApiController.php similarity index 98% rename from controller/filesapicontroller.php rename to lib/Controller/FilesApiController.php index 6fe341b0..9e0e8528 100644 --- a/controller/filesapicontroller.php +++ b/lib/Controller/FilesApiController.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/filescontroller.php b/lib/Controller/FilesController.php similarity index 98% rename from controller/filescontroller.php rename to lib/Controller/FilesController.php index 7ce6ca9b..3c40e567 100644 --- a/controller/filescontroller.php +++ b/lib/Controller/FilesController.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/filespubliccontroller.php b/lib/Controller/FilesPublicController.php similarity index 95% rename from controller/filespubliccontroller.php rename to lib/Controller/FilesPublicController.php index b6db04d2..a34b6b04 100644 --- a/controller/filespubliccontroller.php +++ b/lib/Controller/FilesPublicController.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/httperror.php b/lib/Controller/HttpError.php similarity index 96% rename from controller/httperror.php rename to lib/Controller/HttpError.php index 50cd3368..480f15b3 100644 --- a/controller/httperror.php +++ b/lib/Controller/HttpError.php @@ -1,6 +1,6 @@ * @author Olivier Paroz * - * @copyright Bernhard Posselt 2014-2015 - * @copyright Olivier Paroz 2014-2016 + * @copyright Bernhard Posselt 2017 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/pagecontroller.php b/lib/Controller/PageController.php similarity index 98% rename from controller/pagecontroller.php rename to lib/Controller/PageController.php index 14192f0c..f02be40c 100644 --- a/controller/pagecontroller.php +++ b/lib/Controller/PageController.php @@ -1,6 +1,6 @@ * @author Olivier Paroz * - * @copyright Robin Appelman 2012-2015 - * @copyright Olivier Paroz 2014-2016 + * @copyright Robin Appelman 2017 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/pathmanipulation.php b/lib/Controller/PathManipulation.php similarity index 95% rename from controller/pathmanipulation.php rename to lib/Controller/PathManipulation.php index e0fdef0d..a8a96a82 100644 --- a/controller/pathmanipulation.php +++ b/lib/Controller/PathManipulation.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/preview.php b/lib/Controller/Preview.php similarity index 97% rename from controller/preview.php rename to lib/Controller/Preview.php index c1ee3382..60f88ddf 100644 --- a/controller/preview.php +++ b/lib/Controller/Preview.php @@ -1,6 +1,6 @@ * @author Robin Appelman * - * @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 + * @return array */ private function getErrorData($status = Http::STATUS_INTERNAL_SERVER_ERROR) { return [null, $status]; diff --git a/controller/previewapicontroller.php b/lib/Controller/PreviewApiController.php similarity index 98% rename from controller/previewapicontroller.php rename to lib/Controller/PreviewApiController.php index f3e536d9..51f7eb43 100644 --- a/controller/previewapicontroller.php +++ b/lib/Controller/PreviewApiController.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/previewcontroller.php b/lib/Controller/PreviewController.php similarity index 98% rename from controller/previewcontroller.php rename to lib/Controller/PreviewController.php index c13a1c58..83f31912 100644 --- a/controller/previewcontroller.php +++ b/lib/Controller/PreviewController.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/controller/previewpubliccontroller.php b/lib/Controller/PreviewPublicController.php similarity index 96% rename from controller/previewpubliccontroller.php rename to lib/Controller/PreviewPublicController.php index 5c38139b..49f495ee 100644 --- a/controller/previewpubliccontroller.php +++ b/lib/Controller/PreviewPublicController.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Controller; diff --git a/environment/environment.php b/lib/Environment/Environment.php similarity index 99% rename from environment/environment.php rename to lib/Environment/Environment.php index 99d06c44..02b42764 100644 --- a/environment/environment.php +++ b/lib/Environment/Environment.php @@ -1,6 +1,6 @@ * @author Authors of \OCA\Files_Sharing\Helper * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 * @copyright Authors of \OCA\Files_Sharing\Helper 2014-2016 */ diff --git a/environment/environmentexception.php b/lib/Environment/EnvironmentException.php similarity index 91% rename from environment/environmentexception.php rename to lib/Environment/EnvironmentException.php index b9a3c635..be0c51e7 100644 --- a/environment/environmentexception.php +++ b/lib/Environment/EnvironmentException.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Environment; diff --git a/environment/notfoundenvexception.php b/lib/Environment/NotFoundEnvException.php similarity index 86% rename from environment/notfoundenvexception.php rename to lib/Environment/NotFoundEnvException.php index cdb59e59..3755ea22 100644 --- a/environment/notfoundenvexception.php +++ b/lib/Environment/NotFoundEnvException.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Environment; diff --git a/http/imageresponse.php b/lib/Http/ImageResponse.php similarity index 95% rename from http/imageresponse.php rename to lib/Http/ImageResponse.php index 4cdd3964..2e3e91ea 100644 --- a/http/imageresponse.php +++ b/lib/Http/ImageResponse.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Http; diff --git a/middleware/checkexception.php b/lib/Middleware/CheckException.php similarity index 92% rename from middleware/checkexception.php rename to lib/Middleware/CheckException.php index 910112c2..bf04520e 100644 --- a/middleware/checkexception.php +++ b/lib/Middleware/CheckException.php @@ -1,14 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Middleware; diff --git a/middleware/checkmiddleware.php b/lib/Middleware/CheckMiddleware.php similarity index 97% rename from middleware/checkmiddleware.php rename to lib/Middleware/CheckMiddleware.php index 6530d33e..b65e3bd1 100644 --- a/middleware/checkmiddleware.php +++ b/lib/Middleware/CheckMiddleware.php @@ -1,6 +1,6 @@ * @author Bernhard Posselt * - * @copyright Olivier Paroz 2014-2016 - * @copyright Bernhard Posselt 2012-2015 + * @copyright Olivier Paroz 2017 + * @copyright Bernhard Posselt 2017 */ namespace OCA\Gallery\Middleware; diff --git a/middleware/envcheckmiddleware.php b/lib/Middleware/EnvCheckMiddleware.php similarity index 98% rename from middleware/envcheckmiddleware.php rename to lib/Middleware/EnvCheckMiddleware.php index bfcd1106..43b57845 100644 --- a/middleware/envcheckmiddleware.php +++ b/lib/Middleware/EnvCheckMiddleware.php @@ -1,6 +1,6 @@ * @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; diff --git a/middleware/sharingcheckmiddleware.php b/lib/Middleware/SharingCheckMiddleware.php similarity index 94% rename from middleware/sharingcheckmiddleware.php rename to lib/Middleware/SharingCheckMiddleware.php index e85e1371..1079d9ba 100644 --- a/middleware/sharingcheckmiddleware.php +++ b/lib/Middleware/SharingCheckMiddleware.php @@ -1,15 +1,15 @@ + * @author Lukas Reschke * @author Olivier Paroz * - * @copyright Lukas Reschke 2014-2015 - * @copyright Olivier Paroz 2014-2016 + * @copyright Lukas Reschke 2017 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Middleware; diff --git a/service/base64encode.php b/lib/Service/Base64Encode.php similarity index 93% rename from service/base64encode.php rename to lib/Service/Base64Encode.php index 73bc66bc..2d7e1e66 100644 --- a/service/base64encode.php +++ b/lib/Service/Base64Encode.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/configservice.php b/lib/Service/ConfigService.php similarity index 98% rename from service/configservice.php rename to lib/Service/ConfigService.php index b51e9f9c..e8abe0d6 100644 --- a/service/configservice.php +++ b/lib/Service/ConfigService.php @@ -1,24 +1,24 @@ * - * @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); diff --git a/service/downloadservice.php b/lib/Service/DownloadService.php similarity index 95% rename from service/downloadservice.php rename to lib/Service/DownloadService.php index fa6a9446..0d659560 100644 --- a/service/downloadservice.php +++ b/lib/Service/DownloadService.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/filesservice.php b/lib/Service/FilesService.php similarity index 99% rename from service/filesservice.php rename to lib/Service/FilesService.php index 066d12e5..8df8adee 100644 --- a/service/filesservice.php +++ b/lib/Service/FilesService.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/forbiddenserviceexception.php b/lib/Service/ForbiddenServiceException.php similarity index 85% rename from service/forbiddenserviceexception.php rename to lib/Service/ForbiddenServiceException.php index 22028a69..15867343 100644 --- a/service/forbiddenserviceexception.php +++ b/lib/Service/ForbiddenServiceException.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/internalservererrorserviceexception.php b/lib/Service/InternalServerErrorServiceException.php similarity index 86% rename from service/internalservererrorserviceexception.php rename to lib/Service/InternalServerErrorServiceException.php index dff64102..75a7c92b 100644 --- a/service/internalservererrorserviceexception.php +++ b/lib/Service/InternalServerErrorServiceException.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/notfoundserviceexception.php b/lib/Service/NotFoundServiceException.php similarity index 85% rename from service/notfoundserviceexception.php rename to lib/Service/NotFoundServiceException.php index 163d18f0..afe35a84 100644 --- a/service/notfoundserviceexception.php +++ b/lib/Service/NotFoundServiceException.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/previewservice.php b/lib/Service/PreviewService.php similarity index 91% rename from service/previewservice.php rename to lib/Service/PreviewService.php index 8c2c8bca..18b58535 100644 --- a/service/previewservice.php +++ b/lib/Service/PreviewService.php @@ -1,22 +1,23 @@ * - * @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 |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'); } diff --git a/service/searchfolderservice.php b/lib/Service/SearchFolderService.php similarity index 98% rename from service/searchfolderservice.php rename to lib/Service/SearchFolderService.php index 4e9e54fe..30d3c8d2 100644 --- a/service/searchfolderservice.php +++ b/lib/Service/SearchFolderService.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/searchmediaservice.php b/lib/Service/SearchMediaService.php similarity index 99% rename from service/searchmediaservice.php rename to lib/Service/SearchMediaService.php index 91b9bb18..56af034d 100644 --- a/service/searchmediaservice.php +++ b/lib/Service/SearchMediaService.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/service.php b/lib/Service/Service.php similarity index 97% rename from service/service.php rename to lib/Service/Service.php index 9bfc4f92..ff56a13e 100644 --- a/service/service.php +++ b/lib/Service/Service.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/serviceexception.php b/lib/Service/ServiceException.php similarity index 90% rename from service/serviceexception.php rename to lib/Service/ServiceException.php index bd5d93a4..7d186e91 100644 --- a/service/serviceexception.php +++ b/lib/Service/ServiceException.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/service/thumbnailservice.php b/lib/Service/ThumbnailService.php similarity index 94% rename from service/thumbnailservice.php rename to lib/Service/ThumbnailService.php index 5401d912..1b6f56b5 100644 --- a/service/thumbnailservice.php +++ b/lib/Service/ThumbnailService.php @@ -1,13 +1,13 @@ * - * @copyright Olivier Paroz 2014-2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Service; diff --git a/utility/eventsource.php b/lib/Utility/EventSource.php similarity index 97% rename from utility/eventsource.php rename to lib/Utility/EventSource.php index de6425ed..e1db6602 100644 --- a/utility/eventsource.php +++ b/lib/Utility/EventSource.php @@ -1,6 +1,6 @@ * * @copyright Copyright (c) 2015, ownCloud, Inc. - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Utility; diff --git a/preview/preview.php b/preview/preview.php deleted file mode 100644 index 114c0725..00000000 --- a/preview/preview.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * @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 - */ - 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() - ]; - } - -} diff --git a/tests/README.MD b/tests/README.MD index 499d5fda..2870dffc 100644 --- a/tests/README.MD +++ b/tests/README.MD @@ -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 ./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 diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 6dc20c50..3b530d65 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -1,18 +1,20 @@ * - * @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(); diff --git a/tests/_support/Helper/CoreTestCase.php b/tests/_support/Helper/CoreTestCase.php index 48d257fa..f10e185b 100644 --- a/tests/_support/Helper/CoreTestCase.php +++ b/tests/_support/Helper/CoreTestCase.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace Helper; diff --git a/tests/_support/Helper/DataSetup.php b/tests/_support/Helper/DataSetup.php index e91fbf97..3ff5766e 100644 --- a/tests/_support/Helper/DataSetup.php +++ b/tests/_support/Helper/DataSetup.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace Helper; diff --git a/tests/_support/Page/Acceptance/Login.php b/tests/_support/Page/Acceptance/Login.php index cb28c7c8..14435d4d 100644 --- a/tests/_support/Page/Acceptance/Login.php +++ b/tests/_support/Page/Acceptance/Login.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace Page\Acceptance; diff --git a/tests/_support/Page/Files.php b/tests/_support/Page/Files.php index 610ed075..3ffe2ac2 100644 --- a/tests/_support/Page/Files.php +++ b/tests/_support/Page/Files.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace Page; diff --git a/tests/_support/Page/Gallery.php b/tests/_support/Page/Gallery.php index 6f23b5f8..39c12b61 100644 --- a/tests/_support/Page/Gallery.php +++ b/tests/_support/Page/Gallery.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace Page; diff --git a/tests/_support/Page/Login.php b/tests/_support/Page/Login.php index 6baacf32..6b922f76 100644 --- a/tests/_support/Page/Login.php +++ b/tests/_support/Page/Login.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace Page; diff --git a/tests/_support/Step/Api/Anonymous.php b/tests/_support/Step/Api/Anonymous.php index 0cc0bdf0..26d672fd 100644 --- a/tests/_support/Step/Api/Anonymous.php +++ b/tests/_support/Step/Api/Anonymous.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace Step\Api; diff --git a/tests/_support/Step/Api/TokenUser.php b/tests/_support/Step/Api/TokenUser.php index 00ecd411..26c9e2e4 100644 --- a/tests/_support/Step/Api/TokenUser.php +++ b/tests/_support/Step/Api/TokenUser.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace Step\Api; diff --git a/tests/_support/Step/Api/User.php b/tests/_support/Step/Api/User.php index fab7997f..9bb36037 100644 --- a/tests/_support/Step/Api/User.php +++ b/tests/_support/Step/Api/User.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace Step\Api; diff --git a/tests/_support/_generated/ApiTesterActions.php b/tests/_support/_generated/ApiTesterActions.php index ee203cab..73cd5904 100644 --- a/tests/_support/_generated/ApiTesterActions.php +++ b/tests/_support/_generated/ApiTesterActions.php @@ -1,4 +1,4 @@ -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 + * 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 + * 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 + * 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 + * 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 * 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 + * 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 + * 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 + * '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 + * 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 + * 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 + * '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 + * 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 + * 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 + * 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 + * 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 + * seeBinaryResponseEquals("8c90748342f19b195b9c6b4eff742ded"); + * ?> + * ``` + * + * Example: Using md5 for a file contents + * + * ```php + * seeBinaryResponseEquals(md5($fileData)); + * ?> + * ``` + * Example: Using sha256 hsah + * + * ```php + * 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 + * seeBinaryResponseEquals("8c90748342f19b195b9c6b4eff742ded"); + * ?> + * ``` + * + * Example: Using md5 for a file contents + * + * ```php + * seeBinaryResponseEquals(md5($fileData)); + * ?> + * ``` + * Example: Using sha256 hsah + * + * ```php + * 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 + * 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 + * 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 + * 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 + * 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())); + } } diff --git a/tests/_support/_generated/IntegrationTesterActions.php b/tests/_support/_generated/IntegrationTesterActions.php index 151b7c9d..2480dd98 100644 --- a/tests/_support/_generated/IntegrationTesterActions.php +++ b/tests/_support/_generated/IntegrationTesterActions.php @@ -1,4 +1,4 @@ -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 + * 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 + * 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. * diff --git a/tests/_support/_generated/UnitTesterActions.php b/tests/_support/_generated/UnitTesterActions.php index acca33a7..b5d3d77f 100644 --- a/tests/_support/_generated/UnitTesterActions.php +++ b/tests/_support/_generated/UnitTesterActions.php @@ -1,4 +1,4 @@ -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 - * @see \Helper\DataSetup::getFilesDataForFolder() + * Handles and checks exception called inside callback function. + * Either exception class name or exception instance should be provided. + * + * ```php + * 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 + * 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())); } } diff --git a/tests/acceptance/LoginCept.php b/tests/acceptance/LoginCept.php index 220ff173..49820f4a 100644 --- a/tests/acceptance/LoginCept.php +++ b/tests/acceptance/LoginCept.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Page\Login as LoginPage; diff --git a/tests/acceptance/SignInAsUserCept.php b/tests/acceptance/SignInAsUserCept.php index 25bff647..0e22d13b 100644 --- a/tests/acceptance/SignInAsUserCept.php +++ b/tests/acceptance/SignInAsUserCept.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use \Page\Acceptance\Login; diff --git a/tests/api/CheckTestUsersCest.php b/tests/api/CheckTestUsersCest.php index 9420bddf..2e8c2d82 100644 --- a/tests/api/CheckTestUsersCest.php +++ b/tests/api/CheckTestUsersCest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Helper\DataSetup; diff --git a/tests/api/ConnectWithTokenCest.php b/tests/api/ConnectWithTokenCest.php index f117feba..9a3c4846 100644 --- a/tests/api/ConnectWithTokenCest.php +++ b/tests/api/ConnectWithTokenCest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Page\Gallery as GalleryApp; diff --git a/tests/api/DownloadCest.php b/tests/api/DownloadCest.php index 18c4fd10..3aea273a 100644 --- a/tests/api/DownloadCest.php +++ b/tests/api/DownloadCest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Page\Gallery as GalleryApp; diff --git a/tests/api/DownloadWithTokenCest.php b/tests/api/DownloadWithTokenCest.php index f974d496..37b31176 100644 --- a/tests/api/DownloadWithTokenCest.php +++ b/tests/api/DownloadWithTokenCest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Page\Gallery as GalleryApp; diff --git a/tests/api/GetConfigCest.php b/tests/api/GetConfigCest.php index c856032b..9bc0eaa7 100644 --- a/tests/api/GetConfigCest.php +++ b/tests/api/GetConfigCest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Page\Gallery as GalleryApp; diff --git a/tests/api/GetFilesCest.php b/tests/api/GetFilesCest.php index ae84bd36..3fbf5120 100644 --- a/tests/api/GetFilesCest.php +++ b/tests/api/GetFilesCest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Page\Gallery as GalleryApp; diff --git a/tests/api/GetPreviewCest.php b/tests/api/GetPreviewCest.php index f1346a50..421d2f08 100644 --- a/tests/api/GetPreviewCest.php +++ b/tests/api/GetPreviewCest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Page\Gallery as GalleryApp; diff --git a/tests/api/GetThumbnailsCest.php b/tests/api/GetThumbnailsCest.php index 39cfb727..65d4df0e 100644 --- a/tests/api/GetThumbnailsCest.php +++ b/tests/api/GetThumbnailsCest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Page\Gallery as GalleryApp; diff --git a/tests/api/OcsCreateUserCest.php b/tests/api/OcsCreateUserCest.php index 7cb20027..c9eceb83 100644 --- a/tests/api/OcsCreateUserCest.php +++ b/tests/api/OcsCreateUserCest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ use Codeception\Util\Xml as XmlUtils; diff --git a/tests/integration/GalleryIntegrationTest.php b/tests/integration/GalleryIntegrationTest.php index 3686cebf..0739a3f5 100644 --- a/tests/integration/GalleryIntegrationTest.php +++ b/tests/integration/GalleryIntegrationTest.php @@ -1,13 +1,14 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ namespace OCA\Gallery\Tests\Integration; diff --git a/tests/integration/appinfo/AppTest.php b/tests/integration/appinfo/AppTest.php index fc5adf95..d1693b12 100644 --- a/tests/integration/appinfo/AppTest.php +++ b/tests/integration/appinfo/AppTest.php @@ -1,27 +1,26 @@ * - * @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'); diff --git a/tests/integration/appinfo/ApplicationTest.php b/tests/integration/appinfo/ApplicationTest.php index 63c5edb8..b83fdd1e 100644 --- a/tests/integration/appinfo/ApplicationTest.php +++ b/tests/integration/appinfo/ApplicationTest.php @@ -1,25 +1,24 @@ * - * @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 [ diff --git a/tests/integration/environment/EnvironmentSetupTest.php b/tests/integration/environment/EnvironmentSetupTest.php index 857d3b74..d18e48e3 100644 --- a/tests/integration/environment/EnvironmentSetupTest.php +++ b/tests/integration/environment/EnvironmentSetupTest.php @@ -1,28 +1,29 @@ * - * @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 diff --git a/tests/unit/config/ConfigParserTest.php b/tests/unit/Config/ConfigParserTest.php similarity index 97% rename from tests/unit/config/ConfigParserTest.php rename to tests/unit/Config/ConfigParserTest.php index 6d718dcf..5d8dce8f 100644 --- a/tests/unit/config/ConfigParserTest.php +++ b/tests/unit/Config/ConfigParserTest.php @@ -1,16 +1,19 @@ * - * @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'; diff --git a/tests/unit/config/ConfigValidatorTest.php b/tests/unit/Config/ConfigValidatorTest.php similarity index 90% rename from tests/unit/config/ConfigValidatorTest.php rename to tests/unit/Config/ConfigValidatorTest.php index 152e16cf..edcb7135 100644 --- a/tests/unit/config/ConfigValidatorTest.php +++ b/tests/unit/Config/ConfigValidatorTest.php @@ -1,23 +1,26 @@ * - * @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; diff --git a/tests/unit/controller/ConfigApiControllerTest.php b/tests/unit/Controller/ConfigApiControllerTest.php similarity index 77% rename from tests/unit/controller/ConfigApiControllerTest.php rename to tests/unit/Controller/ConfigApiControllerTest.php index d7cebb24..60d8e8e5 100644 --- a/tests/unit/controller/ConfigApiControllerTest.php +++ b/tests/unit/Controller/ConfigApiControllerTest.php @@ -1,18 +1,19 @@ * - * @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 diff --git a/tests/unit/controller/ConfigControllerTest.php b/tests/unit/Controller/ConfigControllerTest.php similarity index 97% rename from tests/unit/controller/ConfigControllerTest.php rename to tests/unit/Controller/ConfigControllerTest.php index 0144cc97..aa5c7754 100644 --- a/tests/unit/controller/ConfigControllerTest.php +++ b/tests/unit/Controller/ConfigControllerTest.php @@ -1,16 +1,17 @@ * - * @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; diff --git a/tests/unit/controller/ConfigPublicControllerTest.php b/tests/unit/Controller/ConfigPublicControllerTest.php similarity index 77% rename from tests/unit/controller/ConfigPublicControllerTest.php rename to tests/unit/Controller/ConfigPublicControllerTest.php index acb18bc1..98bf322b 100644 --- a/tests/unit/controller/ConfigPublicControllerTest.php +++ b/tests/unit/Controller/ConfigPublicControllerTest.php @@ -1,18 +1,19 @@ * - * @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 diff --git a/tests/unit/controller/FilesApiControllerTest.php b/tests/unit/Controller/FilesApiControllerTest.php similarity index 90% rename from tests/unit/controller/FilesApiControllerTest.php rename to tests/unit/Controller/FilesApiControllerTest.php index bd0f5fef..d8a6ef21 100644 --- a/tests/unit/controller/FilesApiControllerTest.php +++ b/tests/unit/Controller/FilesApiControllerTest.php @@ -1,22 +1,22 @@ * - * @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; /** diff --git a/tests/unit/controller/FilesControllerTest.php b/tests/unit/Controller/FilesControllerTest.php similarity index 97% rename from tests/unit/controller/FilesControllerTest.php rename to tests/unit/Controller/FilesControllerTest.php index 7062474c..168a4c64 100644 --- a/tests/unit/controller/FilesControllerTest.php +++ b/tests/unit/Controller/FilesControllerTest.php @@ -1,18 +1,18 @@ * - * @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; diff --git a/tests/unit/controller/FilesPublicControllerTest.php b/tests/unit/Controller/FilesPublicControllerTest.php similarity index 80% rename from tests/unit/controller/FilesPublicControllerTest.php rename to tests/unit/Controller/FilesPublicControllerTest.php index d55d3f23..ce20949e 100644 --- a/tests/unit/controller/FilesPublicControllerTest.php +++ b/tests/unit/Controller/FilesPublicControllerTest.php @@ -1,18 +1,19 @@ * - * @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 diff --git a/tests/unit/controller/HttpErrorTest.php b/tests/unit/Controller/HttpErrorTest.php similarity index 97% rename from tests/unit/controller/HttpErrorTest.php rename to tests/unit/Controller/HttpErrorTest.php index 0796f278..45c9d230 100644 --- a/tests/unit/controller/HttpErrorTest.php +++ b/tests/unit/Controller/HttpErrorTest.php @@ -1,21 +1,23 @@ * - * @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; diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/Controller/PageControllerTest.php similarity index 98% rename from tests/unit/controller/PageControllerTest.php rename to tests/unit/Controller/PageControllerTest.php index e70f37bf..3fc89d29 100644 --- a/tests/unit/controller/PageControllerTest.php +++ b/tests/unit/Controller/PageControllerTest.php @@ -1,16 +1,17 @@ * - * @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; /** diff --git a/tests/unit/controller/PreviewApiControllerTest.php b/tests/unit/Controller/PreviewApiControllerTest.php similarity index 92% rename from tests/unit/controller/PreviewApiControllerTest.php rename to tests/unit/Controller/PreviewApiControllerTest.php index 78afab34..7193921a 100644 --- a/tests/unit/controller/PreviewApiControllerTest.php +++ b/tests/unit/Controller/PreviewApiControllerTest.php @@ -1,23 +1,23 @@ * - * @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; /** diff --git a/tests/unit/controller/PreviewControllerTest.php b/tests/unit/Controller/PreviewControllerTest.php similarity index 98% rename from tests/unit/controller/PreviewControllerTest.php rename to tests/unit/Controller/PreviewControllerTest.php index 3b0b9e32..81a70e0e 100644 --- a/tests/unit/controller/PreviewControllerTest.php +++ b/tests/unit/Controller/PreviewControllerTest.php @@ -1,16 +1,17 @@ * - * @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; diff --git a/tests/unit/controller/PreviewPublicControllerTest.php b/tests/unit/Controller/PreviewPublicControllerTest.php similarity index 81% rename from tests/unit/controller/PreviewPublicControllerTest.php rename to tests/unit/Controller/PreviewPublicControllerTest.php index f797268d..d284c4b7 100644 --- a/tests/unit/controller/PreviewPublicControllerTest.php +++ b/tests/unit/Controller/PreviewPublicControllerTest.php @@ -1,18 +1,19 @@ * - * @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 diff --git a/tests/unit/environment/EnvironmentTest.php b/tests/unit/Environment/EnvironmentTest.php similarity index 90% rename from tests/unit/environment/EnvironmentTest.php rename to tests/unit/Environment/EnvironmentTest.php index d66dcc6e..dc43b8ae 100644 --- a/tests/unit/environment/EnvironmentTest.php +++ b/tests/unit/Environment/EnvironmentTest.php @@ -1,16 +1,17 @@ * - * @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 { diff --git a/tests/unit/GalleryUnitTest.php b/tests/unit/GalleryUnitTest.php index eb67be61..9edc49c1 100644 --- a/tests/unit/GalleryUnitTest.php +++ b/tests/unit/GalleryUnitTest.php @@ -1,16 +1,17 @@ * - * @copyright Olivier Paroz 2016 + * @copyright Olivier Paroz 2017 */ -namespace Test; +namespace OCA\Gallery\Tests; use OCP\ILogger; use OCP\Files\File; diff --git a/tests/unit/http/ImageResponseTest.php b/tests/unit/Http/ImageResponseTest.php similarity index 86% rename from tests/unit/http/ImageResponseTest.php rename to tests/unit/Http/ImageResponseTest.php index 6f266bbe..4403246d 100644 --- a/tests/unit/http/ImageResponseTest.php +++ b/tests/unit/Http/ImageResponseTest.php @@ -1,22 +1,26 @@ * - * @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 { diff --git a/tests/unit/middleware/EnvCheckMiddlewareTest.php b/tests/unit/Middleware/EnvCheckMiddlewareTest.php similarity index 97% rename from tests/unit/middleware/EnvCheckMiddlewareTest.php rename to tests/unit/Middleware/EnvCheckMiddlewareTest.php index 6790b6a2..6f70799c 100644 --- a/tests/unit/middleware/EnvCheckMiddlewareTest.php +++ b/tests/unit/Middleware/EnvCheckMiddlewareTest.php @@ -1,16 +1,17 @@ * - * @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; diff --git a/tests/unit/middleware/SharingCheckMiddlewareTest.php b/tests/unit/Middleware/SharingCheckMiddlewareTest.php similarity index 94% rename from tests/unit/middleware/SharingCheckMiddlewareTest.php rename to tests/unit/Middleware/SharingCheckMiddlewareTest.php index ab928b84..b4a68700 100644 --- a/tests/unit/middleware/SharingCheckMiddlewareTest.php +++ b/tests/unit/Middleware/SharingCheckMiddlewareTest.php @@ -1,6 +1,7 @@ * * @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 * */ -namespace OCA\Gallery\Service; + +namespace OCA\Gallery\Tests\Service; /** * Class Base64EncodeTest + * + * @package OCA\Gallery\Tests\Service */ class Base64EncodeTest extends \Test\TestCase { diff --git a/tests/unit/service/ConfigServiceTest.php b/tests/unit/Service/ConfigServiceTest.php similarity index 95% rename from tests/unit/service/ConfigServiceTest.php rename to tests/unit/Service/ConfigServiceTest.php index d96f2753..a59b604a 100644 --- a/tests/unit/service/ConfigServiceTest.php +++ b/tests/unit/Service/ConfigServiceTest.php @@ -1,34 +1,36 @@ * - * @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 ( diff --git a/tests/unit/service/DownloadServiceTest.php b/tests/unit/Service/DownloadServiceTest.php similarity index 84% rename from tests/unit/service/DownloadServiceTest.php rename to tests/unit/Service/DownloadServiceTest.php index eb477926..c62e3651 100644 --- a/tests/unit/service/DownloadServiceTest.php +++ b/tests/unit/Service/DownloadServiceTest.php @@ -1,25 +1,30 @@ * - * @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; diff --git a/tests/unit/service/PreviewServiceTest.php b/tests/unit/Service/PreviewServiceTest.php similarity index 90% rename from tests/unit/service/PreviewServiceTest.php rename to tests/unit/Service/PreviewServiceTest.php index a9ae8679..ae579049 100644 --- a/tests/unit/service/PreviewServiceTest.php +++ b/tests/unit/Service/PreviewServiceTest.php @@ -1,33 +1,36 @@ * - * @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(); diff --git a/tests/unit/service/SearchFolderServiceTest.php b/tests/unit/Service/SearchFolderServiceTest.php similarity index 96% rename from tests/unit/service/SearchFolderServiceTest.php rename to tests/unit/Service/SearchFolderServiceTest.php index 1f83dbae..3049453f 100644 --- a/tests/unit/service/SearchFolderServiceTest.php +++ b/tests/unit/Service/SearchFolderServiceTest.php @@ -1,23 +1,28 @@ * - * @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; diff --git a/tests/unit/service/SearchMediaServiceTest.php b/tests/unit/Service/SearchMediaServiceTest.php similarity index 98% rename from tests/unit/service/SearchMediaServiceTest.php rename to tests/unit/Service/SearchMediaServiceTest.php index 81333057..4a52f8d4 100644 --- a/tests/unit/service/SearchMediaServiceTest.php +++ b/tests/unit/Service/SearchMediaServiceTest.php @@ -1,25 +1,29 @@ * - * @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; diff --git a/tests/unit/preview/PreviewTest.php b/tests/unit/preview/PreviewTest.php deleted file mode 100644 index fa6af97f..00000000 --- a/tests/unit/preview/PreviewTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * @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 - ); - } -}