From dcfccc04e9c27eb4014a2c5c269e30f6dde23922 Mon Sep 17 00:00:00 2001 From: Ruslan Baidan Date: Thu, 14 May 2020 23:43:02 +0200 Subject: [PATCH] Added the basic tests to cover stats generation, added a possibility to execute the tests from host machine. --- composer.json | 2 +- composer.lock | 752 +++++++++++++++--- .../ApiAdminUsersControllerTest.php | 2 +- .../AbstractIntegrationTestCase.php | 38 + .../Service/StatsApiServiceTest.php | 83 ++ tests/config/local.php | 22 +- tests/scripts/setup_db.sh | 15 +- 7 files changed, 792 insertions(+), 122 deletions(-) create mode 100644 tests/Integration/AbstractIntegrationTestCase.php create mode 100644 tests/Integration/Service/StatsApiServiceTest.php diff --git a/composer.json b/composer.json index d1da139..e7bcedc 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "ext-json": "*", "ext-pdo": "*", "monarc/frontoffice": "dev-feature/stats", - "monarc/core": "^2.9.15", + "monarc/core": "dev-feature/stats as 2.9.18", "laminas/laminas-mvc": "^3.1", "laminas/laminas-di": "^3.1", "laminas/laminas-permissions-rbac": "^3.0", diff --git a/composer.lock b/composer.lock index b9714d9..e5854a5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "443aa5df52b237a67e9c157b8813bfd2", + "content-hash": "eb1f56ed4a5268340b0a0b42c260c7c5", "packages": [ { "name": "brick/math", @@ -60,16 +60,16 @@ }, { "name": "cakephp/cache", - "version": "3.8.11", + "version": "3.8.12", "source": { "type": "git", "url": "https://github.com/cakephp/cache.git", - "reference": "4c261d241f30cda8c6636cf8a22d01797a89009b" + "reference": "09b2a1c4929e134456d30c61d9dbf6e10ace8436" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/cache/zipball/4c261d241f30cda8c6636cf8a22d01797a89009b", - "reference": "4c261d241f30cda8c6636cf8a22d01797a89009b", + "url": "https://api.github.com/repos/cakephp/cache/zipball/09b2a1c4929e134456d30c61d9dbf6e10ace8436", + "reference": "09b2a1c4929e134456d30c61d9dbf6e10ace8436", "shasum": "" }, "require": { @@ -100,11 +100,11 @@ "caching", "cakephp" ], - "time": "2020-03-02T21:42:14+00:00" + "time": "2020-04-19T21:38:42+00:00" }, { "name": "cakephp/collection", - "version": "3.8.11", + "version": "3.8.12", "source": { "type": "git", "url": "https://github.com/cakephp/collection.git", @@ -150,7 +150,7 @@ }, { "name": "cakephp/core", - "version": "3.8.11", + "version": "3.8.12", "source": { "type": "git", "url": "https://github.com/cakephp/core.git", @@ -200,16 +200,16 @@ }, { "name": "cakephp/database", - "version": "3.8.11", + "version": "3.8.12", "source": { "type": "git", "url": "https://github.com/cakephp/database.git", - "reference": "100542d4364a6de674c37bb605ac2fce5a8cc0cd" + "reference": "489591545fd223d6cdbf022049f7c73ede0cb4fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/database/zipball/100542d4364a6de674c37bb605ac2fce5a8cc0cd", - "reference": "100542d4364a6de674c37bb605ac2fce5a8cc0cd", + "url": "https://api.github.com/repos/cakephp/database/zipball/489591545fd223d6cdbf022049f7c73ede0cb4fa", + "reference": "489591545fd223d6cdbf022049f7c73ede0cb4fa", "shasum": "" }, "require": { @@ -244,20 +244,20 @@ "database abstraction", "pdo" ], - "time": "2020-02-04T11:23:19+00:00" + "time": "2020-04-13T01:41:15+00:00" }, { "name": "cakephp/datasource", - "version": "3.8.11", + "version": "3.8.12", "source": { "type": "git", "url": "https://github.com/cakephp/datasource.git", - "reference": "e2fff5bd4adb650d565c853fb25380657e2d1dbb" + "reference": "adc983f7c4d99c4361e3a8e4c0db7cdde26ee180" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/datasource/zipball/e2fff5bd4adb650d565c853fb25380657e2d1dbb", - "reference": "e2fff5bd4adb650d565c853fb25380657e2d1dbb", + "url": "https://api.github.com/repos/cakephp/datasource/zipball/adc983f7c4d99c4361e3a8e4c0db7cdde26ee180", + "reference": "adc983f7c4d99c4361e3a8e4c0db7cdde26ee180", "shasum": "" }, "require": { @@ -294,11 +294,11 @@ "entity", "query" ], - "time": "2019-11-20T00:00:46+00:00" + "time": "2020-04-14T14:22:40+00:00" }, { "name": "cakephp/log", - "version": "3.8.11", + "version": "3.8.12", "source": { "type": "git", "url": "https://github.com/cakephp/log.git", @@ -343,7 +343,7 @@ }, { "name": "cakephp/utility", - "version": "3.8.11", + "version": "3.8.12", "source": { "type": "git", "url": "https://github.com/cakephp/utility.git", @@ -1110,33 +1110,38 @@ }, { "name": "doctrine/inflector", - "version": "1.3.1", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1" + "reference": "4111f6853aea6f28b2b1dcfdde83d12dd3d5e6e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/ec3a55242203ffa6a4b27c58176da97ff0a7aec1", - "reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/4111f6853aea6f28b2b1dcfdde83d12dd3d5e6e3", + "reference": "4111f6853aea6f28b2b1dcfdde83d12dd3d5e6e3", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.2" }, "require-dev": { - "phpunit/phpunit": "^6.2" + "doctrine/coding-standard": "^7.0", + "phpstan/phpstan": "^0.11", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-strict-rules": "^0.11", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { "psr-4": { - "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" + "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector", + "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" } }, "notification-url": "https://packagist.org/downloads/", @@ -1165,15 +1170,35 @@ "email": "schmittjoh@gmail.com" } ], - "description": "Common String Manipulations with regard to casing and singular/plural rules.", - "homepage": "http://www.doctrine-project.org", + "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.", + "homepage": "https://www.doctrine-project.org/projects/inflector.html", "keywords": [ "inflection", - "pluralize", - "singularize", - "string" + "inflector", + "lowercase", + "manipulation", + "php", + "plural", + "singular", + "strings", + "uppercase", + "words" ], - "time": "2019-10-30T19:59:35+00:00" + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", + "type": "tidelift" + } + ], + "time": "2020-05-09T15:09:09+00:00" }, { "name": "doctrine/instantiator", @@ -1566,6 +1591,195 @@ ], "time": "2020-03-27T11:06:43+00:00" }, + { + "name": "guzzlehttp/guzzle", + "version": "6.5.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/aab4ebd862aa7d04f01a4b51849d657db56d882e", + "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.6.1", + "php": ">=5.5", + "symfony/polyfill-intl-idn": "^1.11" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "psr/log": "^1.1" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.5-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2020-04-18T10:38:46+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "ext-zlib": "*", + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2019-07-01T23:21:34+00:00" + }, { "name": "laminas/laminas-authentication", "version": "2.7.0", @@ -3229,16 +3443,16 @@ }, { "name": "laminas/laminas-servicemanager", - "version": "3.4.0", + "version": "3.4.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-servicemanager.git", - "reference": "044cb8e380682563fb277ed5f6de4f690e4e6239" + "reference": "0d4c8628a71fae9f7bd0b1b74b76382e5e9a04b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/044cb8e380682563fb277ed5f6de4f690e4e6239", - "reference": "044cb8e380682563fb277ed5f6de4f690e4e6239", + "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/0d4c8628a71fae9f7bd0b1b74b76382e5e9a04b1", + "reference": "0d4c8628a71fae9f7bd0b1b74b76382e5e9a04b1", "shasum": "" }, "require": { @@ -3253,7 +3467,7 @@ "psr/container-implementation": "^1.0" }, "replace": { - "zendframework/zend-servicemanager": "self.version" + "zendframework/zend-servicemanager": "^3.4.0" }, "require-dev": { "laminas/laminas-coding-standard": "~1.0.0", @@ -3297,7 +3511,13 @@ "service-manager", "servicemanager" ], - "time": "2019-12-31T17:44:47+00:00" + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2020-05-11T14:43:22+00:00" }, { "name": "laminas/laminas-stdlib", @@ -3682,16 +3902,16 @@ }, { "name": "monarc/core", - "version": "v2.9.18", + "version": "dev-feature/stats", "source": { "type": "git", "url": "https://github.com/monarc-project/zm-core.git", - "reference": "bcb0b2bea8c83c55284ab77571ff4692268582ae" + "reference": "c1ec0a0c3e7e271c5ceb4556d40b5a2c5bf146d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/monarc-project/zm-core/zipball/bcb0b2bea8c83c55284ab77571ff4692268582ae", - "reference": "bcb0b2bea8c83c55284ab77571ff4692268582ae", + "url": "https://api.github.com/repos/monarc-project/zm-core/zipball/c1ec0a0c3e7e271c5ceb4556d40b5a2c5bf146d9", + "reference": "c1ec0a0c3e7e271c5ceb4556d40b5a2c5bf146d9", "shasum": "" }, "require": { @@ -3766,7 +3986,7 @@ } ], "description": "Core for monarc/monarc application", - "time": "2020-04-24T08:06:23+00:00" + "time": "2020-05-14T21:38:39+00:00" }, { "name": "monarc/frontoffice", @@ -3774,12 +3994,12 @@ "source": { "type": "git", "url": "https://github.com/monarc-project/zm-client.git", - "reference": "182d2fcc163c89322709aa046297a99cf308750f" + "reference": "99122fee81b899c0a61b83967baf746e3abf483f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/monarc-project/zm-client/zipball/182d2fcc163c89322709aa046297a99cf308750f", - "reference": "182d2fcc163c89322709aa046297a99cf308750f", + "url": "https://api.github.com/repos/monarc-project/zm-client/zipball/99122fee81b899c0a61b83967baf746e3abf483f", + "reference": "99122fee81b899c0a61b83967baf746e3abf483f", "shasum": "" }, "require": { @@ -3787,6 +4007,7 @@ "ext-imagick": "*", "ext-intl": "*", "ext-json": "*", + "guzzlehttp/guzzle": "^6.5", "laminas/laminas-dependency-plugin": "^1.0", "laminas/laminas-di": "^3.1", "laminas/laminas-filter": "^2.9", @@ -3803,6 +4024,9 @@ "require-dev": { "roave/security-advisories": "dev-master" }, + "bin": [ + "bin/console" + ], "type": "library", "autoload": { "psr-4": { @@ -3849,7 +4073,7 @@ } ], "description": "Frontoffice for monarc/monarc application", - "time": "2020-04-22T08:57:02+00:00" + "time": "2020-05-14T21:38:13+00:00" }, { "name": "monarc/phpword", @@ -4261,6 +4485,56 @@ ], "time": "2017-02-14T16:28:37+00:00" }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, { "name": "psr/log", "version": "1.1.3", @@ -4356,6 +4630,46 @@ ], "time": "2017-10-23T01:57:42+00:00" }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "ramsey/collection", "version": "1.0.1", @@ -4552,16 +4866,16 @@ }, { "name": "robmorgan/phinx", - "version": "0.11.6", + "version": "0.11.7", "source": { "type": "git", "url": "https://github.com/cakephp/phinx.git", - "reference": "6bac1f51c8e35201ec281e842e6ae6dbe066212f" + "reference": "3cdde73e0c33c410e076108b3e1603fabb5b330d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/phinx/zipball/6bac1f51c8e35201ec281e842e6ae6dbe066212f", - "reference": "6bac1f51c8e35201ec281e842e6ae6dbe066212f", + "url": "https://api.github.com/repos/cakephp/phinx/zipball/3cdde73e0c33c410e076108b3e1603fabb5b330d", + "reference": "3cdde73e0c33c410e076108b3e1603fabb5b330d", "shasum": "" }, "require": { @@ -4569,14 +4883,14 @@ "cakephp/database": "^3.7", "php": ">=5.6", "symfony/config": "^3.4|^4.0|^5.0", - "symfony/console": "^3.4|^4.0|^5.0" + "symfony/console": "^3.4|^4.0|^5.0", + "symfony/yaml": "^3.4|^4.0|^5.0" }, "require-dev": { "cakephp/cakephp-codesniffer": "^3.0", "ext-json": "*", "phpunit/phpunit": ">=5.7,<8.0", - "sebastian/comparator": ">=1.2.3", - "symfony/yaml": "^3.4|^4.0|^5.0" + "sebastian/comparator": ">=1.2.3" }, "suggest": { "ext-json": "Install if using JSON configuration format", @@ -4628,20 +4942,20 @@ "migrations", "phinx" ], - "time": "2020-04-06T16:36:00+00:00" + "time": "2020-05-09T13:59:05+00:00" }, { "name": "symfony/config", - "version": "v5.0.7", + "version": "v5.0.8", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "3e633c31a34738f7f4ed7a225c43fc45ca74c986" + "reference": "db1674e1a261148429f123871f30d211992294e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/3e633c31a34738f7f4ed7a225c43fc45ca74c986", - "reference": "3e633c31a34738f7f4ed7a225c43fc45ca74c986", + "url": "https://api.github.com/repos/symfony/config/zipball/db1674e1a261148429f123871f30d211992294e7", + "reference": "db1674e1a261148429f123871f30d211992294e7", "shasum": "" }, "require": { @@ -4706,11 +5020,11 @@ "type": "tidelift" } ], - "time": "2020-03-27T16:56:45+00:00" + "time": "2020-04-15T15:59:10+00:00" }, { "name": "symfony/console", - "version": "v5.0.7", + "version": "v5.0.8", "source": { "type": "git", "url": "https://github.com/symfony/console.git", @@ -4800,16 +5114,16 @@ }, { "name": "symfony/filesystem", - "version": "v5.0.7", + "version": "v5.0.8", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "ca3b87dd09fff9b771731637f5379965fbfab420" + "reference": "7cd0dafc4353a0f62e307df90b48466379c8cc91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/ca3b87dd09fff9b771731637f5379965fbfab420", - "reference": "ca3b87dd09fff9b771731637f5379965fbfab420", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/7cd0dafc4353a0f62e307df90b48466379c8cc91", + "reference": "7cd0dafc4353a0f62e307df90b48466379c8cc91", "shasum": "" }, "require": { @@ -4860,20 +5174,20 @@ "type": "tidelift" } ], - "time": "2020-03-27T16:56:45+00:00" + "time": "2020-04-12T14:40:17+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.15.0", + "version": "v1.17.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14" + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/4719fa9c18b0464d399f1a63bf624b42b6fa8d14", - "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", "shasum": "" }, "require": { @@ -4885,7 +5199,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.17-dev" } }, "autoload": { @@ -4932,20 +5246,96 @@ "type": "tidelift" } ], - "time": "2020-02-27T09:26:54+00:00" + "time": "2020-05-12T16:14:59+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.15.0", + "name": "symfony/polyfill-intl-idn", + "version": "v1.17.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac" + "url": "https://github.com/symfony/polyfill-intl-idn.git", + "reference": "3bff59ea7047e925be6b7f2059d60af31bb46d6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac", - "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/3bff59ea7047e925be6b7f2059d60af31bb46d6a", + "reference": "3bff59ea7047e925be6b7f2059d60af31bb46d6a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-php72": "^1.10" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Idn\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Laurent Bassin", + "email": "laurent@bassin.info" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "idn", + "intl", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-12T16:47:27+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.17.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "fa79b11539418b02fc5e1897267673ba2c19419c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fa79b11539418b02fc5e1897267673ba2c19419c", + "reference": "fa79b11539418b02fc5e1897267673ba2c19419c", "shasum": "" }, "require": { @@ -4957,7 +5347,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.17-dev" } }, "autoload": { @@ -5005,20 +5395,20 @@ "type": "tidelift" } ], - "time": "2020-03-09T19:04:49+00:00" + "time": "2020-05-12T16:47:27+00:00" }, { - "name": "symfony/polyfill-php73", - "version": "v1.15.0", + "name": "symfony/polyfill-php72", + "version": "v1.17.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7" + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "f048e612a3905f34931127360bdd2def19a5e582" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", - "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/f048e612a3905f34931127360bdd2def19a5e582", + "reference": "f048e612a3905f34931127360bdd2def19a5e582", "shasum": "" }, "require": { @@ -5027,7 +5417,76 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.17-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-12T16:47:27+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.17.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "a760d8964ff79ab9bf057613a5808284ec852ccc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/a760d8964ff79ab9bf057613a5808284ec852ccc", + "reference": "a760d8964ff79ab9bf057613a5808284ec852ccc", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" } }, "autoload": { @@ -5077,7 +5536,7 @@ "type": "tidelift" } ], - "time": "2020-02-27T09:26:54+00:00" + "time": "2020-05-12T16:47:27+00:00" }, { "name": "symfony/service-contracts", @@ -5137,6 +5596,79 @@ ], "time": "2019-11-18T17:27:11+00:00" }, + { + "name": "symfony/yaml", + "version": "v5.0.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "482fb4e710e5af3e0e78015f19aa716ad953392f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/482fb4e710e5af3e0e78015f19aa716ad953392f", + "reference": "482fb4e710e5af3e0e78015f19aa716ad953392f", + "shasum": "" + }, + "require": { + "php": "^7.2.5", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<4.4" + }, + "require-dev": { + "symfony/console": "^4.4|^5.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-04-28T17:58:55+00:00" + }, { "name": "true/punycode", "version": "v2.1.1", @@ -5459,24 +5991,21 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", "shasum": "" }, "require": { "php": ">=7.1" }, - "require-dev": { - "phpunit/phpunit": "~6" - }, "type": "library", "extra": { "branch-alias": { @@ -5507,7 +6036,7 @@ "reflection", "static analysis" ], - "time": "2018-08-07T13:53:10+00:00" + "time": "2020-04-27T09:25:28+00:00" }, { "name": "phpdocumentor/reflection-docblock", @@ -6022,12 +6551,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "81541a731da2f245a08666de73169cb5da7ac573" + "reference": "9b0501ceb2d00bea5814316c5333d513d7622ed5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/81541a731da2f245a08666de73169cb5da7ac573", - "reference": "81541a731da2f245a08666de73169cb5da7ac573", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/9b0501ceb2d00bea5814316c5333d513d7622ed5", + "reference": "9b0501ceb2d00bea5814316c5333d513d7622ed5", "shasum": "" }, "conflict": { @@ -6040,6 +6569,7 @@ "asymmetricrypt/asymmetricrypt": ">=0,<9.9.99", "aws/aws-sdk-php": ">=3,<3.2.1", "bagisto/bagisto": "<0.1.5", + "barrelstrength/sprout-base-email": "<3.9", "bolt/bolt": "<3.6.10", "brightlocal/phpwhois": "<=4.2.5", "buddypress/buddypress": "<5.1.2", @@ -6117,6 +6647,7 @@ "magento/product-community-edition": ">=2,<2.2.10|>=2.3,<2.3.2-p.2", "monolog/monolog": ">=1.8,<1.12", "namshi/jose": "<2.2", + "nzo/url-encryptor-bundle": ">=4,<4.3.2|>=5,<5.0.1", "onelogin/php-saml": "<2.10.4", "oneup/uploader-bundle": "<1.9.3|>=2,<2.1.5", "openid/php-openid": "<2.3", @@ -6171,7 +6702,7 @@ "socalnick/scn-social-auth": "<1.15.2", "spoonity/tcpdf": "<6.2.22", "squizlabs/php_codesniffer": ">=1,<2.8.1|>=3,<3.0.1", - "ssddanbrown/bookstack": "<0.25.3", + "ssddanbrown/bookstack": "<0.29.2", "stormpath/sdk": ">=0,<9.9.99", "studio-42/elfinder": "<2.1.49", "swiftmailer/swiftmailer": ">=4,<5.4.5", @@ -6209,6 +6740,7 @@ "symfony/var-exporter": ">=4.2,<4.2.12|>=4.3,<4.3.8", "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7", + "t3g/svg-sanitizer": "<1.0.3", "tecnickcom/tcpdf": "<6.2.22", "thelia/backoffice-default-template": ">=2.1,<2.1.2", "thelia/thelia": ">=2.1-beta.1,<2.1.3", @@ -6216,8 +6748,8 @@ "titon/framework": ">=0,<9.9.99", "truckersmp/phpwhois": "<=4.3.1", "twig/twig": "<1.38|>=2,<2.7", - "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.32|>=8,<8.7.30|>=9,<9.5.12|>=10,<10.2.1", - "typo3/cms-core": ">=8,<8.7.30|>=9,<9.5.12|>=10,<10.2.1", + "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.32|>=8,<8.7.30|>=9,<9.5.17|>=10,<10.4.2", + "typo3/cms-core": ">=8,<8.7.30|>=9,<9.5.17|>=10,<10.4.2", "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5", "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4", "typo3/phar-stream-wrapper": ">=1,<2.1.1|>=3,<3.1.1", @@ -6290,7 +6822,7 @@ "type": "tidelift" } ], - "time": "2020-04-23T00:01:30+00:00" + "time": "2020-05-14T00:01:29+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -6996,10 +7528,18 @@ "time": "2020-04-18T12:12:48+00:00" } ], - "aliases": [], + "aliases": [ + { + "alias": "2.9.18", + "alias_normalized": "2.9.18.0", + "version": "dev-feature/stats", + "package": "monarc/core" + } + ], "minimum-stability": "dev", "stability-flags": { "monarc/frontoffice": 20, + "monarc/core": 20, "roave/security-advisories": 20 }, "prefer-stable": true, diff --git a/tests/Functional/Controller/ApiAdminUsersControllerTest.php b/tests/Functional/Controller/ApiAdminUsersControllerTest.php index eb270d4..18c31a5 100644 --- a/tests/Functional/Controller/ApiAdminUsersControllerTest.php +++ b/tests/Functional/Controller/ApiAdminUsersControllerTest.php @@ -20,7 +20,7 @@ class ApiAdminUsersControllerTest extends AbstractFunctionalTestCase /** @var ConnectedUserService */ private $connectedUserService; - /** @var AuthenticationService|MockObject */ + /** @var AuthenticationService */ private $authenticationService; protected function configureServiceManager(ServiceManager $serviceManager) diff --git a/tests/Integration/AbstractIntegrationTestCase.php b/tests/Integration/AbstractIntegrationTestCase.php new file mode 100644 index 0000000..08f17de --- /dev/null +++ b/tests/Integration/AbstractIntegrationTestCase.php @@ -0,0 +1,38 @@ +setApplicationConfig(require dirname(__DIR__) . '/../config/application.config.php'); + + parent::setUp(); + + $this->configureServiceManager($this->getApplicationServiceLocator()); + } + + protected function tearDown(): void + { + // TODO: clear the db data. + } + + public static function setUpBeforeClass(): void + { + // Creates the DB with initial data, executes all the migrations. + shell_exec(getenv('TESTS_DIR') . '/scripts/setup_db.sh'); + } + + public static function tearDownAfterClass(): void + { + // TODO: drop the database or clear the phinxlog table and all the data. + } + + protected function configureServiceManager(ServiceManager $serviceManager) + { + } +} diff --git a/tests/Integration/Service/StatsApiServiceTest.php b/tests/Integration/Service/StatsApiServiceTest.php new file mode 100644 index 0000000..5890654 --- /dev/null +++ b/tests/Integration/Service/StatsApiServiceTest.php @@ -0,0 +1,83 @@ +setAllowOverride(true); + + $this->mockHandler = new MockHandler(); + $statsApiProvider = new StatsApiProvider( + $serviceManager->get(SettingTable::class), + [], + $this->mockHandler + ); + $serviceManager->setService(StatsApiProvider::class, $statsApiProvider); + + $serviceManager->setAllowOverride(false); + } + + public function testItThrowsTheErrorWhenTheTheStatsAlreadyGeneratedForToday() + { + $this->expectException(StatsAlreadyCollectedException::class); + $this->expectExceptionMessage('The stats is already collected for today.'); + + $this->mockHandler->append(new Response(200, [], $this->getStatsResponse([['type' => 'risks']]))); + + /** @var StatsAnrService $statsAnrService */ + $statsAnrService = $this->getApplicationServiceLocator()->get(StatsAnrService::class); + $statsAnrService->collectStats(); + } + + public function testItDoesNotSendTheStatsWhenTheDataIsEmpty() + { + $this->mockHandler->append(new Response(200, [], $this->getStatsResponse())); + + /** @var StatsAnrService $statsAnrService */ + $statsAnrService = $this->getApplicationServiceLocator()->get(StatsAnrService::class); + $statsAnrService->collectStats(); + + $this->assertEquals('GET', $this->mockHandler->getLastRequest()->getMethod()); + } + + public function testItCanGenerateTheStatsWhenItIsNotDoneForToday() + { + $this->mockHandler->append(new Response(200, [], $this->getStatsResponse())); + $this->mockHandler->append(new Response(200, [], '{"status": "ok"}')); + + // TODO: import MyPrint to test if the exact Json is generated and compare with the last request history. + /** @var StatsAnrService $statsAnrService */ + $statsAnrService = $this->getApplicationServiceLocator()->get(StatsAnrService::class); + $statsAnrService->collectStats(); + } + + private function getStatsResponse(array $results = []): string + { + return json_encode([ + 'metadata' => [ + 'resultset' => [ + 'count' => \count($results), + 'offset' => 0, + 'limit' => 0, + ], + ], + 'results' => $results, + ]); + } +} diff --git a/tests/config/local.php b/tests/config/local.php index 4ef5ba6..79266a8 100644 --- a/tests/config/local.php +++ b/tests/config/local.php @@ -1,29 +1,35 @@ [ 'connection' => [ 'orm_default' => [ - 'params' => array( - 'host' => 'localhost', + 'params' => [ + 'host' => '127.0.0.1', 'user' => 'sqlmonarcuser', 'password' => 'sqlmonarcuser', 'dbname' => 'monarc_common_test', 'port' => 3306, - ), + // To execute tests from your host machine uncomment these lines: + 'options' => [ + PDO::MYSQL_ATTR_SSL_KEY => '~/web/monarc/MonarcAppFO/vagrant/.vagrant/machines/default/virtualbox/private_key' + ] + ], ], 'orm_cli' => [ - 'params' => array( - 'host' => 'localhost', + 'params' => [ + 'host' => '127.0.0.1', 'user' => 'sqlmonarcuser', 'password' => 'sqlmonarcuser', 'dbname' => 'monarc_cli_test', 'port' => 3306, - ), + // To execute tests from your host machine uncomment these lines: + 'options' => [ + PDO::MYSQL_ATTR_SSL_KEY => '~/web/monarc/MonarcAppFO/vagrant/.vagrant/machines/default/virtualbox/private_key' + ] + ], ], ], 'entitymanager' => [ diff --git a/tests/scripts/setup_db.sh b/tests/scripts/setup_db.sh index 2a3db96..8f5d431 100644 --- a/tests/scripts/setup_db.sh +++ b/tests/scripts/setup_db.sh @@ -1,15 +1,18 @@ #!/bin/bash -DBUSER_MONARC='sqlmonarcuser' +DBHOST="127.0.0.1" +DBUSER_MONARC="sqlmonarcuser" DBPASSWORD_MONARC="sqlmonarcuser" +# Comment/Uncomment and modify the following line to run tests from your host machine: +CONNECTION_OPTIONS="--ssl-key=~/web/monarc/MonarcAppFO/vagrant/.vagrant/machines/default/virtualbox/private_key" -mysql -u $DBUSER_MONARC -p$DBPASSWORD_MONARC -e "CREATE DATABASE IF NOT EXISTS monarc_cli_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" > /dev/null +mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS -e "CREATE DATABASE IF NOT EXISTS monarc_cli_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" > /dev/null # Check if the database is already exist we don't need to create the structure and import the data. -if ! mysql -u $DBUSER_MONARC -p$DBPASSWORD_MONARC -e 'use monarc_common_test'; then - mysql -u $DBUSER_MONARC -p$DBPASSWORD_MONARC -e "CREATE DATABASE monarc_common_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" > /dev/null - mysql -u $DBUSER_MONARC -p$DBPASSWORD_MONARC monarc_common_test < db-bootstrap/monarc_structure.sql > /dev/null - mysql -u $DBUSER_MONARC -p$DBPASSWORD_MONARC monarc_common_test < db-bootstrap/monarc_data.sql > /dev/null +if ! mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS -e 'use monarc_common_test'; then + mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS -e "CREATE DATABASE monarc_common_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" > /dev/null + mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS monarc_common_test < db-bootstrap/monarc_structure.sql > /dev/null + mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS monarc_common_test < db-bootstrap/monarc_data.sql > /dev/null fi php bin/phinx migrate -c tests/migrations/phinx_core.php