From e9345a2bce3b03849085b95a15c00fef14133b7a Mon Sep 17 00:00:00 2001 From: Gaurav Mishra Date: Thu, 7 Jun 2018 17:50:34 +0530 Subject: [PATCH 1/2] feat(fossology): Support for Bionic Beaver fix(debian/control): Change dependency from heirloom-mailx heirloom-mailx | s-nail fix(DMalloc.c): Initialize i fix(license.c): Change sprintf to handle longer strings without unexpected results. fix(nomos_utils.c): Change NULL_CHAR to NULL to compare fix(util.c): Change sprintf to handle longer strings withour unexpected results. fix(database.c): Initialize variables feat(Makefile): Add flag for RPM 4.14 feat(pkgagent.c): Changes according to RPM 4.14 feat(fo-installdeps): Added support for Ubuntu Bionic Beaver feat(fo-installdeps): Drop support for Lenny, Hardy, Squeeze, Lucid, Natty, Isadora, Precise, Oneiric, Quantal, Raring, Saucy, Yakkety As they are no longer supported by their producer/developer. Signed-off-by: Gaurav Mishra --- debian/control | 2 +- src/nomos/agent/DMalloc.c | 2 +- src/nomos/agent/licenses.c | 6 ++++-- src/nomos/agent/nomos_utils.c | 2 +- src/nomos/agent/util.c | 3 ++- src/scheduler/agent/database.c | 4 ++-- utils/fo-installdeps | 14 +++++++++----- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/debian/control b/debian/control index d7cd676540..d7fc42f82d 100644 --- a/debian/control +++ b/debian/control @@ -62,7 +62,7 @@ Description: architecture for analyzing software, web interface Package: fossology-scheduler Architecture: any -Depends: fossology-common, ${shlibs:Depends}, ${misc:Depends}, heirloom-mailx +Depends: fossology-common, ${shlibs:Depends}, ${misc:Depends}, heirloom-mailx | s-nail Conflicts: fossology-scheduler-single Description: architecture for analyzing software, scheduler The FOSSology project is a web based framework that allows you to diff --git a/src/nomos/agent/DMalloc.c b/src/nomos/agent/DMalloc.c index 058bd99292..63dc98ea50 100644 --- a/src/nomos/agent/DMalloc.c +++ b/src/nomos/agent/DMalloc.c @@ -309,7 +309,7 @@ DMnotfreed() */ DMtrigger() { - int i; + int i = 0; i++; } diff --git a/src/nomos/agent/licenses.c b/src/nomos/agent/licenses.c index 6170f8f012..caa3562672 100644 --- a/src/nomos/agent/licenses.c +++ b/src/nomos/agent/licenses.c @@ -568,13 +568,15 @@ char* createRelativePath(item_t *p, scanres_t *scp) char* cp; if (*(p->str) == '/') { - (void) strcpy(scp->fullpath, p->str); + strcpy(scp->fullpath, p->str); scp->nameOffset = (size_t) (cur.targetLen + 1); cp = scp->fullpath; /* full pathname */ } else { - (void) sprintf(scp->fullpath, "%s/%s", cur.cwd, p->str); + strncpy(scp->fullpath, cur.cwd, sizeof(scp->fullpath)-1); + strncat(scp->fullpath, "/", sizeof(scp->fullpath)-1); + strncat(scp->fullpath, p->str, sizeof(scp->fullpath)-1); scp->nameOffset = (size_t) (cur.cwdLen + 1); cp = p->str; /* relative path == faster open() */ } diff --git a/src/nomos/agent/nomos_utils.c b/src/nomos/agent/nomos_utils.c index 548e10a3e3..1decc6cd3f 100644 --- a/src/nomos/agent/nomos_utils.c +++ b/src/nomos/agent/nomos_utils.c @@ -483,7 +483,7 @@ FUNCTION void parseLicenseList() } /* check for a single name FIX THIS!*/ - if (strstr(cur.compLic, ",") == NULL_CHAR) + if (strstr(cur.compLic, ",") == NULL) { cur.licenseList[0] = cur.compLic; cur.licenseList[1] = NULL; diff --git a/src/nomos/agent/util.c b/src/nomos/agent/util.c index 64bfa36a8c..7f18ce7050 100644 --- a/src/nomos/agent/util.c +++ b/src/nomos/agent/util.c @@ -908,7 +908,8 @@ void printRegexMatch(int n, int cached) #endif /* PROC_TRACE */ if (*debugStr == NULL_CHAR) { - (void) sprintf(debugStr, "%s/Nomos.strings.txt", gl.initwd); + strncpy(debugStr, gl.initwd, sizeof(debugStr)-1); + strncat(debugStr, "/Nomos.strings.txt", sizeof(debugStr)-1); #ifdef DEBUG printf("File: %s\n", debugStr); #endif /* DEBUG */ diff --git a/src/scheduler/agent/database.c b/src/scheduler/agent/database.c index 921c335eb9..3e506927e7 100644 --- a/src/scheduler/agent/database.c +++ b/src/scheduler/agent/database.c @@ -542,8 +542,8 @@ static void email_notification(scheduler_t* scheduler, job_t* job) void email_init(scheduler_t* scheduler) { int email_notify, fd; - struct stat header_sb; - struct stat footer_sb; + struct stat header_sb = {}; + struct stat footer_sb = {}; gchar* fname; GError* error = NULL; diff --git a/utils/fo-installdeps b/utils/fo-installdeps index a2973582c4..47399c2476 100755 --- a/utils/fo-installdeps +++ b/utils/fo-installdeps @@ -113,6 +113,8 @@ if [[ $BUILDTIME ]]; then apt-get $YesOpt install postgresql-server-dev-9.5;; stretch|buster|sid) apt-get $YesOpt install postgresql-server-dev-9.6;; + bionic) + apt-get "$YesOpt" install postgresql-server-dev-10;; *) echo "ERROR: Unknown or Unsupported $DISTRO $CODENAME release, please report to the mailing list"; exit 1;; esac fi @@ -154,16 +156,18 @@ if [[ $RUNTIME ]]; then poppler-utils upx-ucl \ unrar-free unzip p7zip-full p7zip wget \ subversion git \ - dpkg-dev heirloom-mailx + dpkg-dev case "$CODENAME" in trusty) - apt-get $YesOpt install postgresql-9.3 libapache2-mod-php5 php5 php5-pgsql php5-cli php5-curl;; + apt-get $YesOpt install postgresql-9.3 libapache2-mod-php5 php5 php5-pgsql php5-cli php5-curl heirloom-mailx;; jessie) - apt-get $YesOpt install postgresql-9.4 libapache2-mod-php5 php5 php5-pgsql php5-cli php5-curl;; + apt-get $YesOpt install postgresql-9.4 libapache2-mod-php5 php5 php5-pgsql php5-cli php5-curl heirloom-mailx;; xenial) - apt-get $YesOpt install postgresql-9.5 php7.0 libapache2-mod-php7.0 php7.0-pgsql php7.0-cli php7.0-curl php7.0-mbstring php7.0-zip;; + apt-get $YesOpt install postgresql-9.5 php7.0 libapache2-mod-php7.0 php7.0-pgsql php7.0-cli php7.0-curl php7.0-mbstring php7.0-zip s-nail;; stretch|buster|sid) - apt-get $YesOpt install postgresql-9.6 php7.0 php7.0-pgsql php7.0-cli php7.0-curl php7.0-xml php7.0-zip;; + apt-get $YesOpt install postgresql-9.6 php7.0 php7.0-pgsql php7.0-cli php7.0-curl php7.0-xml php7.0-zip s-nail;; + bionic) + apt-get "$YesOpt" install postgresql-10 php7.2 php7.2-pgsql php7.2-cli php7.2-curl php7.2-xml php7.2-zip s-nail;; *) echo "ERROR: Unknown or Unsupported $DISTRO $CODENAME release, please report to the mailing list"; exit 1;; esac ;; From d277eb7b35f81b6cf5712267525db938ca5e25cd Mon Sep 17 00:00:00 2001 From: Gaurav Mishra Date: Tue, 10 Jul 2018 20:26:32 +0530 Subject: [PATCH 2/2] fix(deps): Add Boost runtime dependencies fix(php-conf-fix): Use regex/awk to find php.ini path. feat(.travis.yml): Added tests for PHP 7.2 as allow failure. See #1175 for more. Signed-off-by: Gaurav Mishra --- .travis.yml | 6 +- install/scripts/php-conf-fix.sh | 11 +- src/composer.json | 82 +++-- src/composer.lock | 322 ++++++++++-------- .../agent_tests/Functional/schedulerTest.php | 2 +- .../agent_tests/Unit/DeciderAgentTest.php | 1 - src/lib/c/tests/testClib.php | 2 +- .../Application/test/LicenseCsvExportTest.php | 32 +- .../Application/test/LicenseCsvImportTest.php | 47 ++- src/lib/php/Application/test/UserInfoTest.php | 1 - .../test/AgentLicenseEventProcessorTest.php | 12 +- .../test/ClearingDecisionProcessorTest.php | 20 +- .../test/ClearingEventProcessorTest.php | 5 +- .../php/BusinessRules/test/LicenseMapTest.php | 22 +- src/lib/php/Dao/test/AgentDaoTest.php | 6 +- src/lib/php/Dao/test/ClearingDaoTest.php | 42 +-- src/lib/php/Dao/test/CopyrightDaoTest.php | 20 +- src/lib/php/Dao/test/FolderDaoTest.php | 20 +- src/lib/php/Dao/test/LicenseDaoTest.php | 1 - src/lib/php/Dao/test/ShowJobsDaoTest.php | 32 +- src/lib/php/Dao/test/TreeDaoTest.php | 10 +- src/lib/php/Dao/test/UploadDaoTest.php | 28 +- .../php/Dao/test/UploadPermissionDaoTest.php | 30 +- src/lib/php/Dao/test/UserDaoTest.php | 24 +- .../Data/Clearing/test/ClearingResultTest.php | 16 +- src/lib/php/Data/Folder/test/FolderTest.php | 1 - src/lib/php/Data/Package/test/PackageTest.php | 1 - src/lib/php/Data/Upload/test/UploadTest.php | 3 +- .../Data/test/ClearingDecisionBuilderTest.php | 8 +- src/lib/php/Data/test/LicenseMatchTest.php | 4 +- src/lib/php/Data/test/LicenseTest.php | 1 - src/lib/php/Data/test/TextFragmentTest.php | 1 - src/lib/php/Db/test/DbManagerTest.php | 26 +- src/lib/php/Db/test/ModernDbManagerTest.php | 10 +- src/lib/php/Html/test/LinkElementTest.php | 1 - src/lib/php/Html/test/SimpleElementTest.php | 1 - src/lib/php/Plugin/test/DefaultPluginTest.php | 8 +- src/lib/php/Proxy/test/DbViewProxyTest.php | 12 +- .../php/Proxy/test/LatestScannerProxyTest.php | 27 +- .../php/Proxy/test/LicenseViewProxyTest.php | 20 +- src/lib/php/Proxy/test/ScanJobProxyTest.php | 51 ++- .../php/Proxy/test/UploadBrowseProxyTest.php | 56 +-- .../php/Proxy/test/UploadTreeProxyTest.php | 110 +++--- .../Report/tests/ClearedGetterCommonTest.php | 2 +- src/lib/php/Test/test/ReflectoryTest.php | 8 +- src/lib/php/Test/test/TestLiteDbTest.php | 10 +- src/lib/php/Test/test/TestPgDbTest.php | 12 +- .../php/Text/tests/EncodingConverterTest.php | 1 - src/lib/php/UI/test/FolderNavTest.php | 6 +- src/lib/php/Util/TimingLogger.php | 6 +- src/lib/php/Util/test/ArrayOperationTest.php | 7 +- src/lib/php/Util/test/StringOperationTest.php | 5 +- src/lib/php/Util/test/TimingLoggerTest.php | 4 +- .../php/View/test/HighlightProcessorTest.php | 2 +- src/lib/php/View/test/HighlightStateTest.php | 1 - src/lib/php/View/test/TextRendererTest.php | 4 +- src/lib/php/tests/test_common_active.php | 2 +- src/lib/php/tests/test_common_cache.php | 6 +- src/lib/php/tests/test_common_cli.php | 6 +- src/lib/php/tests/test_common_dir.php | 6 +- .../php/tests/test_common_license_file.php | 26 +- src/lib/php/tests/test_common_menu.php | 4 +- src/lib/php/tests/test_common_pkg.php | 6 +- src/lib/php/tests/test_common_sysconfig.php | 7 +- src/monk/agent_tests/Functional/bulkTest.php | 1 - src/monk/agent_tests/Functional/cliTest.php | 1 - .../agent_tests/Functional/schedulerTest.php | 1 - src/phpunit.xml | 6 +- src/pkgagent/agent/pkgagent.c | 4 +- src/www/ui_tests/Unit/ui-picker-Test.php | 1 - utils/fo-installdeps | 2 +- 71 files changed, 662 insertions(+), 620 deletions(-) diff --git a/.travis.yml b/.travis.yml index 16f19c861e..3cacd4dbba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ php: - 7.0 - 5.6 - 7.1 + - 7.2 addons: apt: packages: &default_packages @@ -64,6 +65,7 @@ script: - if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then composer require --no-update phpunit/phpunit ^5; fi - if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.0" ]]; then composer require --dev --no-update phpunit/phpunit ^6; fi - if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.1" ]]; then composer require --dev --no-update phpunit/phpunit ^7; fi + - if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2" ]]; then composer require --dev --no-update phpunit/phpunit ^7; fi - if [[ ! -z "${CHECKBEFORE}" ]]; then ${CHECKBEFORE}; fi - if [[ ! -z "${MAKETARGETS}" ]]; then make ${MAKETARGETS}; fi - if [[ ! -z "${PHPTESTSUITE}" ]]; then src/vendor/bin/phpunit -csrc/phpunit.xml --testsuite="${PHPTESTSUITE}"; fi @@ -121,7 +123,9 @@ matrix: - *default_packages - clang-3.6 ## PHP: phpcpd ## - - script: src/vendor/bin/phpcpd src/cli/ src/copyright/ src/decider*/ src/lib/ src/monk/ src/nomos/ src/readmeoss/ src/spdx2/ src/www/ + - name: PHP-CPD + script: src/vendor/bin/phpcpd src/cli/ src/copyright/ src/decider*/ src/lib/ src/monk/ src/nomos/ src/readmeoss/ src/spdx2/ src/www/ allow_failures: - script: src/vendor/bin/phpcpd src/cli/ src/copyright/ src/decider*/ src/lib/ src/monk/ src/nomos/ src/readmeoss/ src/spdx2/ src/www/ - php: 7.1 + - php: 7.2 diff --git a/install/scripts/php-conf-fix.sh b/install/scripts/php-conf-fix.sh index 19e9a38be8..488eea59d3 100755 --- a/install/scripts/php-conf-fix.sh +++ b/install/scripts/php-conf-fix.sh @@ -4,22 +4,15 @@ # # uses phpIni to store file path - change if required # -PHP5_PATH=/etc/php5/apache2/php.ini -PHP7_PATH=/etc/php/7.0/apache2/php.ini -phpIni="" +PHP_PATH=$(php --ini | awk '/\/etc\/php.*\/cli$/{print $5}') +phpIni="${PHP_PATH}/../apache2/php.ini" echo 'Automated php.ini configuration adjustments' echo if [ -f /etc/redhat-release ]; then phpIni=/etc/php.ini TIMEZONE=`readlink -f /etc/localtime | sed 's%/usr/share/zoneinfo/%%'` -elif [ -f ${PHP5_PATH} ]; then - phpIni=${PHP5_PATH} - TIMEZONE=`cat /etc/timezone` -elif [ -f ${PHP7_PATH} ]; then - phpIni=${PHP7_PATH} else - phpIni=/etc/php5/apache2/php.ini TIMEZONE=`cat /etc/timezone` fi diff --git a/src/composer.json b/src/composer.json index db61f0685e..b1b0bfa615 100644 --- a/src/composer.json +++ b/src/composer.json @@ -1,7 +1,7 @@ { - "name": "fossology/fossology", - "description": "FOSSology is a open source license compliance software system and toolkit.", - "_readme": [ + "name" : "fossology/fossology", + "description" : "FOSSology is a open source license compliance software system and toolkit.", + "_readme" : [ "Copyright Siemens AG 2014-2016", "", "Copying and distribution of this file, with or without modification,", @@ -9,40 +9,54 @@ "notice and this notice are preserved. This file is offered as-is,", "without any warranty." ], - "require": { - "monolog/monolog": "1.10.*", - "symfony/config": "2.6.*", - "symfony/http-foundation": "2.6.*", - "symfony/dependency-injection": "2.6.*", - "twig/twig": "1.*", - "twig/extensions": "1.*", - "easyrdf/easyrdf": "0.9.*", - "phpoffice/phpword": "v0.13.*" + "require" : { + "monolog/monolog" : "1.10.*", + "symfony/config" : "2.6.*", + "symfony/http-foundation" : "2.6.*", + "symfony/dependency-injection" : "2.6.*", + "twig/twig" : "1.*", + "twig/extensions" : "1.*", + "easyrdf/easyrdf" : "0.9.*", + "phpoffice/phpword" : "v0.13.*" }, - - "require-dev": { - "mockery/mockery": ">=0.9.1", - "hamcrest/hamcrest-php": "1.1.*", - "squizlabs/php_codesniffer": "1.*", - "sebastian/phpcpd": "2.*", - "satooshi/php-coveralls": "1.0.*", - "phpunit/phpunit": "~5" + "require-dev" : { + "mockery/mockery" : ">=0.9.1", + "hamcrest/hamcrest-php" : "1.1.*", + "squizlabs/php_codesniffer" : "1.*", + "sebastian/phpcpd" : "2.*", + "php-coveralls/php-coveralls" : "1.0.*", + "phpunit/phpunit" : "~5" }, - - "autoload": { - "psr-4": { - "Fossology\\Lib\\": "lib/php", - "Fossology\\Agent\\Copyright\\UI\\": "copyright/ui", - "Fossology\\DeciderJob\\UI\\": "deciderjob/ui", - "Fossology\\Decider\\UI\\": "decider/ui", - "Fossology\\DelAgent\\UI\\": "delagent/ui", - "Fossology\\UI\\Page\\": "www/ui/page" + "autoload" : { + "psr-4" : { + "Fossology\\Lib\\" : "lib/php", + "Fossology\\Agent\\Copyright\\UI\\" : "copyright/ui", + "Fossology\\DeciderJob\\UI\\" : "deciderjob/ui", + "Fossology\\Decider\\UI\\" : "decider/ui", + "Fossology\\DelAgent\\UI\\" : "delagent/ui", + "Fossology\\UI\\Page\\" : "www/ui/page" } }, - - "config": { - "platform": { - "php": "5.6" + "config" : { + "platform" : { + "php" : "5.6" } - } + }, + "homepage" : "https://www.fossology.org/", + "license" : [ + "GPL-2.0-only", + "LGPL-2.1-only" + ], + "support" : { + "email" : "fossology@fossology.org", + "issues" : "https://github.com/fossology/fossology/issues", + "wiki" : "https://github.com/fossology/fossology/wiki", + "source" : "https://github.com/fossology/fossology/" + }, + "keywords" : [ + "fossology", + "spdx", + "license-management", + "license" + ] } diff --git a/src/composer.lock b/src/composer.lock index 6696be2212..63880f434b 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "3173602c86d5749ee2431ca1b3c191bf", + "content-hash": "0bd24570b6c36a98262f8fdd79ffa344", "packages": [ { "name": "easyrdf/easyrdf", @@ -489,20 +489,21 @@ }, { "name": "symfony/filesystem", - "version": "v2.8.31", + "version": "v2.8.42", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "10507c5f24577b0ad971b0d22097c823b2b45dd3" + "reference": "0f685c099aca7ba86bcc31850186dbfe84a4a8a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/10507c5f24577b0ad971b0d22097c823b2b45dd3", - "reference": "10507c5f24577b0ad971b0d22097c823b2b45dd3", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/0f685c099aca7ba86bcc31850186dbfe84a4a8a1", + "reference": "0f685c099aca7ba86bcc31850186dbfe84a4a8a1", "shasum": "" }, "require": { - "php": ">=5.3.9" + "php": ">=5.3.9", + "symfony/polyfill-ctype": "~1.8" }, "type": "library", "extra": { @@ -534,7 +535,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2017-11-07T14:08:47+00:00" + "time": "2018-06-21T09:24:14+00:00" }, { "name": "symfony/http-foundation", @@ -590,6 +591,61 @@ "homepage": "https://symfony.com", "time": "2015-07-22T10:08:40+00:00" }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.8.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-04-30T19:57:29+00:00" + }, { "name": "twig/extensions", "version": "v1.5.1", @@ -648,16 +704,16 @@ }, { "name": "twig/twig", - "version": "v1.35.0", + "version": "v1.35.3", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "daa657073e55b0a78cce8fdd22682fddecc6385f" + "reference": "b48680b6eb7d16b5025b9bfc4108d86f6b8af86f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/daa657073e55b0a78cce8fdd22682fddecc6385f", - "reference": "daa657073e55b0a78cce8fdd22682fddecc6385f", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/b48680b6eb7d16b5025b9bfc4108d86f6b8af86f", + "reference": "b48680b6eb7d16b5025b9bfc4108d86f6b8af86f", "shasum": "" }, "require": { @@ -665,8 +721,8 @@ }, "require-dev": { "psr/container": "^1.0", - "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~3.3@dev" + "symfony/debug": "^2.7", + "symfony/phpunit-bridge": "^3.3" }, "type": "library", "extra": { @@ -709,7 +765,7 @@ "keywords": [ "templating" ], - "time": "2017-09-27T18:06:46+00:00" + "time": "2018-03-20T04:25:58+00:00" }, { "name": "zendframework/zend-escaper", @@ -1181,6 +1237,67 @@ ], "time": "2017-10-19T19:58:43+00:00" }, + { + "name": "php-coveralls/php-coveralls", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-coveralls/php-coveralls.git", + "reference": "9c07b63acbc9709344948b6fd4f63a32b2ef4127" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/9c07b63acbc9709344948b6fd4f63a32b2ef4127", + "reference": "9c07b63acbc9709344948b6fd4f63a32b2ef4127", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-simplexml": "*", + "guzzle/guzzle": "^2.8 || ^3.0", + "php": "^5.3.3 || ^7.0", + "psr/log": "^1.0", + "symfony/config": "^2.1 || ^3.0 || ^4.0", + "symfony/console": "^2.1 || ^3.0 || ^4.0", + "symfony/stopwatch": "^2.0 || ^3.0 || ^4.0", + "symfony/yaml": "^2.0 || ^3.0 || ^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.0" + }, + "suggest": { + "symfony/http-kernel": "Allows Symfony integration" + }, + "bin": [ + "bin/coveralls" + ], + "type": "library", + "autoload": { + "psr-4": { + "Satooshi\\": "src/Satooshi/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/php-coveralls/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2017-10-14T23:15:34+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", @@ -1329,28 +1446,28 @@ }, { "name": "phpspec/prophecy", - "version": "1.7.3", + "version": "1.7.6", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf" + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", - "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712", + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" }, "type": "library", "extra": { @@ -1388,7 +1505,7 @@ "spy", "stub" ], - "time": "2017-11-24T13:59:53+00:00" + "time": "2018-04-18T13:57:24+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1592,16 +1709,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "1.4.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", "shasum": "" }, "require": { @@ -1637,20 +1754,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2017-12-04T08:55:13+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.25", + "version": "5.7.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a" + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4b1c822a68ae6577df38a59eb49b046712ec0f6a", - "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", "shasum": "" }, "require": { @@ -1674,7 +1791,7 @@ "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", + "sebastian/version": "^1.0.6|^2.0.1", "symfony/yaml": "~2.1|~3.0|~4.0" }, "conflict": { @@ -1719,7 +1836,7 @@ "testing", "xunit" ], - "time": "2017-11-14T14:50:51+00:00" + "time": "2018-02-01T05:50:59+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -1780,67 +1897,6 @@ ], "time": "2017-06-30T09:13:00+00:00" }, - { - "name": "satooshi/php-coveralls", - "version": "v1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-coveralls/php-coveralls.git", - "reference": "9c07b63acbc9709344948b6fd4f63a32b2ef4127" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/9c07b63acbc9709344948b6fd4f63a32b2ef4127", - "reference": "9c07b63acbc9709344948b6fd4f63a32b2ef4127", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-simplexml": "*", - "guzzle/guzzle": "^2.8 || ^3.0", - "php": "^5.3.3 || ^7.0", - "psr/log": "^1.0", - "symfony/config": "^2.1 || ^3.0 || ^4.0", - "symfony/console": "^2.1 || ^3.0 || ^4.0", - "symfony/stopwatch": "^2.0 || ^3.0 || ^4.0", - "symfony/yaml": "^2.0 || ^3.0 || ^4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.0" - }, - "suggest": { - "symfony/http-kernel": "Allows Symfony integration" - }, - "bin": [ - "bin/coveralls" - ], - "type": "library", - "autoload": { - "psr-4": { - "Satooshi\\": "src/Satooshi/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kitamura Satoshi", - "email": "with.no.parachute@gmail.com", - "homepage": "https://www.facebook.com/satooshi.jp" - } - ], - "description": "PHP client library for Coveralls API", - "homepage": "https://github.com/php-coveralls/php-coveralls", - "keywords": [ - "ci", - "coverage", - "github", - "test" - ], - "time": "2017-10-14T23:15:34+00:00" - }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", @@ -2584,16 +2640,16 @@ }, { "name": "symfony/debug", - "version": "v3.3.13", + "version": "v3.4.12", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "74557880e2846b5c84029faa96b834da37e29810" + "reference": "47e6788c5b151cf0cfdf3329116bf33800632d75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/74557880e2846b5c84029faa96b834da37e29810", - "reference": "74557880e2846b5c84029faa96b834da37e29810", + "url": "https://api.github.com/repos/symfony/debug/zipball/47e6788c5b151cf0cfdf3329116bf33800632d75", + "reference": "47e6788c5b151cf0cfdf3329116bf33800632d75", "shasum": "" }, "require": { @@ -2604,12 +2660,12 @@ "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" }, "require-dev": { - "symfony/http-kernel": "~2.8|~3.0" + "symfony/http-kernel": "~2.8|~3.0|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2636,20 +2692,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-11-10T16:38:39+00:00" + "time": "2018-06-25T11:10:40+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.31", + "version": "v2.8.42", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "b59aacf238fadda50d612c9de73b74751872a903" + "reference": "9b69aad7d4c086dc94ebade2d5eb9145da5dac8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b59aacf238fadda50d612c9de73b74751872a903", - "reference": "b59aacf238fadda50d612c9de73b74751872a903", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9b69aad7d4c086dc94ebade2d5eb9145da5dac8c", + "reference": "9b69aad7d4c086dc94ebade2d5eb9145da5dac8c", "shasum": "" }, "require": { @@ -2696,20 +2752,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-11-05T15:25:56+00:00" + "time": "2018-04-06T07:35:03+00:00" }, { "name": "symfony/finder", - "version": "v3.3.13", + "version": "v3.4.12", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880" + "reference": "3a8c3de91d2b2c68cd2d665cf9d00f7ef9eaa394" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/138af5ec075d4b1d1bd19de08c38a34bb2d7d880", - "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880", + "url": "https://api.github.com/repos/symfony/finder/zipball/3a8c3de91d2b2c68cd2d665cf9d00f7ef9eaa394", + "reference": "3a8c3de91d2b2c68cd2d665cf9d00f7ef9eaa394", "shasum": "" }, "require": { @@ -2718,7 +2774,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2745,20 +2801,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-11-05T15:47:03+00:00" + "time": "2018-06-19T20:52:10+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.6.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" + "reference": "3296adf6a6454a050679cde90f95350ad604b171" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171", + "reference": "3296adf6a6454a050679cde90f95350ad604b171", "shasum": "" }, "require": { @@ -2770,7 +2826,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -2804,20 +2860,20 @@ "portable", "shim" ], - "time": "2017-10-11T12:05:26+00:00" + "time": "2018-04-26T10:06:28+00:00" }, { "name": "symfony/stopwatch", - "version": "v3.3.13", + "version": "v3.4.12", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "1e93c3139ef6c799831fe03efd0fb1c7aecb3365" + "reference": "eb17cfa072cab26537ac37e9c4ece6c0361369af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/1e93c3139ef6c799831fe03efd0fb1c7aecb3365", - "reference": "1e93c3139ef6c799831fe03efd0fb1c7aecb3365", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/eb17cfa072cab26537ac37e9c4ece6c0361369af", + "reference": "eb17cfa072cab26537ac37e9c4ece6c0361369af", "shasum": "" }, "require": { @@ -2826,7 +2882,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2853,20 +2909,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2017-11-10T19:02:53+00:00" + "time": "2018-02-17T14:55:25+00:00" }, { "name": "symfony/yaml", - "version": "v3.3.13", + "version": "v3.3.17", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "0938408c4faa518d95230deabb5f595bf0de31b9" + "reference": "af615970e265543a26ee712c958404eb9b7ac93d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/0938408c4faa518d95230deabb5f595bf0de31b9", - "reference": "0938408c4faa518d95230deabb5f595bf0de31b9", + "url": "https://api.github.com/repos/symfony/yaml/zipball/af615970e265543a26ee712c958404eb9b7ac93d", + "reference": "af615970e265543a26ee712c958404eb9b7ac93d", "shasum": "" }, "require": { @@ -2908,7 +2964,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-11-10T18:26:04+00:00" + "time": "2018-01-20T15:04:53+00:00" }, { "name": "theseer/fdomdocument", @@ -2952,16 +3008,16 @@ }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", "shasum": "" }, "require": { @@ -2998,7 +3054,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], diff --git a/src/decider/agent_tests/Functional/schedulerTest.php b/src/decider/agent_tests/Functional/schedulerTest.php index 17aaea191b..0038d82187 100644 --- a/src/decider/agent_tests/Functional/schedulerTest.php +++ b/src/decider/agent_tests/Functional/schedulerTest.php @@ -26,9 +26,9 @@ use Fossology\Lib\Dao\ClearingDao; use Fossology\Lib\Dao\HighlightDao; use Fossology\Lib\Dao\LicenseDao; +use Fossology\Lib\Dao\ShowJobsDao; use Fossology\Lib\Dao\UploadDao; use Fossology\Lib\Dao\UploadPermissionDao; -use Fossology\Lib\Dao\ShowJobsDao; use Fossology\Lib\Data\DecisionScopes; use Fossology\Lib\Data\DecisionTypes; use Fossology\Lib\Data\Tree\ItemTreeBounds; diff --git a/src/decider/agent_tests/Unit/DeciderAgentTest.php b/src/decider/agent_tests/Unit/DeciderAgentTest.php index 452129fecd..de41bca33e 100644 --- a/src/decider/agent_tests/Unit/DeciderAgentTest.php +++ b/src/decider/agent_tests/Unit/DeciderAgentTest.php @@ -36,7 +36,6 @@ require_once(__DIR__ . '/../../../lib/php/Test/Agent/AgentTestMockHelper.php'); require_once(__DIR__ . '/../../agent/DeciderAgent.php'); - class DeciderAgentTest extends \PHPUnit\Framework\TestCase { /** @var DbManager */ diff --git a/src/lib/c/tests/testClib.php b/src/lib/c/tests/testClib.php index eef3a37393..846e7c3252 100644 --- a/src/lib/c/tests/testClib.php +++ b/src/lib/c/tests/testClib.php @@ -19,7 +19,7 @@ use Fossology\Lib\Test\TestPgDb; use Mockery as M; -/** +/** * @todo remove this file and change Makefile */ diff --git a/src/lib/php/Application/test/LicenseCsvExportTest.php b/src/lib/php/Application/test/LicenseCsvExportTest.php index 627daefb71..601efd5be9 100644 --- a/src/lib/php/Application/test/LicenseCsvExportTest.php +++ b/src/lib/php/Application/test/LicenseCsvExportTest.php @@ -34,8 +34,8 @@ protected function tearDown() { $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); M::close(); } - - + + public function testCreateCsv() { $testDb = new TestLiteDb(); @@ -51,7 +51,7 @@ public function testCreateCsv() $dbManager->insertTableRow('license_map', array('rf_fk'=>3,'rf_parent'=>1,'usage'=>LicenseMap::CONCLUSION)); $dbManager->insertTableRow('license_map', array('rf_fk'=>3,'rf_parent'=>2,'usage'=>LicenseMap::REPORT)); - + $licenseCsvExport = new LicenseCsvExport($dbManager); $head = array('shortname','fullname','text','parent_shortname','report_shortname','url','notes','source','risk'); $out = fopen('php://output', 'w'); @@ -68,7 +68,7 @@ public function testCreateCsv() $licenses[1]['rf_notes'], $licenses[1]['rf_source'], $licenses[1]['rf_risk'])); - + fputcsv($out, array($licenses[2]['rf_shortname'], $licenses[2]['rf_fullname'], $licenses[2]['rf_text'], @@ -78,7 +78,7 @@ public function testCreateCsv() $licenses[2]['rf_notes'], $licenses[2]['rf_source'], $licenses[2]['rf_risk'])); - + fputcsv($out, array($licenses[3]['rf_shortname'], $licenses[3]['rf_fullname'], $licenses[3]['rf_text'], @@ -91,7 +91,7 @@ public function testCreateCsv() $expected = ob_get_contents(); ob_end_clean(); assertThat($csv,is(equalTo($expected))); - + $delimiter = '|'; $licenseCsvExport->setDelimiter($delimiter); $csv3 = $licenseCsvExport->createCsv(3); @@ -109,37 +109,37 @@ public function testCreateCsv() $delimiter); $expected3 = ob_get_contents(); ob_end_clean(); - assertThat($csv3,is(equalTo($expected3))); + assertThat($csv3,is(equalTo($expected3))); } - - + + public function testSetDelimiter() { $dbManager = M::mock(DbManager::class); $licenseCsvExport = new LicenseCsvExport($dbManager); - $reflection = new \ReflectionClass($licenseCsvExport); + $reflection = new \ReflectionClass($licenseCsvExport); $delimiter = $reflection->getProperty('delimiter'); $delimiter->setAccessible(true); - + $licenseCsvExport->setDelimiter('|'); assertThat($delimiter->getValue($licenseCsvExport),is('|')); - + $licenseCsvExport->setDelimiter('<>'); assertThat($delimiter->getValue($licenseCsvExport),is('<')); } - + public function testSetEnclosure() { $dbManager = M::mock(DbManager::class); $licenseCsvExport = new LicenseCsvExport($dbManager); - $reflection = new \ReflectionClass($licenseCsvExport); + $reflection = new \ReflectionClass($licenseCsvExport); $enclosure = $reflection->getProperty('enclosure'); $enclosure->setAccessible(true); - + $licenseCsvExport->setEnclosure('|'); assertThat($enclosure->getValue($licenseCsvExport),is('|')); - + $licenseCsvExport->setEnclosure('<>'); assertThat($enclosure->getValue($licenseCsvExport),is('<')); } diff --git a/src/lib/php/Application/test/LicenseCsvImportTest.php b/src/lib/php/Application/test/LicenseCsvImportTest.php index d6083cc127..40c365f9ed 100644 --- a/src/lib/php/Application/test/LicenseCsvImportTest.php +++ b/src/lib/php/Application/test/LicenseCsvImportTest.php @@ -36,7 +36,7 @@ protected function tearDown() { $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); M::close(); } - + public function testGetKeyFromShortname() { $testDb = new TestLiteDb(); @@ -47,11 +47,11 @@ public function testGetKeyFromShortname() $dbManager = &$testDb->getDbManager(); $dbManager->insertTableRow('license_ref', array('rf_pk'=>$knownId,'rf_shortname'=>$shortname)); $licenseCsvImport = new LicenseCsvImport($dbManager); - + assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'getKeyFromShortname', array($shortname)), equalTo($knownId)); assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'getKeyFromShortname', array("no $shortname")), equalTo(false)); } - + public function testHandleCsvLicense() { $dbManager = M::mock(DbManager::class); @@ -68,7 +68,7 @@ public function testHandleCsvLicense() $dbManager->shouldReceive('execute'); $dbManager->shouldReceive('freeResult'); $dbManager->shouldReceive('fetchArray')->andReturn(array('rf_pk'=>102)); - + $dbManager->shouldReceive('insertTableRow')->withArgs(array('license_map', array('rf_fk'=>102,'rf_parent'=>101,'usage'=>LicenseMap::CONCLUSION)))->once(); $returnB = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleCsvLicense', array( @@ -82,12 +82,12 @@ public function testHandleCsvLicense() array('shortname'=>'licF','fullname'=>'liceF','text'=>'txF','url'=>'','notes'=>'','source'=>'','risk'=>1, 'parent_shortname'=>null,'report_shortname'=>'licZ'))); assertThat($returnF, is("Inserted 'licF' in DB reporting 'licZ'")); - + $returnC = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleCsvLicense', array( array('shortname'=>'licC','fullname'=>'liceC','text'=>'txC','url'=>'','notes'=>'','source'=>'','risk'=>2, 'parent_shortname'=>null,'report_shortname'=>null))); assertThat($returnC, is("Inserted 'licC' in DB")); - + $returnA = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleCsvLicense', array( array('shortname'=>'licA','fullname'=>'liceB','text'=>'txB','url'=>'','notes'=>'','source'=>'','risk'=>2, 'parent_shortname'=>null,'report_shortname'=>null))); @@ -97,30 +97,30 @@ public function testHandleCsvLicense() array('shortname'=>'licE','fullname'=>'liceE','text'=>'txD','url'=>'','notes'=>'','source'=>'','risk'=>false, 'parent_shortname'=>null,'report_shortname'=>null))); assertThat($returnE, is("Text of 'licE' already used for 'licD'")); - + $returnG = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleCsvLicense', array( array('shortname'=>'licG','fullname'=>'liceG','text'=>'txD','url'=>'','notes'=>'','source'=>'_G_go_G_', 'parent_shortname'=>null,'report_shortname'=>null,'risk'=>false))); assertThat($returnG, is("Text of 'licG' already used for 'licD', updated the source")); - + $returnH = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleCsvLicense', array( array('shortname'=>'licH','fullname'=>'liceH','text'=>'txD','url'=>'','notes'=>'','source'=>'_G_go_G_', 'parent_shortname'=>null,'report_shortname'=>null,'risk'=>3))); assertThat($returnH, is("Text of 'licH' already used for 'licD', updated the source, updated the risk level")); } - + public function testHandleHeadCsv() { $dbManager = M::mock(DbManager::class); $licenseCsvImport = new LicenseCsvImport($dbManager); - + assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleHeadCsv',array(array('shortname','foo','text','fullname','notes','bar'))), is( array('shortname'=>0,'fullname'=>3,'text'=>2,'parent_shortname'=>false,'report_shortname'=>false,'url'=>false,'notes'=>4,'source'=>false,'risk'=>0) ) ); - + assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleHeadCsv',array(array('Short Name','URL','text','fullname','notes','Foreign ID'))), is( array('shortname'=>0,'fullname'=>3,'text'=>2,'parent_shortname'=>false,'report_shortname'=>false,'url'=>1,'notes'=>4,'source'=>5,'risk'=>false) ) ); } - + /** * @expectedException Exception */ @@ -130,36 +130,36 @@ public function testHandleHeadCsv_missingMandidatoryKey() $licenseCsvImport = new LicenseCsvImport($dbManager); Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleHeadCsv',array(array('shortname','foo','text'))); } - + public function testSetDelimiter() { $dbManager = M::mock(DbManager::class); $licenseCsvImport = new LicenseCsvImport($dbManager); - + $licenseCsvImport->setDelimiter('|'); assertThat(Reflectory::getObjectsProperty($licenseCsvImport,'delimiter'),is('|')); - + $licenseCsvImport->setDelimiter('<>'); assertThat(Reflectory::getObjectsProperty($licenseCsvImport,'delimiter'),is('<')); } - + public function testSetEnclosure() { $dbManager = M::mock(DbManager::class); $licenseCsvImport = new LicenseCsvImport($dbManager); - + $licenseCsvImport->setEnclosure('|'); assertThat(Reflectory::getObjectsProperty($licenseCsvImport,'enclosure') ,is('|')); - + $licenseCsvImport->setEnclosure('<>'); assertThat(Reflectory::getObjectsProperty($licenseCsvImport,'enclosure'),is('<')); } - + public function testHandleCsv() { $dbManager = M::mock(DbManager::class); $licenseCsvImport = new LicenseCsvImport($dbManager); - + Reflectory::invokeObjectsMethodnameWith($licenseCsvImport, 'handleCsv', array(array('shortname','foo','text','fullname','notes'))); assertThat(Reflectory::getObjectsProperty($licenseCsvImport,'headrow'),is(notNullValue())); @@ -172,8 +172,8 @@ public function testHandleCsv() Reflectory::invokeObjectsMethodnameWith($licenseCsvImport, 'handleCsv', array(array('licA','bar','txA','liceA','noteA'))); assertThat(Reflectory::getObjectsProperty($licenseCsvImport, 'nkMap'),is(array('licA'=>101))); } - - + + public function testHandleFileIfFileNotExists() { $dbManager = M::mock(DbManager::class); @@ -181,7 +181,7 @@ public function testHandleFileIfFileNotExists() $msg = $licenseCsvImport->handleFile('/tmp/thisFileNameShouldNotExists'); assertThat($msg, is(equalTo(_('Internal error')))); } - + public function testHandleFileIfFileIsNotParsable() { $dbManager = M::mock(DbManager::class); @@ -202,5 +202,4 @@ public function testHandleFile() assertThat($msg, startsWith( _('head okay'))); unlink($filename); } - } diff --git a/src/lib/php/Application/test/UserInfoTest.php b/src/lib/php/Application/test/UserInfoTest.php index f80ae8451b..2dd68b2777 100644 --- a/src/lib/php/Application/test/UserInfoTest.php +++ b/src/lib/php/Application/test/UserInfoTest.php @@ -18,7 +18,6 @@ namespace Fossology\Lib\Application; - class UserInfoTest extends \PHPUnit\Framework\TestCase { /** @var UserInfo */ diff --git a/src/lib/php/BusinessRules/test/AgentLicenseEventProcessorTest.php b/src/lib/php/BusinessRules/test/AgentLicenseEventProcessorTest.php index 52da19a02a..2e84e74c1e 100644 --- a/src/lib/php/BusinessRules/test/AgentLicenseEventProcessorTest.php +++ b/src/lib/php/BusinessRules/test/AgentLicenseEventProcessorTest.php @@ -48,7 +48,7 @@ protected function setUp() $this->itemTreeBounds = M::mock(ItemTreeBounds::class); $this->agentLicenseEventProcessor = new AgentLicenseEventProcessor($this->licenseDao, $this->agentsDao); - + global $container; $this->dbManagerMock = M::mock(DbManager::class); $this->dbManagerMock->shouldReceive('prepare'); @@ -106,7 +106,7 @@ public function testGetScannerDetectedLicenseDetails() ->andReturn($licenseMatches); // $latestAgentDetectedLicenses = $this->agentLicenseEventProcessor->getScannerDetectedLicenseDetails($this->itemTreeBounds); - $reflection = new \ReflectionClass($this->agentLicenseEventProcessor); + $reflection = new \ReflectionClass($this->agentLicenseEventProcessor); $method = $reflection->getMethod('getScannerDetectedLicenseDetails'); $method->setAccessible(true); $latestAgentDetectedLicenses = $method->invoke($this->agentLicenseEventProcessor,$this->itemTreeBounds); @@ -119,7 +119,7 @@ public function testGetScannerDetectedLicenseDetails() array('id' => $licId, 'licenseRef' => $licenseRef2, 'agentRef' => $agentRef2, 'matchId' => 665, 'percentage' => 95) ) ) ); - + } @@ -137,7 +137,7 @@ public function testGetScannerDetectedLicenseDetailsWithUnknownAgent() // $latestAgentDetectedLicenses = $this->agentLicenseEventProcessor->getScannerDetectedLicenseDetails($this->itemTreeBounds); - $reflection = new \ReflectionClass($this->agentLicenseEventProcessor); + $reflection = new \ReflectionClass($this->agentLicenseEventProcessor); $method = $reflection->getMethod('getScannerDetectedLicenseDetails'); $method->setAccessible(true); $latestAgentDetectedLicenses = $method->invoke($this->agentLicenseEventProcessor,$this->itemTreeBounds); @@ -165,7 +165,7 @@ public function testGetScannerDetectedLicenseDetailsWithOutdatedMatches() // $latestAgentDetectedLicenses = $this->agentLicenseEventProcessor->getScannerDetectedLicenseDetails($this->itemTreeBounds); - $reflection = new \ReflectionClass($this->agentLicenseEventProcessor); + $reflection = new \ReflectionClass($this->agentLicenseEventProcessor); $method = $reflection->getMethod('getScannerDetectedLicenseDetails'); $method->setAccessible(true); $latestAgentDetectedLicenses = $method->invoke($this->agentLicenseEventProcessor,$this->itemTreeBounds); @@ -186,7 +186,7 @@ public function testGetScannerDetectedLicenseDetailsNoLicenseFoundShouldBeSkippe // $latestAgentDetectedLicenses = $this->agentLicenseEventProcessor->getScannerDetectedLicenseDetails($this->itemTreeBounds); - $reflection = new \ReflectionClass($this->agentLicenseEventProcessor); + $reflection = new \ReflectionClass($this->agentLicenseEventProcessor); $method = $reflection->getMethod('getScannerDetectedLicenseDetails'); $method->setAccessible(true); $latestAgentDetectedLicenses = $method->invoke($this->agentLicenseEventProcessor,$this->itemTreeBounds); diff --git a/src/lib/php/BusinessRules/test/ClearingDecisionProcessorTest.php b/src/lib/php/BusinessRules/test/ClearingDecisionProcessorTest.php index 56253ad343..acaf243f16 100644 --- a/src/lib/php/BusinessRules/test/ClearingDecisionProcessorTest.php +++ b/src/lib/php/BusinessRules/test/ClearingDecisionProcessorTest.php @@ -20,15 +20,15 @@ use Fossology\Lib\Dao\ClearingDao; use Fossology\Lib\Data\AgentRef; +use Fossology\Lib\Data\ClearingDecision; +use Fossology\Lib\Data\DecisionScopes; +use Fossology\Lib\Data\DecisionTypes; +use Fossology\Lib\Data\LicenseRef; use Fossology\Lib\Data\Clearing\AgentClearingEvent; use Fossology\Lib\Data\Clearing\ClearingEvent; use Fossology\Lib\Data\Clearing\ClearingEventTypes; use Fossology\Lib\Data\Clearing\ClearingLicense; use Fossology\Lib\Data\Clearing\ClearingResult; -use Fossology\Lib\Data\ClearingDecision; -use Fossology\Lib\Data\DecisionScopes; -use Fossology\Lib\Data\DecisionTypes; -use Fossology\Lib\Data\LicenseRef; use Fossology\Lib\Data\Tree\ItemTreeBounds; use Fossology\Lib\Db\DbManager; use Mockery as M; @@ -299,7 +299,7 @@ public function testMakeDecisionFromLastEventsWithDelayedScanner() $this->clearingDao->shouldReceive("insertClearingEvent") ->never(); - + $this->clearingDao->shouldReceive("createDecisionFromEvents") ->once() ->with($this->uploadTreeId, $this->userId, $this->groupId, DecisionTypes::IDENTIFIED, DecisionScopes::ITEM, @@ -390,7 +390,7 @@ public function testGetCurrentClearingsWithUserAndAgentDecision() ->andReturn($scannerResults); $licenseId = $licenseRef->getId(); - + $addedEvent = $this->createClearingEvent(123, $this->timestamp, $licenseId, $licenseRef->getShortName(), $licenseRef->getFullName()); $this->clearingDao->shouldReceive("getRelevantClearingEvents") ->with($this->itemTreeBounds, $this->groupId) @@ -453,7 +453,7 @@ public function testGetUnhandledScannerDetectedLicenses() ->with($this->itemTreeBounds,LicenseMap::TRIVIAL)->andReturn($scannerResults); $hasUnhandledScannerDetectedLicenses = $this->clearingDecisionProcessor->hasUnhandledScannerDetectedLicenses($this->itemTreeBounds, $this->groupId); - + assertThat($hasUnhandledScannerDetectedLicenses); } @@ -491,7 +491,7 @@ public function testGetUnhandledScannerDetectedLicensesWithoutMatch() assertThat($hasUnhandledScannerDetectedLicenses, is(True)); } - + public function testGetUnhandledScannerDetectedLicensesWithMappedMatch() { /** @var LicenseRef $licenseRef */ @@ -508,7 +508,7 @@ public function testGetUnhandledScannerDetectedLicensesWithMappedMatch() $licenseMap = M::mock(LicenseMap::class); $licenseMap->shouldReceive('getProjectedId')->andReturnUsing(function($id) {return $id;}); $licenseMap->shouldReceive('getUsage')->andReturn(LicenseMap::CONCLUSION); - + $hasUnhandledScannerDetectedLicenses = $this->clearingDecisionProcessor->hasUnhandledScannerDetectedLicenses($this->itemTreeBounds, $this->groupId, array(), $licenseMap); assertThat( $hasUnhandledScannerDetectedLicenses, is(False) ); @@ -541,7 +541,7 @@ protected function createScannerDetectedLicenses($licenseId = 13, $licenseShortn $licenseRef = new LicenseRef($licenseId, $licenseShortname, $licenseFullName); $agentRef = M::mock(AgentRef::class); - + $scannerEvents = array( $licenseId => array(new AgentClearingEvent($licenseRef, $agentRef, self::MATCH_ID, self::PERCENTAGE)) ); diff --git a/src/lib/php/BusinessRules/test/ClearingEventProcessorTest.php b/src/lib/php/BusinessRules/test/ClearingEventProcessorTest.php index 220d466e42..18e4872684 100644 --- a/src/lib/php/BusinessRules/test/ClearingEventProcessorTest.php +++ b/src/lib/php/BusinessRules/test/ClearingEventProcessorTest.php @@ -19,12 +19,11 @@ namespace Fossology\Lib\BusinessRules; use Fossology\Lib\Data\Clearing\ClearingEvent; -use Fossology\Lib\Data\Clearing\ClearingLicense; use Fossology\Lib\Data\Clearing\ClearingEventTypes; +use Fossology\Lib\Data\Clearing\ClearingLicense; use Fossology\Lib\Data\LicenseRef; use Mockery as M; - class ClearingEventProcessorTest extends \PHPUnit\Framework\TestCase { private $itemId = 12; @@ -52,7 +51,7 @@ protected function setUp() $this->addedLicense = M::mock(ClearingLicense::class); $this->addedLicense->shouldReceive("getShortName")->withNoArgs()->andReturn($this->addedName); $this->addedLicense->shouldReceive("getId")->withNoArgs()->andReturn($this->addedId); - + $this->addedEvent = M::mock(ClearingEvent::class); $this->addedEvent->shouldReceive("getLicenseShortName")->withNoArgs()->andReturn($this->addedName); $this->addedEvent->shouldReceive("getLicenseId")->withNoArgs()->andReturn($this->addedId); diff --git a/src/lib/php/BusinessRules/test/LicenseMapTest.php b/src/lib/php/BusinessRules/test/LicenseMapTest.php index 3e81628997..104061de11 100644 --- a/src/lib/php/BusinessRules/test/LicenseMapTest.php +++ b/src/lib/php/BusinessRules/test/LicenseMapTest.php @@ -47,7 +47,7 @@ protected function tearDown() { $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); } - + function testProjectedIdOfUnmappedIdIsIdItself() { $licenseMap = new LicenseMap($this->dbManager, $this->groupId); @@ -61,26 +61,26 @@ function testProjectedIdOfCandidatesAreRecognized() $licenseId = 3; assertThat($licenseMap->getProjectedId($licenseId),is($licenseId)); } - + function testProjectedIdOfUnmappedIdIsParentId() { $licenseMap = new LicenseMap($this->dbManager, $this->groupId); $licenseMap->getGroupId(); assertThat($licenseMap->getProjectedId(2),is(1)); } - + function testProjectedShortNameOfMappedId() { $licenseMap = new LicenseMap($this->dbManager, $this->groupId); assertThat($licenseMap->getProjectedShortName(2),is('One')); } - + function testProjectedIdOfMappedIdIsIdItselfIfTrivialMap() { $licenseMap = new LicenseMap($this->dbManager, $this->groupId, LicenseMap::TRIVIAL); assertThat($licenseMap->getProjectedId(2),is(2)); } - + function testGetTopLevelLicenseRefs() { $licenseMap = new LicenseMap($this->dbManager, $this->groupId, LicenseMap::CONCLUSION); @@ -88,8 +88,8 @@ function testGetTopLevelLicenseRefs() assertThat($topLevelLicenses,hasItemInArray(new LicenseRef(1,'One','One-1'))); assertThat($topLevelLicenses, not(hasKeyInArray(2))); } - - + + public function testGetMappedLicenseRefView() { $this->testDb = new TestPgDb(); @@ -102,7 +102,7 @@ public function testGetMappedLicenseRefView() $this->dbManager->insertTableRow('license_candidate', array('rf_pk'=>3,'rf_shortname'=>'Three','rf_fullname'=>'Three-3','group_fk'=>$this->groupId)); $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); - + $view = LicenseMap::getMappedLicenseRefView(LicenseMap::CONCLUSION); $stmt = __METHOD__; $this->dbManager->prepare($stmt,$view); @@ -116,7 +116,7 @@ public function testGetMappedLicenseRefView() ); assertThat($map,containsInAnyOrder($expected)); } - + public function testFullMap() { $licenseMap = new LicenseMap($this->dbManager, $this->groupId+1, LicenseMap::CONCLUSION, true); @@ -124,7 +124,7 @@ public function testFullMap() assertThat($map,hasItemInArray(array('rf_fk'=>1,'parent_shortname'=>'One','rf_parent'=>1))); assertThat($map,hasItemInArray(array('rf_fk'=>2,'parent_shortname'=>'One','rf_parent'=>1))); } - + public function testFullMapWithCandidates() { $licenseMap = new LicenseMap($this->dbManager, $this->groupId, LicenseMap::CONCLUSION, true); @@ -133,5 +133,5 @@ public function testFullMapWithCandidates() assertThat($map,hasItemInArray(array('rf_fk'=>2,'parent_shortname'=>'One','rf_parent'=>1))); assertThat($map,hasItemInArray(array('rf_fk'=>3,'parent_shortname'=>'Three','rf_parent'=>3))); } - + } diff --git a/src/lib/php/Dao/test/AgentDaoTest.php b/src/lib/php/Dao/test/AgentDaoTest.php index 97c5476cc6..ab11a06957 100644 --- a/src/lib/php/Dao/test/AgentDaoTest.php +++ b/src/lib/php/Dao/test/AgentDaoTest.php @@ -72,7 +72,7 @@ protected function setUp() { $this->testDb = new TestPgDb(); $this->dbManager = &$this->testDb->getDbManager(); - + $this->agent = new AgentRef($this->agentId, $this->agentName, $this->agentRev); $this->olderAgent = new AgentRef($this->olderAgentId, $this->agentName, $this->olderAgentRev); $this->otherAgent = new AgentRef($this->otherAgentId, $this->otherAgentName, $this->otherAgentRev); @@ -146,7 +146,7 @@ public function testGetLatestAgentResultForUpload() $container = M::mock('ContainerBuilder'); $this->dbManagerMock = M::mock(DbManager::class); $container->shouldReceive('get')->withArgs(array('db.manager'))->andReturn($this->dbManagerMock); - + $this->dbManagerMock->shouldReceive('prepare')->once(); $this->dbManagerMock->shouldReceive('execute')->once(); $this->dbManagerMock->shouldReceive('fetchArray') @@ -154,7 +154,7 @@ public function testGetLatestAgentResultForUpload() array('agent_pk'=>$this->otherAgentId,'agent_name'=>$this->otherAgentName), false); $this->dbManagerMock->shouldReceive('freeResult')->once(); - + $latestAgentResults = $this->agentsDao->getLatestAgentResultForUpload($this->uploadId, array($this->agentName, $this->otherAgentName)); assertThat($latestAgentResults, is(array( $this->agentName => $this->agentId, diff --git a/src/lib/php/Dao/test/ClearingDaoTest.php b/src/lib/php/Dao/test/ClearingDaoTest.php index 721077c95a..3a3ecf48c1 100644 --- a/src/lib/php/Dao/test/ClearingDaoTest.php +++ b/src/lib/php/Dao/test/ClearingDaoTest.php @@ -19,17 +19,17 @@ namespace Fossology\Lib\Dao; -use Fossology\Lib\Data\Clearing\ClearingEvent; use Fossology\Lib\Data\DecisionScopes; use Fossology\Lib\Data\DecisionTypes; use Fossology\Lib\Data\LicenseRef; +use Fossology\Lib\Data\Clearing\ClearingEvent; use Fossology\Lib\Data\Tree\ItemTreeBounds; use Fossology\Lib\Db\DbManager; use Fossology\Lib\Test\TestPgDb; +use Monolog\Logger; +use Monolog\Handler\ErrorLogHandler; use Mockery as M; use Mockery\MockInterface; -use Monolog\Handler\ErrorLogHandler; -use Monolog\Logger; class ClearingDaoTest extends \PHPUnit\Framework\TestCase { @@ -74,7 +74,7 @@ protected function setUp() 'users', 'uploadtree' )); - + $this->testDb->createInheritedTables(); $userArray = array( @@ -143,8 +143,8 @@ protected function setUp() $this->dbManager->insertInto('license_ref_bulk', 'lrb_pk, rf_text, upload_fk, uploadtree_fk, group_fk', $paramsRef, 'insert.bulkref'); $this->dbManager->insertInto('license_set_bulk', 'lrb_fk, rf_fk, removing', $paramsSet, 'insert.bulkset'); } - - + + $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); } @@ -267,7 +267,7 @@ function testWip() $watchOtherNow = $this->clearingDao->isDecisionWip(303, $groupId); assertThat($watchOtherNow,is(FALSE)); } - + private function collectBulkLicenses($bulks) { $bulkLics = array(); @@ -357,7 +357,7 @@ public function testBulkHistoryWithAMatchReturningAlsoNotTried() assertThat($bulkLicDirs, arrayContaining(false, false, true, false, true, true)); assertThat($bulkTried, arrayContaining(true, true, true, true, true, false)); } - + public function testGetClearedLicenseMultiplicities() { $user = 1; @@ -377,11 +377,11 @@ public function testGetClearedLicenseMultiplicities() $treeBounds->shouldReceive('getRight')->andReturn(8); $treeBounds->shouldReceive('getUploadTreeTableName')->andReturn("uploadtree"); $treeBounds->shouldReceive('getUploadId')->andReturn(102); - + $map = $this->clearingDao->getClearedLicenseIdAndMultiplicities($treeBounds, $groupId); assertThat($map, is(array('FOO'=>array('count'=>2,'shortname'=>'FOO','rf_pk'=>401)))); } - + public function testGetClearedLicenses() { $user = 1; @@ -401,48 +401,48 @@ public function testGetClearedLicenses() $treeBounds->shouldReceive('getRight')->andReturn(8); $treeBounds->shouldReceive('getUploadTreeTableName')->andReturn("uploadtree"); $treeBounds->shouldReceive('getUploadId')->andReturn(102); - + $map = $this->clearingDao->getClearedLicenses($treeBounds, $groupId); assertThat($map, equalTo(array(new LicenseRef($rf,'FOO','foo full')))); } - + public function testMainLicenseIds() { $this->testDb->createPlainTables(array('upload_clearing_license')); $uploadId = 101; $mainLicIdsInitially = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId); assertThat($mainLicIdsInitially, is(emptyArray())); - + $this->clearingDao->makeMainLicense($uploadId,$this->groupId,$licenseId=402); $mainLicIdsAfterAddingOne = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId); assertThat($mainLicIdsAfterAddingOne, arrayContaining(array($licenseId))); - + $this->clearingDao->makeMainLicense($uploadId,$this->groupId,$licenseId); $mainLicIdsAfterAddingOneTwice = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId); assertThat($mainLicIdsAfterAddingOneTwice, is(arrayWithSize(1))); - + $this->clearingDao->makeMainLicense($uploadId,$this->groupId,$licenseId2=403); $mainLicIdsAfterAddingOther = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId); assertThat($mainLicIdsAfterAddingOther, arrayContainingInAnyOrder(array($licenseId,$licenseId2))); - + $this->clearingDao->removeMainLicense($uploadId,$this->groupId,$licenseId2); $mainLicIdsAfterRemovingOne = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId); assertThat($mainLicIdsAfterRemovingOne, is(arrayWithSize(1))); - + $this->clearingDao->removeMainLicense($uploadId,$this->groupId,$licenseId2); $mainLicIdAfterRemovingSomethingNotInSet = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId); assertThat($mainLicIdAfterRemovingSomethingNotInSet, is(arrayWithSize(1))); - + $this->clearingDao->removeMainLicense($uploadId,$this->groupId+1,$licenseId); $mainLicIdAfterInsertToOtherGroup = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId); assertThat($mainLicIdAfterInsertToOtherGroup, is(arrayWithSize(1))); - + $this->clearingDao->removeMainLicense($uploadId+1,$this->groupId,$licenseId); $mainLicIdAfterInsertToOtherUpload = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId); assertThat($mainLicIdAfterInsertToOtherUpload, is(arrayWithSize(1))); } - + public function testupdateClearingEvent() { $this->testDb->createSequences(array('clearing_event_clearing_event_pk_seq')); @@ -452,7 +452,7 @@ public function testupdateClearingEvent() $this->clearingDao->updateClearingEvent($uploadTreeId=301, $userId=1, $groupId=1, $licenseId=402, $what='comment', $changeCom='abc123'); $rowPast = $this->dbManager->getSingleRow('SELECT * FROM clearing_event WHERE uploadtree_fk=$1 AND rf_fk=$2 ORDER BY clearing_event_pk DESC LIMIT 1',array($uploadTreeId,$licenseId),__METHOD__.'beforeReportinfo'); assertThat($rowPast['comment'],equalTo($changeCom)); - + $this->clearingDao->updateClearingEvent($uploadTreeId, $userId, $groupId, $licenseId, $what='reportinfo', $changeRep='def456'); $rowFuture = $this->dbManager->getSingleRow('SELECT * FROM clearing_event WHERE uploadtree_fk=$1 AND rf_fk=$2 ORDER BY clearing_event_pk DESC LIMIT 1',array($uploadTreeId,$licenseId),__METHOD__.'afterReportinfo'); assertThat($rowFuture['comment'],equalTo($changeCom)); diff --git a/src/lib/php/Dao/test/CopyrightDaoTest.php b/src/lib/php/Dao/test/CopyrightDaoTest.php index 429caa4aaf..10a0c1d0ce 100644 --- a/src/lib/php/Dao/test/CopyrightDaoTest.php +++ b/src/lib/php/Dao/test/CopyrightDaoTest.php @@ -45,7 +45,7 @@ protected function setUp() $this->testDb = new TestPgDb(); $this->dbManager = $this->testDb->getDbManager(); } - + protected function tearDown() { $this->testDb = null; @@ -64,7 +64,7 @@ public function testGetCopyrightHighlights() $copyrightDao = new CopyrightDao($this->dbManager,$uploadDao); $noHighlights = $copyrightDao->getHighlights($uploadTreeId=1); assertThat($noHighlights,emptyArray()); - + $this->testDb->insertData(array('copyright')); $highlights = $copyrightDao->getHighlights($uploadTreeId = 1); assertThat($highlights,arrayWithSize(1)); @@ -72,7 +72,7 @@ public function testGetCopyrightHighlights() assertThat($highlight0,anInstanceOf(Highlight::class)); $this->assertInstanceOf('Fossology\Lib\Data\Highlight', $highlight0); assertThat($highlight0->getEnd(),equalTo(201)); - + $hilights = $copyrightDao->getHighlights($uploadTreeId=2); assertThat($hilights,arrayWithSize(1)); $hilight0 = $hilights[0]; @@ -291,11 +291,11 @@ public function testGetAllEntriesOnlyStatementsWithFilterAndOnlyClearedIndentify public function testUpdateTable() { $this->setUpClearingTables(); - + $item = new ItemTreeBounds(6,'uploadtree_a',1,17,18); $hash2 = '0x3a910990f114f12f'; $ctPk = 2; - + $uploadDao = M::mock('Fossology\Lib\Dao\UploadDao'); $copyrightDao = new CopyrightDao($this->dbManager,$uploadDao); $copyrightDao->updateTable($item, $hash2, $content='foo', $userId=55); @@ -303,20 +303,20 @@ public function testUpdateTable() $updatedCp = $this->dbManager->getSingleRow('SELECT * FROM copyright WHERE ct_pk=$1',array($ctPk),__METHOD__.'.cp'); assertThat($updatedCp['content'],is(equalTo($content))); } - + public function testDeleteCopyright() { $this->setUpClearingTables(); - + $uploadDao = M::mock('Fossology\Lib\Dao\UploadDao'); - $copyrightDao = new CopyrightDao($this->dbManager,$uploadDao); + $copyrightDao = new CopyrightDao($this->dbManager,$uploadDao); $initialEntries = $copyrightDao->getAllEntries("copyright", 1, "uploadtree_a"); $initialCount = count($initialEntries); - + $item = new ItemTreeBounds(6,'uploadtree_a',1,17,18); $hash2 = '0x3a910990f114f12f'; $copyrightDao->updateTable($item, $hash2, $content='', 55, 'copyright', 'delete'); - + $remainingEntries = $copyrightDao->getAllEntries("copyright", 1, "uploadtree_a"); $remainingCount = count($remainingEntries); assertThat($remainingCount,is(equalTo($initialCount-1))); diff --git a/src/lib/php/Dao/test/FolderDaoTest.php b/src/lib/php/Dao/test/FolderDaoTest.php index 5d30db475f..1eb958f6a0 100644 --- a/src/lib/php/Dao/test/FolderDaoTest.php +++ b/src/lib/php/Dao/test/FolderDaoTest.php @@ -44,7 +44,7 @@ protected function setUp() $this->testDb->createSequences(array('folder_folder_pk_seq','foldercontents_foldercontents_pk_seq')); $this->testDb->createConstraints(array('folder_pkey','foldercontents_pkey')); $this->testDb->alterTables(array('folder','foldercontents')); - + $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); } @@ -74,7 +74,7 @@ public function testHasTopLevelFolder_no() assertThat($htlf, is(FALSE)); } - + public function testInsertFolder() { $folderId = $this->folderDao->insertFolder($folderName = 'three', $folderDescription = 'floor(PI)'); @@ -82,7 +82,7 @@ public function testInsertFolder() $folderInfo = $this->dbManager->getSingleRow('SELECT folder_name,folder_desc FROM folder WHERE folder_pk=$1', array($folderId), __METHOD__); assertThat($folderInfo, is(array('folder_name' => $folderName, 'folder_desc' => $folderDescription))); - + $folderIdPlusOne = $this->folderDao->insertFolder($folderName = 'four', $folderDescription = 'ceil(PI)'); assertThat($folderIdPlusOne, equalTo(FolderDao::TOP_LEVEL+1)); @@ -126,7 +126,7 @@ public function testEnsureTopLevelFolder() $folders = $this->dbManager->getSingleRow('SELECT count(*) FROM folder'); assertThat($folders['count'],is(1)); } - + public function testIsWithoutReusableFolders() { assertThat($this->folderDao->isWithoutReusableFolders(array()),is(true)); @@ -140,7 +140,7 @@ public function testIsWithoutReusableFolders() assertThat($this->folderDao->isWithoutReusableFolders(array($filledFolder,$emptyFolder)),is(false)); } - + public function testGetFolderChildFolders() { $this->folderDao->ensureTopLevelFolder(); @@ -149,7 +149,7 @@ public function testGetFolderChildFolders() $this->folderDao->insertFolder('C', '/C', FolderDao::TOP_LEVEL); assertThat($this->folderDao->getFolderChildFolders(FolderDao::TOP_LEVEL),is(arrayWithSize(2))); } - + public function testMoveContent() { $this->folderDao->ensureTopLevelFolder(); @@ -160,7 +160,7 @@ public function testMoveContent() $this->folderDao->moveContent($fc['foldercontents_pk'], FolderDao::TOP_LEVEL); assertThat($this->folderDao->getFolderChildFolders(FolderDao::TOP_LEVEL),is(arrayWithSize(2))); } - + /** * @expectedException Exception */ @@ -173,7 +173,7 @@ public function testMoveContentShouldFailIfCyclesAreProduced() array($folderA),__METHOD__.'.needs.the.foldercontent_pk'); $this->folderDao->moveContent($fc['foldercontents_pk'], $folderB); } - + public function testCopyContent() { $this->folderDao->ensureTopLevelFolder(); @@ -186,7 +186,7 @@ public function testCopyContent() assertThat($this->folderDao->getFolderChildFolders($folderA),is(arrayWithSize(1))); assertThat($this->folderDao->getFolderChildFolders(FolderDao::TOP_LEVEL),is(arrayWithSize(3))); } - + public function testGetRemovableContents() { $this->folderDao->ensureTopLevelFolder(); @@ -199,7 +199,7 @@ public function testGetRemovableContents() $this->dbManager->insertTableRow('foldercontents',array('foldercontents_mode'=> FolderDao::MODE_FOLDER,'parent_fk'=>$folderA,'child_id'=>$folderC)); assertThat($this->folderDao->getRemovableContents($folderA),arrayWithSize(1)); } - + public function testGetFolder() { $this->folderDao->ensureTopLevelFolder(); diff --git a/src/lib/php/Dao/test/LicenseDaoTest.php b/src/lib/php/Dao/test/LicenseDaoTest.php index 799b03ca51..1a807300ea 100644 --- a/src/lib/php/Dao/test/LicenseDaoTest.php +++ b/src/lib/php/Dao/test/LicenseDaoTest.php @@ -24,7 +24,6 @@ use Fossology\Lib\Data\LicenseMatch; use Fossology\Lib\Data\LicenseRef; use Fossology\Lib\Data\Tree\ItemTreeBounds; -use Fossology\Lib\Db\DbManager; use Fossology\Lib\Test\TestPgDb; class LicenseDaoTest extends \PHPUnit\Framework\TestCase diff --git a/src/lib/php/Dao/test/ShowJobsDaoTest.php b/src/lib/php/Dao/test/ShowJobsDaoTest.php index cb31829441..d8bc896be8 100644 --- a/src/lib/php/Dao/test/ShowJobsDaoTest.php +++ b/src/lib/php/Dao/test/ShowJobsDaoTest.php @@ -1,7 +1,7 @@ uploadPermissionDao = M::mock('Fossology\Lib\Dao\UploadPermissionDao'); $this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermissionDao); $this->showJobsDao = new ShowJobsDao($this->dbManager, $this->uploadDao); - + $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); } @@ -86,7 +86,7 @@ protected function tearDown() $this->testDb = null; $this->dbManager = null; } - + public function testUploads2Jobs() @@ -106,7 +106,7 @@ public function testUploads2Jobs() $jobsWithUploadFour = $showJobDao->uploads2Jobs(array(4)); assertThat($jobsWithUploadFour, is(emptyArray())); } - + public function testUploads2JobsPaged() { $jobs = array_combine(range(3,13),range(3,13)); @@ -115,7 +115,7 @@ public function testUploads2JobsPaged() } $uploadDao = M::mock('Fossology\Lib\Dao\UploadDao'); $showJobDao = new ShowJobsDao($this->dbManager,$uploadDao); - + $jobsPage1 = $showJobDao->uploads2Jobs(range(1,17),0); assertThat($jobsPage1, arrayWithSize(10)); $jobsPage2 = $showJobDao->uploads2Jobs(array_combine(range(10,16),range(11,17)),1); @@ -123,7 +123,7 @@ public function testUploads2JobsPaged() $jobsPage3 = $showJobDao->uploads2Jobs(array(),2); assertThat($jobsPage3, arrayWithSize(0)); } - + public function testgetJobName() { @@ -133,7 +133,7 @@ public function testgetJobName() $testJobNameIfNothingQueued = $this->showJobsDao->getJobName($uploadId = 3); assertThat($testJobNameIfNothingQueued, equalTo($uploadId)); } - + public function testMyJobs() { $groupId = 2; @@ -153,7 +153,7 @@ public function testMyJobs() $testOutdatedJobs = $this->showJobsDao->myJobs(true); assertThat($testOutdatedJobs,equalTo(array(2))); } - + public function testgetNumItemsPerSec() { $numSecs = 30; @@ -169,7 +169,7 @@ public function testGetJobInfo() $this->dbManager->prepare($stmt = 'insert.jobqueue', "INSERT INTO jobqueue (jq_pk, jq_job_fk, jq_type, jq_args, jq_starttime, jq_endtime, jq_endtext, jq_end_bits, jq_schedinfo, jq_itemsprocessed)" . "VALUES ($1, $2, $3, $4,$5, $6,$7,$8,$9,$10)"); - + $nowTime = time(); $diffTime = 2345; $nomosTime = date('Y-m-d H:i:sO',$nowTime-$diffTime); @@ -179,7 +179,7 @@ public function testGetJobInfo() { $this->dbManager->freeResult($this->dbManager->execute($stmt, $uploadEntry)); } - + $this->dbManager->prepare($stmt = 'insert.uploadtree_a', "INSERT INTO uploadtree_a (uploadtree_pk, parent, upload_fk, pfile_fk, ufile_mode, lft, rgt, ufile_name)" . "VALUES ($1, $2, $3, $4,$5, $6, $7, $8)"); @@ -219,14 +219,14 @@ public function testGetJobInfo() $hourMinSec = explode(':', $formattedEstimatedTime); assertThat($hourMinSec[0]*3600+$hourMinSec[1]*60+$hourMinSec[2], is(closeTo(($itemCount-$itemNomos)/$testFilesPerSec,0.5+$testFilesPerSec))); - + $testGetEstimatedTime = $this->showJobsDao->getEstimatedTime($job_pk=1, $jq_Type, 0); assertThat($testGetEstimatedTime, matchesPattern ('/\\d+:\\d{2}:\\d{2}/')); $hourMinSec = explode(':', $testGetEstimatedTime); $tolerance = 0.5+($itemCount-$itemNomos)/$itemNomos+(time()-$nowTime); assertThat($hourMinSec[0]*3600+$hourMinSec[1]*60+$hourMinSec[2], is(closeTo(($itemCount-$itemNomos)/$itemNomos*$diffTime,$tolerance))); - + $fewFilesPerSec = 0.003; $formattedLongTime = $this->showJobsDao->getEstimatedTime($job_pk=1, $jq_Type="nomos", $fewFilesPerSec); assertThat($formattedLongTime, matchesPattern ('/\\d+:\\d{2}:\\d{2}/')); @@ -234,13 +234,13 @@ public function testGetJobInfo() assertThat($hourMinSec[0]*3600+$hourMinSec[1]*60+$hourMinSec[2], is(closeTo(($itemCount-$itemNomos)/$fewFilesPerSec,0.5+$fewFilesPerSec))); } - + public function testGetEstimatedTimeShouldNotDivideByZero() { $this->dbManager->prepare($stmt = 'insert.jobqueue', "INSERT INTO jobqueue (jq_pk, jq_job_fk, jq_type, jq_args, jq_starttime, jq_endtime, jq_endtext, jq_end_bits, jq_schedinfo, jq_itemsprocessed)" . "VALUES ($1, $2, $3, $4,$5, $6,$7,$8,$9,$10)"); - + $nowTime = time(); $diffTime = 2345; $nomosTime = date('Y-m-d H:i:sO',$nowTime-$diffTime); @@ -250,7 +250,7 @@ public function testGetEstimatedTimeShouldNotDivideByZero() { $this->dbManager->freeResult($this->dbManager->execute($stmt, $uploadEntry)); } - + $showJobsDaoMock = M::mock('Fossology\\Lib\\Dao\\ShowJobsDao[getNumItemsPerSec]',array($this->dbManager, $this->uploadDao)); $showJobsDaoMock->shouldReceive('getNumItemsPerSec')->andReturn(0); diff --git a/src/lib/php/Dao/test/TreeDaoTest.php b/src/lib/php/Dao/test/TreeDaoTest.php index f0d24a7094..a6c19fa4df 100644 --- a/src/lib/php/Dao/test/TreeDaoTest.php +++ b/src/lib/php/Dao/test/TreeDaoTest.php @@ -53,22 +53,22 @@ protected function setUp() protected function tearDown() { $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); - + $this->testDb = null; $this->dbManager = null; } - + public function testGetMinimalCoveringItem() { $this->prepareModularTable(array()); $coverContainer = $this->treeDao->getMinimalCoveringItem(1, "uploadtree"); assertThat($coverContainer,equalTo(5)); - + $this->prepareUploadTree(array(array($item=99,null,$upload=32,88,0x0,1,2,'plainFile',null))); $coverSelf = $this->treeDao->getMinimalCoveringItem($upload, "uploadtree"); assertThat($coverSelf,equalTo($item)); } - + public function testGetFullPathFromSingleFolderUpload() { $this->prepareModularTable(array(array(6,5,1,0,0,5,6,$fName="file",5))); @@ -257,7 +257,7 @@ public function testGetFullPathWithComlpexStructureFromFileAndOtherUpload() assertThat($this->treeDao->getFullPath(3665, "uploadtree"), equalTo("uploadDaoTest.tar/uploadDaoTest/L/L2/L2a")); assertThat($this->treeDao->getFullPath(3665, "uploadtree",0,true), equalTo( "uploadDaoTest/L/L2/L2a")); } - + public function testGetUploadHashes() { $this->testDb->createPlainTables(array('pfile')); diff --git a/src/lib/php/Dao/test/UploadDaoTest.php b/src/lib/php/Dao/test/UploadDaoTest.php index 7970eb6253..2628c4394f 100644 --- a/src/lib/php/Dao/test/UploadDaoTest.php +++ b/src/lib/php/Dao/test/UploadDaoTest.php @@ -52,7 +52,7 @@ protected function setUp() $logger->shouldReceive('debug'); $uploadPermissionDao = M::mock('Fossology\Lib\Dao\UploadPermissionDao'); $this->uploadDao = new UploadDao($this->dbManager, $logger, $uploadPermissionDao); - + $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); } @@ -410,22 +410,22 @@ public function testGetPreviousFull() $previousItem = $this->uploadDao->getPreviousItem(32, $previousId); assertThat($previousItem, is(nullValue())); } - - + + public function testCountNonArtifactDescendants() { $this->dbManager->queryOnce('ALTER TABLE uploadtree RENAME TO uploadtree_a'); $this->testDb->insertData(array('uploadtree_a')); - + $artifact = new ItemTreeBounds(2,'uploadtree_a', 1, 2, 3); $artifactDescendants = $this->uploadDao->countNonArtifactDescendants($artifact); assertThat($artifactDescendants, is(0)); - + $zip = new ItemTreeBounds(1,'uploadtree_a', 1, 1, 24); $zipDescendants = $this->uploadDao->countNonArtifactDescendants($zip); assertThat($zipDescendants, is(count(array(6,7,8,10,11,12)) ) ); } - + public function testGetUploadParent() { @@ -433,7 +433,7 @@ public function testGetUploadParent() $topId = $this->uploadDao->getUploadParent(32); assertThat($topId,equalTo(3650)); } - + /** @expectedException \Exception * @expectedExceptionMessage Missing upload tree parent for upload */ @@ -442,7 +442,7 @@ public function testGetUploadParentFromBrokenTree() $this->prepareUploadTree(array(array(4651, 3650, 33, 0, 805323776, 2, 75, 'artifact.dir'))); $this->uploadDao->getUploadParent(33); } - + /** @expectedException \Exception * @expectedExceptionMessage Missing upload tree parent for upload */ @@ -450,7 +450,7 @@ public function testGetUploadParentFromNonExistingTree() { $this->uploadDao->getUploadParent(34); } - + public function testGetUploadHashes() { $this->testDb->createPlainTables(array('pfile')); @@ -460,7 +460,7 @@ public function testGetUploadHashes() $hashes = $this->uploadDao->getUploadHashes(2); assertThat($hashes,equalTo(array('md5'=>'F703E0197FB6C5BD0C8DFDCC115A0231','sha1'=>'5DAFC9C82988A81413B995210B668CF5CF5975FF'))); } - + public function testGetFatItem() { $this->prepareUploadTree($this->getTestFileStructure()); @@ -468,18 +468,18 @@ public function testGetFatItem() $itemM1a = 13655; $this->prepareUploadTree(array(array($itemM1a, 3655, 32, 0, $isContainer, 39+0, 40-0, 'M1a'))); $this->dbManager->queryOnce('UPDATE uploadtree SET realparent=parent WHERE ufile_mode&(1<<28)=0',__METHOD__.'.fixRealparent'); - + $fatA = $this->uploadDao->getFatItemId($itemA=3653, 32, 'uploadtree'); assertThat($fatA,equalTo($itemA)); $fatB = $this->uploadDao->getFatItemId($itemBEmpty=3663, 32, 'uploadtree'); assertThat($fatB, equalTo($itemBEmpty)); $fatD = $this->uploadDao->getFatItemId($itemDFolder=3682, 32, 'uploadtree'); - assertThat($fatD, equalTo($itemDFolder)); + assertThat($fatD, equalTo($itemDFolder)); $fatL1 = $this->uploadDao->getFatItemId($itemL1ToFolder=3666, 32, 'uploadtree'); - assertThat($fatL1, equalTo(3667)); + assertThat($fatL1, equalTo(3667)); $fatL2 = $this->uploadDao->getFatItemId($itemL2ToItem=3664, 32, 'uploadtree'); assertThat($fatL2, equalTo(3665)); - + $fatM = $this->uploadDao->getFatItemId(3654, 32, 'uploadtree'); assertThat($fatM, equalTo($itemM1a)); } diff --git a/src/lib/php/Dao/test/UploadPermissionDaoTest.php b/src/lib/php/Dao/test/UploadPermissionDaoTest.php index e708e09934..8ef5a68d89 100644 --- a/src/lib/php/Dao/test/UploadPermissionDaoTest.php +++ b/src/lib/php/Dao/test/UploadPermissionDaoTest.php @@ -51,7 +51,7 @@ protected function setUp() $logger = M::mock('Monolog\Logger'); // new Logger("UploadDaoTest"); $logger->shouldReceive('debug'); $this->uploadPermissionDao = new UploadPermissionDao($this->dbManager, $logger); - + $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); } @@ -61,7 +61,7 @@ protected function tearDown() $this->testDb = null; $this->dbManager = null; } - + public function testmakeAccessibleToGroup() { $this->testDb->createPlainTables(array('perm_upload','group_user_member')); @@ -70,21 +70,21 @@ public function testmakeAccessibleToGroup() $groupIdAlternative = 602; $this->dbManager->insertTableRow('group_user_member', array('group_fk'=>$groupId,'user_fk'=>$userId,'group_perm'=>Auth::PERM_READ)); $this->dbManager->insertTableRow('group_user_member', array('group_fk'=>$groupIdAlternative,'user_fk'=>$userId,'group_perm'=>Auth::PERM_READ)); - + $unaccessibleIsAccessible = $this->uploadPermissionDao->isAccessible($uploadId=1, $groupId); assertThat($unaccessibleIsAccessible,equalTo(false)); - + $this->uploadPermissionDao->makeAccessibleToGroup($uploadId, $groupId, Auth::PERM_WRITE); $accessibleIsAccessible = $this->uploadPermissionDao->isAccessible($uploadId, $groupId); assertThat($accessibleIsAccessible,equalTo(true)); $stillUnaccessibleIsAccessible = $this->uploadPermissionDao->isAccessible($uploadId, $groupIdAlternative); assertThat($stillUnaccessibleIsAccessible,equalTo(false)); - + $this->uploadPermissionDao->makeAccessibleToAllGroupsOf($uploadId, $userId); $nowAccessibleIsAccessible = $this->uploadPermissionDao->isAccessible($uploadId, $groupIdAlternative); assertThat($nowAccessibleIsAccessible,equalTo(true)); } - + public function testDeletePermissionId() { $this->testDb->createPlainTables(array('perm_upload')); @@ -95,7 +95,7 @@ public function testDeletePermissionId() $accessibleAfter = $this->uploadPermissionDao->isAccessible($uploadId, $groupId); assertThat($accessibleAfter,equalTo(false)); } - + public function testUpdatePermissionId() { $this->testDb->createPlainTables(array('perm_upload')); @@ -123,14 +123,14 @@ public function testInsertPermission() $accessibleNomore = $this->uploadPermissionDao->isAccessible($uploadId, $groupId); assertThat($accessibleNomore,equalTo(false)); } - + public function testGetPublicPermission() { $this->testDb->insertData(array('upload')); $perm = $this->uploadPermissionDao->getPublicPermission(3); assertThat($perm,equalTo(0)); } - + public function testGetPermissionGroups() { $this->testDb->createPlainTables(array('perm_upload','groups')); @@ -138,16 +138,16 @@ public function testGetPermissionGroups() $permissionGroups = $this->uploadPermissionDao->getPermissionGroups(1); assertThat($permissionGroups,is(array(2=>array('perm_upload_pk'=>1, 'perm'=>10, 'group_pk'=>2, 'group_name'=>'fossy')))); } - + public function testAccessibilityViaNone() { $this->testDb->createPlainTables(array('perm_upload','groups')); $this->testDb->insertData(array('groups')); - $_SESSION[Auth::USER_LEVEL] = Auth::PERM_NONE; + $_SESSION[Auth::USER_LEVEL] = Auth::PERM_NONE; $accessibilityWithBadGroup = $this->uploadPermissionDao->isAccessible($uploadId=2, $groupId=2); assertThat($accessibilityWithBadGroup, equalTo(false)); } - + public function testAccessibilityViaGroup() { $this->testDb->createPlainTables(array('perm_upload','groups')); @@ -156,8 +156,8 @@ public function testAccessibilityViaGroup() $accessibilityByGroup = $this->uploadPermissionDao->isAccessible($uploadId=2, $groupId=2); assertThat($accessibilityByGroup, equalTo(true)); } - - + + public function testAccessibilityViaPublicForUnqualifiedUser() { $this->testDb->createPlainTables(array('perm_upload','groups')); @@ -170,7 +170,7 @@ public function testAccessibilityViaPublicForUnqualifiedUser() $accessibilityByPublic = $this->uploadPermissionDao->isAccessible($uploadId, $groupId); assertThat($accessibilityByPublic, equalTo(false)); } - + public function testAccessibilityViaPublicForQualifiedUser() { $this->testDb->createPlainTables(array('perm_upload','groups')); diff --git a/src/lib/php/Dao/test/UserDaoTest.php b/src/lib/php/Dao/test/UserDaoTest.php index 41d57e3611..3a9af1fd04 100644 --- a/src/lib/php/Dao/test/UserDaoTest.php +++ b/src/lib/php/Dao/test/UserDaoTest.php @@ -44,7 +44,7 @@ protected function setUp() $this->userDao = new UserDao($this->dbManager, $this->logger); $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); } - + protected function tearDown() { $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); @@ -56,11 +56,11 @@ public function testGetUserGroupMap() { $this->testDb->createPlainTables(array('groups','group_user_member')); $this->testDb->insertData(array('groups','group_user_member')); - + $defaultGroups = $this->userDao->getUserGroupMap($userId=1); assertThat($defaultGroups, equalTo(array(1=>'Default User'))); } - + public function testGetAdminGroupMap() { $this->testDb->createPlainTables(array('groups','group_user_member')); @@ -70,8 +70,8 @@ public function testGetAdminGroupMap() $defaultGroups = $this->userDao->getAdminGroupMap($userId=2,$userLevel=PLUGIN_DB_ADMIN); assertThat($defaultGroups, equalTo(array(1=>'Default User',2=>'fossy'))); } - - + + public function testGetDeletableAdminGroupMap() { $this->testDb->createPlainTables(array('groups','group_user_member','users')); @@ -89,10 +89,10 @@ public function testGetDeletableAdminGroupMap() $groups = $this->userDao->getDeletableAdminGroupMap($userId); assertThat($groups, equalTo(array($deletable['group_pk']=>$deletable['group_name']))); - + $groupsAsForeign = $this->userDao->getDeletableAdminGroupMap($userId+1); assertThat($groupsAsForeign, equalTo(array())); - } + } public function testAddGroup() { @@ -102,7 +102,7 @@ public function testAddGroup() $row = $this->dbManager->getSingleRow('SELECT group_name FROM groups WHERE group_pk=$1',array($groupId)); assertThat($row['group_name'], equalTo($groupName)); } - + /** * @expectedException \Exception */ @@ -122,7 +122,7 @@ public function testAddGroupFailEmptyName() $this->testDb->insertData(array('groups','user')); $this->userDao->addGroup(''); } - + public function testGetUserName() { $username = 'testi'; @@ -132,7 +132,7 @@ public function testGetUserName() $uName = $this->userDao->getUserName($userId); assertThat($uName,equalTo($username)); } - + /** * @expectedException \Exception * @expectedExceptionMessage unknown user with id=101 @@ -142,7 +142,7 @@ public function testGetUserNameFail() $this->testDb->createPlainTables(array('users')); $this->userDao->getUserName(101); } - + public function testGetGroupIdByName() { $this->testDb->createPlainTables(array('groups')); @@ -150,7 +150,7 @@ public function testGetGroupIdByName() $groupId = $this->userDao->getGroupIdByName('fossy'); assertThat($groupId,equalTo(2)); } - + public function testAddGroupMembership() { $this->testDb->createPlainTables(array('users','groups','group_user_member')); diff --git a/src/lib/php/Data/Clearing/test/ClearingResultTest.php b/src/lib/php/Data/Clearing/test/ClearingResultTest.php index 02c9f361d0..1ece79e80b 100644 --- a/src/lib/php/Data/Clearing/test/ClearingResultTest.php +++ b/src/lib/php/Data/Clearing/test/ClearingResultTest.php @@ -35,7 +35,7 @@ class ClearingResultTest extends \PHPUnit\Framework\TestCase private $agentClearingEvent2; /** @var ClearingResult */ private $licenseDecisionResult; - + protected function setUp() { @@ -44,7 +44,7 @@ protected function setUp() $this->agentClearingEvent1 = M::mock(AgentClearingEvent::class); $this->agentClearingEvent2 = M::mock(AgentClearingEvent::class); - + $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); } @@ -83,7 +83,7 @@ public function testGetLicenseRefFromClearingEvent() $this->licenseDecisionResult = new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1)); assertThat($this->licenseDecisionResult->getLicenseRef(), is($this->licenseRef)); } - + public function testGetLicenseRefFromAgentEvents() { $this->agentClearingEvent1->shouldReceive("getLicenseRef")->once()->andReturn($this->licenseRef); @@ -99,7 +99,7 @@ public function testGetLicenseIdFromClearingEvent() assertThat($this->licenseDecisionResult->getLicenseId(), is($licenseId)); } - + public function testGetLicenseIdFromAgentEvent() { $licenseId = 123; @@ -107,7 +107,7 @@ public function testGetLicenseIdFromAgentEvent() $this->licenseDecisionResult = new ClearingResult(null, array($this->agentClearingEvent1)); assertThat($this->licenseDecisionResult->getLicenseId(), is($licenseId)); } - + public function testGetLicenseShortName() { $licenseShortName = ""; @@ -131,7 +131,7 @@ public function testGetCommentWithClearingEvent() $this->licenseDecisionResult = new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1)); assertThat($this->licenseDecisionResult->getComment(), is($comment)); } - + public function testGetCommentWithoutClearingEvent() { $comment = ""; @@ -155,7 +155,7 @@ public function testGetAcknowledgementWithClearingEvent() $this->licenseDecisionResult = new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1)); assertThat($this->licenseDecisionResult->getAcknowledgement(), is($acknowledgement)); } - + public function testGetReportInfoWithoutClearingEvent() { $reportInfo = ""; @@ -208,7 +208,7 @@ public function testGetLicenseIdWithClearingEvent() $this->licenseDecisionResult = new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1)); assertThat($this->licenseDecisionResult->getLicenseId(), is($licenseId)); } - + public function testGetLicenseIdWithoutClearingEvent() { $licenseId = 123; diff --git a/src/lib/php/Data/Folder/test/FolderTest.php b/src/lib/php/Data/Folder/test/FolderTest.php index 623e6d6849..292c88bd3d 100644 --- a/src/lib/php/Data/Folder/test/FolderTest.php +++ b/src/lib/php/Data/Folder/test/FolderTest.php @@ -18,7 +18,6 @@ namespace Fossology\Lib\Data\Folder; - class FolderTest extends \PHPUnit\Framework\TestCase { /** @var int */ diff --git a/src/lib/php/Data/Package/test/PackageTest.php b/src/lib/php/Data/Package/test/PackageTest.php index 61cda2a291..5e824d257d 100644 --- a/src/lib/php/Data/Package/test/PackageTest.php +++ b/src/lib/php/Data/Package/test/PackageTest.php @@ -21,7 +21,6 @@ use Fossology\Lib\Data\Upload\Upload; use Mockery as M; - class PackageTest extends \PHPUnit\Framework\TestCase { private $id = 123; diff --git a/src/lib/php/Data/Upload/test/UploadTest.php b/src/lib/php/Data/Upload/test/UploadTest.php index f2acf5b02d..eefc31a672 100644 --- a/src/lib/php/Data/Upload/test/UploadTest.php +++ b/src/lib/php/Data/Upload/test/UploadTest.php @@ -18,7 +18,6 @@ namespace Fossology\Lib\Data\Upload; - class UploadTest extends \PHPUnit\Framework\TestCase { /** @var int */ @@ -38,7 +37,7 @@ protected function setUp() { $this->timestamp = time(); $this->upload = new Upload($this->id, $this->fileName, $this->description, $this->treeTableName, $this->timestamp); - + $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); } diff --git a/src/lib/php/Data/test/ClearingDecisionBuilderTest.php b/src/lib/php/Data/test/ClearingDecisionBuilderTest.php index a36b722b48..b052be06f5 100644 --- a/src/lib/php/Data/test/ClearingDecisionBuilderTest.php +++ b/src/lib/php/Data/test/ClearingDecisionBuilderTest.php @@ -88,7 +88,7 @@ protected function tearDown() public function testSameFolder() { - $clearingDec =$this->clearingDecisionBuilder + $clearingDec =$this->clearingDecisionBuilder ->setSameFolder($this->sameFolder) ->build(); assertThat($clearingDec->getSameFolder(), is($this->sameFolder)); @@ -105,16 +105,16 @@ public function testClearingLicenses() public function testPositiveLicenses() { $addedLic = M::mock(LicenseRef::class); - + $addedClearingLic = M::mock(ClearingLicense::class); $addedClearingLic->shouldReceive('isRemoved')->withNoArgs()->andReturn(false); $addedClearingLic->shouldReceive('getLicenseRef')->withNoArgs()->andReturn($addedLic); - + $removedClearingLic = M::mock(ClearingLicense::class); $removedClearingLic->shouldReceive('isRemoved')->andReturn(true); $removedClearingEvent = M::mock(ClearingEvent::class); - + $this->clearingEvent->shouldReceive('getClearingLicense')->andReturn($addedClearingLic); $removedClearingEvent->shouldReceive('getClearingLicense')->andReturn($removedClearingLic); diff --git a/src/lib/php/Data/test/LicenseMatchTest.php b/src/lib/php/Data/test/LicenseMatchTest.php index c0f77aaeb4..0655f43a4b 100644 --- a/src/lib/php/Data/test/LicenseMatchTest.php +++ b/src/lib/php/Data/test/LicenseMatchTest.php @@ -63,7 +63,7 @@ protected function setUp() $this->licenseFileId = 12; $this->licenseMatch = new LicenseMatch($this->fileId, $this->licenseRef, $this->agentRef, $this->licenseFileId, $this->percent); - + $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); } @@ -71,7 +71,7 @@ protected function tearDown() { $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); } - + public function testGetFileId() { assertThat($this->licenseMatch->getFileId(), is($this->fileId)); diff --git a/src/lib/php/Data/test/LicenseTest.php b/src/lib/php/Data/test/LicenseTest.php index b345f7fb71..5ae84448d8 100644 --- a/src/lib/php/Data/test/LicenseTest.php +++ b/src/lib/php/Data/test/LicenseTest.php @@ -19,7 +19,6 @@ namespace Fossology\Lib\Data; - class LicenseTest extends \PHPUnit\Framework\TestCase { /** @var string */ private $text; diff --git a/src/lib/php/Data/test/TextFragmentTest.php b/src/lib/php/Data/test/TextFragmentTest.php index d042759c5e..dad10f788d 100644 --- a/src/lib/php/Data/test/TextFragmentTest.php +++ b/src/lib/php/Data/test/TextFragmentTest.php @@ -18,7 +18,6 @@ namespace Fossology\Lib\Data; - class TextFragmentTest extends \PHPUnit\Framework\TestCase { const START_OFFSET = 10; diff --git a/src/lib/php/Db/test/DbManagerTest.php b/src/lib/php/Db/test/DbManagerTest.php index 3dd3c388c6..8b940f05a1 100644 --- a/src/lib/php/Db/test/DbManagerTest.php +++ b/src/lib/php/Db/test/DbManagerTest.php @@ -39,7 +39,7 @@ function setUp() $this->logger = M::mock('Monolog\\Logger'); $this->logger->shouldReceive('addDebug'); - + // $this->dbManager->setDriver($this->driver); } @@ -60,7 +60,7 @@ function testBeginTransactionTwice() $this->dbManager->begin(); $this->dbManager->begin(); } - + /** * @expectedException \Exception */ @@ -69,7 +69,7 @@ function testCommitTransaction() $this->driver->shouldReceive("commit")->withNoArgs()->never(); $this->dbManager->commit(); } - + function testBeginAndCommitTransaction() { $this->driver->shouldReceive("begin")->withNoArgs()->once(); @@ -77,34 +77,34 @@ function testBeginAndCommitTransaction() $this->driver->shouldReceive("commit")->withNoArgs()->once(); $this->dbManager->commit(); } - + abstract function testInsertTableRow(); - + function testFlushStats() { $this->driver->shouldReceive('prepare'); $sqlStmt = 'foo'; $this->dbManager->prepare($sqlStmt,'SELECT elephant FROM africa'); - $this->logger->shouldReceive('addDebug')->with("/executing '$sqlStmt' took /"); + $this->logger->shouldReceive('addDebug')->with(matchesPattern("/executing '$sqlStmt' took /")); $this->dbManager->flushStats(); } - + abstract function testCreateMap(); - + function testExistsDb_no() { - $this->driver->shouldReceive('existsTable')->with('/dTable/')->andReturn(FALSE); + $this->driver->shouldReceive('existsTable')->with(matchesPattern('/dTable/'))->andReturn(FALSE); $existsTable = $this->dbManager->existsTable('badTable'); assertThat($existsTable, is(FALSE)); } - + function testExistsDb_yes() { - $this->driver->shouldReceive('existsTable')->with('/dTable/')->andReturn(TRUE); + $this->driver->shouldReceive('existsTable')->with(matchesPattern('/dTable/'))->andReturn(TRUE); $existsTable = $this->dbManager->existsTable('goodTable'); assertThat($existsTable, is(TRUE)); } - + /** * @expectedException \Exception */ @@ -112,7 +112,7 @@ function testExistsDb_hack() { $this->dbManager->existsTable("goodTable' OR 3<'4"); } - + function testInsertTableRowReturning() { $this->driver->shouldReceive('query'); diff --git a/src/lib/php/Db/test/ModernDbManagerTest.php b/src/lib/php/Db/test/ModernDbManagerTest.php index 9641df7e45..02d6892f60 100644 --- a/src/lib/php/Db/test/ModernDbManagerTest.php +++ b/src/lib/php/Db/test/ModernDbManagerTest.php @@ -33,7 +33,7 @@ function tearDown() { parent::tearDown(); } - + function testInsertTableRow() { $tableName = 'foo'; @@ -45,7 +45,7 @@ function testInsertTableRow() $this->driver->shouldReceive('freeResult'); $this->dbManager->insertTableRow($tableName,$assocParams,$sqlLog); } - + function testCreateMap() { $keyColumn = 'yek'; @@ -53,7 +53,7 @@ function testCreateMap() $tableName = 'foo'; $sqlLog = 'bar'; $preSql = "/ $keyColumn, *$valueColumn /"; - $this->driver->shouldReceive('prepare')->with($sqlLog,$preSql)->once(); + $this->driver->shouldReceive('prepare')->with($sqlLog,matchesPattern($preSql))->once(); $this->driver->shouldReceive('execute')->andReturn('fakeRes'); $this->driver->shouldReceive('fetchArray')->andReturn( array($keyColumn=>'k0',$valueColumn=>'v0'), @@ -65,5 +65,5 @@ function testCreateMap() assertThat($map,hasKey('k0')); assertThat($map,EqualTo(array('k0'=>'v0','k1'=>'v1'))); } - -} \ No newline at end of file + +} \ No newline at end of file diff --git a/src/lib/php/Html/test/LinkElementTest.php b/src/lib/php/Html/test/LinkElementTest.php index 1538bd40bb..bf024d56cf 100644 --- a/src/lib/php/Html/test/LinkElementTest.php +++ b/src/lib/php/Html/test/LinkElementTest.php @@ -19,7 +19,6 @@ namespace Fossology\Lib\Html; - class LinkElementTest extends \PHPUnit\Framework\TestCase { public function testLinkElement() diff --git a/src/lib/php/Html/test/SimpleElementTest.php b/src/lib/php/Html/test/SimpleElementTest.php index fc688270ba..8d4061ac22 100644 --- a/src/lib/php/Html/test/SimpleElementTest.php +++ b/src/lib/php/Html/test/SimpleElementTest.php @@ -19,7 +19,6 @@ namespace Fossology\Lib\Html; - class SimpleHtmlElementTest extends \PHPUnit\Framework\TestCase { diff --git a/src/lib/php/Plugin/test/DefaultPluginTest.php b/src/lib/php/Plugin/test/DefaultPluginTest.php index 97b445578f..4e6daf80d3 100644 --- a/src/lib/php/Plugin/test/DefaultPluginTest.php +++ b/src/lib/php/Plugin/test/DefaultPluginTest.php @@ -18,18 +18,16 @@ namespace Fossology\Lib\Plugin; - use Exception; use Fossology\Lib\Auth\Auth; use Fossology\Lib\UI\Component\Menu; use Fossology\Lib\UI\Component\MicroMenu; use Monolog\Logger; use Symfony\Component\DependencyInjection\Container; -use Mockery as M; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Session; - +use Mockery as M; class TestPlugin extends DefaultPlugin { @@ -207,7 +205,7 @@ public function testSessionIsWrappedInRequest() { assertThat($request->getSession(), is($this->session)); } - + public function testIsLoggedIn() { global $_SESSION; @@ -220,4 +218,4 @@ public function testIsLoggedIn() $this->addToAssertionCount(3); } } - + diff --git a/src/lib/php/Proxy/test/DbViewProxyTest.php b/src/lib/php/Proxy/test/DbViewProxyTest.php index c796f4d07d..536e704537 100644 --- a/src/lib/php/Proxy/test/DbViewProxyTest.php +++ b/src/lib/php/Proxy/test/DbViewProxyTest.php @@ -18,8 +18,8 @@ namespace Fossology\Lib\Proxy; -use Mockery as M; use Fossology\Lib\Db\DbManager; +use Mockery as M; class DbViewProxyTest extends \PHPUnit\Framework\TestCase { @@ -47,7 +47,7 @@ public function testGetDbViewName() { assertThat($this->dbViewDao->getDbViewName(),is($this->dbViewName)); } - + public function testMaterialize() { $this->dbManagerMock->shouldReceive('queryOnce')->with("CREATE TEMPORARY TABLE $this->dbViewName AS $this->dbViewQuery", M::any()); @@ -68,16 +68,16 @@ public function testUnmaterializeAfterMaterialize() $this->dbManagerMock->shouldReceive('queryOnce')->with("DROP TABLE $this->dbViewName"); $this->dbViewDao->unmaterialize(); } - + public function testUnmaterializeWithoutMaterialize() { $this->dbManagerMock->shouldReceive('queryOnce')->never(); $this->dbViewDao->unmaterialize(); - } - + } + public function testAsCTE() { assertThat($this->dbViewDao->asCTE(),is("WITH $this->dbViewName AS (".$this->dbViewQuery.")")); } - + } diff --git a/src/lib/php/Proxy/test/LatestScannerProxyTest.php b/src/lib/php/Proxy/test/LatestScannerProxyTest.php index a4ddb46eff..3f7973d5ff 100644 --- a/src/lib/php/Proxy/test/LatestScannerProxyTest.php +++ b/src/lib/php/Proxy/test/LatestScannerProxyTest.php @@ -21,7 +21,6 @@ use Fossology\Lib\Test\TestLiteDb; use Mockery as M; - class LatestScannerProxyTest extends \PHPUnit\Framework\TestCase { /** @var TestLiteDb */ @@ -29,7 +28,7 @@ class LatestScannerProxyTest extends \PHPUnit\Framework\TestCase /** @var assertCountBefore */ private $assertCountBefore; - + protected function setUp() { $this->testDb = new TestLiteDb(); @@ -45,7 +44,7 @@ protected function tearDown() $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); M::close(); } - + private function getAllColumns($sql,$params=array()) { $backtrace = debug_backtrace(); @@ -54,14 +53,14 @@ private function getAllColumns($sql,$params=array()) $dbManager = &$this->testDb->getDbManager(); $dbManager->prepare($stmt, $sql); - + $res = $dbManager->execute($stmt,$params); $result = $dbManager->fetchAll($res); $dbManager->freeResult($res); return $result; } - + public function testQuery() { $uploadId = 2; @@ -71,7 +70,7 @@ public function testQuery() $scanners = $this->getAllColumns($sql); assertThat($scanners,arrayContaining(array(array('agent_pk'=>6,'agent_name'=>'nomos')))); } - + public function testQueryTwoScanners() { $this->testDb->getDbManager()->queryOnce('CREATE TABLE monk_ars AS SELECT * FROM nomos_ars WHERE 0=1'); @@ -83,7 +82,7 @@ public function testQueryTwoScanners() $scanners = $this->getAllColumns($sql); assertThat($scanners,arrayContainingInAnyOrder(array(array('agent_pk'=>6,'agent_name'=>'nomos'),array('agent_pk'=>5,'agent_name'=>'monk')))); } - + /** * @expectedException \Exception */ @@ -93,7 +92,7 @@ public function testQueryNoScanners() $agentNames = array(); new LatestScannerProxy($uploadId,$agentNames,'latest_scanner', "AND agent_enabled='true'"); } - + public function testQueryPrepared() { $uploadId = 2; @@ -103,7 +102,7 @@ public function testQueryPrepared() $scanners = $this->getAllColumns($sql,array($uploadId)); assertThat($scanners,arrayContaining(array(array('agent_pk'=>6,'agent_name'=>'nomos')))); } - + public function testMaterializePossibleForUnparameterizedQuery() { $uploadId = 2; @@ -111,7 +110,7 @@ public function testMaterializePossibleForUnparameterizedQuery() $latestScannerProxy = new LatestScannerProxy($uploadId,$agentNames,'latest_scanner', "AND agent_enabled='true'"); $latestScannerProxy->materialize(); } - + /** * @expectedException \Exception */ @@ -121,8 +120,8 @@ public function testMaterializeNotPossibleForParameterizedQuery() $latestScannerProxy = new LatestScannerProxy('$1',$agentNames,'latest_scanner', "AND agent_enabled='true'"); $latestScannerProxy->materialize(); } - - + + public function testGetNameToIdMap() { $uploadId = 2; @@ -131,7 +130,7 @@ public function testGetNameToIdMap() $map = $latestScannerProxy->getNameToIdMap(); assertThat($map,equalTo(array('nomos'=>6))); } - + /** * @expectedException \Exception */ @@ -141,5 +140,5 @@ public function testGetNameToIdMapNotPossibleForParameterizedQuery() $latestScannerProxy = new LatestScannerProxy('$1',$agentNames,'latest_scanner', "AND agent_enabled='true'"); $latestScannerProxy->getNameToIdMap(); } - + } diff --git a/src/lib/php/Proxy/test/LicenseViewProxyTest.php b/src/lib/php/Proxy/test/LicenseViewProxyTest.php index 007aa0bbc4..553b8bb840 100644 --- a/src/lib/php/Proxy/test/LicenseViewProxyTest.php +++ b/src/lib/php/Proxy/test/LicenseViewProxyTest.php @@ -18,9 +18,8 @@ namespace Fossology\Lib\Proxy; -use Mockery as M; use Fossology\Lib\Db\DbManager; - +use Mockery as M; class LicenseViewProxyTest extends \PHPUnit\Framework\TestCase { @@ -47,16 +46,16 @@ public function testQueryOnlyLicenseRef() $reflection = new \ReflectionClass(get_class($licenseViewProxy)); $method = $reflection->getMethod('queryOnlyLicenseRef'); $method->setAccessible(true); - + $options1 = array('columns'=>array('rf_pk','rf_shortname')); $query1 = $method->invoke($licenseViewProxy,$options1); assertThat($query1, is("SELECT rf_pk,rf_shortname FROM ONLY license_ref")); - + $options2 = array('extraCondition'=>'rf_pk<100'); $query2 = $method->invoke($licenseViewProxy,$options2); assertThat($query2, is("SELECT $this->almostAllColumns,0 AS group_fk FROM ONLY license_ref WHERE rf_pk<100")); } - + public function testQueryLicenseCandidate() { $groupId = 123; @@ -65,28 +64,28 @@ public function testQueryLicenseCandidate() $reflection = new \ReflectionClass(get_class($licenseViewProxy)); $method = $reflection->getMethod('queryLicenseCandidate'); $method->setAccessible(true); - + $options1 = array('columns'=>array('rf_pk','rf_shortname')); $query1 = $method->invoke($licenseViewProxy,$options1); assertThat($query1, is("SELECT rf_pk,rf_shortname FROM license_candidate WHERE group_fk=$groupId")); - + $options2 = array('extraCondition'=>'rf_pk<100'); $query2 = $method->invoke($licenseViewProxy,$options2); assertThat($query2, is("SELECT $this->almostAllColumns,group_fk FROM license_candidate WHERE group_fk=$groupId AND rf_pk<100")); - + $prefix = '#'; $options3 = array(LicenseViewProxy::CANDIDATE_PREFIX=>$prefix,'columns'=>array('rf_shortname')); $query3 = $method->invoke($licenseViewProxy,$options3); assertThat($query3, is("SELECT '". pg_escape_string($prefix). "'||rf_shortname AS rf_shortname FROM license_candidate WHERE group_fk=$groupId")); } - + public function testConstruct() { $licenseViewProxy0 = new LicenseViewProxy(0); $query0 = $licenseViewProxy0->getDbViewQuery(); $expected0 = "SELECT $this->almostAllColumns,0 AS group_fk FROM ONLY license_ref"; assertThat($query0,is($expected0)); - + $licenseViewProxy123 = new LicenseViewProxy(123,array('diff'=>true)); $query123 = $licenseViewProxy123->getDbViewQuery(); $expected123 = "SELECT $this->almostAllColumns,group_fk FROM license_candidate WHERE group_fk=123"; @@ -97,5 +96,4 @@ public function testConstruct() $expected0123 = "$expected123 UNION $expected0"; assertThat($query0123,is($expected0123)); } - } diff --git a/src/lib/php/Proxy/test/ScanJobProxyTest.php b/src/lib/php/Proxy/test/ScanJobProxyTest.php index 1a5fb99c66..d6b260d736 100644 --- a/src/lib/php/Proxy/test/ScanJobProxyTest.php +++ b/src/lib/php/Proxy/test/ScanJobProxyTest.php @@ -22,7 +22,6 @@ use Fossology\Lib\Data\AgentRef; use Mockery as M; - class ScanJobProxyTest extends \PHPUnit\Framework\TestCase { private $agentDaoMock; @@ -50,10 +49,10 @@ private function prepareScanAgentStatus() $reflection = new \ReflectionClass(get_class($this->scanJobProxy)); $method = $reflection->getMethod('scanAgentStatus'); $method->setAccessible(true); - + return $method; } - + public function testScanAgentStatus() { $method = $this->prepareScanAgentStatus(); @@ -63,7 +62,7 @@ public function testScanAgentStatus() $this->agentDaoMock->shouldReceive('getRunningAgentIds')->never(); $this->agentDaoMock->shouldReceive('getCurrentAgentRef')->with($this->agentName) ->andReturn(new AgentRef($this->agentId, $this->agentName, 'a0815')); - + $vars = $method->invoke($this->scanJobProxy,$this->agentName); assertThat($vars, is(array( 'successfulAgents'=>$successfulAgents, @@ -73,8 +72,8 @@ public function testScanAgentStatus() 'currentAgentRev'=>'a0815' ))); } - - + + public function testScanAgentStatusLatestStillRuns() { $method = $this->prepareScanAgentStatus(); @@ -86,7 +85,7 @@ public function testScanAgentStatusLatestStillRuns() ->andReturn(array($runningAgentId))->once(); $this->agentDaoMock->shouldReceive('getCurrentAgentRef')->with($this->agentName) ->andReturn(new AgentRef($runningAgentId, $this->agentName, 'b1234')); - + $vars = $method->invoke($this->scanJobProxy,$this->agentName); assertThat($vars, is(array( 'successfulAgents'=>$successfulAgents, @@ -97,8 +96,8 @@ public function testScanAgentStatusLatestStillRuns() 'currentAgentRev'=>'b1234' ))); } - - + + public function testScanAgentStatusLatestNotRuns() { $method = $this->prepareScanAgentStatus(); @@ -110,7 +109,7 @@ public function testScanAgentStatusLatestNotRuns() ->andReturn(array())->once(); $this->agentDaoMock->shouldReceive('getCurrentAgentRef')->with($this->agentName) ->andReturn(new AgentRef($runningAgentId, $this->agentName, 'b1234')); - + $vars = $method->invoke($this->scanJobProxy,$this->agentName); assertThat($vars, is(array( 'successfulAgents'=>$successfulAgents, @@ -121,8 +120,8 @@ public function testScanAgentStatusLatestNotRuns() 'currentAgentRev'=>'b1234' ))); } - - + + public function testScanAgentStatusWithoutSuccess() { $method = $this->prepareScanAgentStatus(); @@ -134,7 +133,7 @@ public function testScanAgentStatusWithoutSuccess() ->andReturn(array($runningAgentId))->once(); $this->agentDaoMock->shouldReceive('getCurrentAgentRef')->with($this->agentName) ->andReturn(new AgentRef($runningAgentId, $this->agentName, 'b1234')); - + $vars = $method->invoke($this->scanJobProxy,$this->agentName); assertThat($vars, is(array( 'successfulAgents'=>$successfulAgents, @@ -143,8 +142,8 @@ public function testScanAgentStatusWithoutSuccess() 'isAgentRunning'=>true ))); } - - + + public function testCreateAgentStatus() { $successfulAgents = array(array('agent_id'=>$this->agentId,'agent_rev'=>'a0815','agent_name'=>$this->agentName)); @@ -155,7 +154,7 @@ public function testCreateAgentStatus() ->andReturn(new AgentRef($this->agentId, $this->agentName, 'a0815')); $fakedAgentName = 'ghost'; $this->agentDaoMock->shouldReceive('arsTableExists')->with(M::anyOf($this->agentName,$fakedAgentName))->andReturn(true,false)->twice(); - + $vars = $this->scanJobProxy->createAgentStatus(array($this->agentName,$fakedAgentName)); assertThat($vars, is(array(array( 'successfulAgents'=>$successfulAgents, @@ -165,8 +164,8 @@ public function testCreateAgentStatus() 'currentAgentRev'=>'a0815' )))); } - - + + private function pretendScanAgentStatus($successfulAgents) { $reflection = new \ReflectionObject($this->scanJobProxy); @@ -174,18 +173,18 @@ private function pretendScanAgentStatus($successfulAgents) $prop->setAccessible(true); $prop->setValue($this->scanJobProxy, $successfulAgents); } - + public function testGetAgentMap() { $successfulAgents = array($this->agentName=>array(new AgentRef($this->agentId, $this->agentName, 'a0815'))); $this->pretendScanAgentStatus($successfulAgents); - + $expected = array($this->agentId=>"$this->agentName a0815"); $map = $this->scanJobProxy->getAgentMap(); assertThat($map,is(equalTo($expected))); } - - + + public function testGetLatestSuccessfulAgentIds() { $otherAgentName = 'drinkMe'; @@ -194,12 +193,12 @@ public function testGetLatestSuccessfulAgentIds() new AgentRef($this->agentId-1, $this->agentName, 'beforeA0815')), $otherAgentName=>array(new AgentRef($otherAgentId, $otherAgentName, 'coffee'))); $this->pretendScanAgentStatus($successfulAgents); - + $expected = array($this->agentName=>$this->agentId,$otherAgentName=>$otherAgentId); $ids = $this->scanJobProxy->getLatestSuccessfulAgentIds(); assertThat($ids,is(equalTo($expected))); } - + public function testGetSuccessfulAgents() { $otherAgentName = 'drinkMe'; @@ -208,10 +207,10 @@ public function testGetSuccessfulAgents() new AgentRef($this->agentId-1, $this->agentName, 'beforeA0815')), $otherAgentName=>array(new AgentRef($otherAgentId, $otherAgentName, 'coffee'))); $this->pretendScanAgentStatus($successfulAgents); - + $expected = array_merge($successfulAgents[$this->agentName],$successfulAgents[$otherAgentName]); $ids = $this->scanJobProxy->getSuccessfulAgents(); assertThat($ids,is(equalTo($expected))); } - + } diff --git a/src/lib/php/Proxy/test/UploadBrowseProxyTest.php b/src/lib/php/Proxy/test/UploadBrowseProxyTest.php index 6e3b55d76d..f1d749c274 100644 --- a/src/lib/php/Proxy/test/UploadBrowseProxyTest.php +++ b/src/lib/php/Proxy/test/UploadBrowseProxyTest.php @@ -44,13 +44,13 @@ protected function tearDown() $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); $this->testDb = null; } - + public function testConstructAndSanity() { $uploadBrowseProxy = new UploadBrowseProxy($this->groupId, UserDao::USER, $this->testDb->getDbManager(), true); assertThat($uploadBrowseProxy,is(anInstanceOf(UploadBrowseProxy::class))); } - + public function testUpdateTableStatus() { $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>1,'group_fk'=>$this->groupId, 'status_fk'=> UploadStatus::OPEN)); @@ -59,7 +59,7 @@ public function testUpdateTableStatus() $updatedRow = $this->testDb->getDbManager()->getSingleRow('SELECT status_fk FROM upload_clearing WHERE upload_fk=$1 AND group_fk=$2',array($uploadId,$this->groupId)); assertThat($updatedRow['status_fk'],equalTo($newStatus)); } - + public function testUpdateTableStatusFromRejectByUser() { $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>1,'group_fk'=>$this->groupId, 'status_fk'=> UploadStatus::REJECTED)); @@ -68,7 +68,7 @@ public function testUpdateTableStatusFromRejectByUser() $updatedRow = $this->testDb->getDbManager()->getSingleRow('SELECT status_fk FROM upload_clearing WHERE upload_fk=$1 AND group_fk=$2',array($uploadId,$this->groupId)); assertThat($updatedRow['status_fk'],equalTo(UploadStatus::REJECTED)); } - + public function testUpdateTableStatusByAdvisor() { $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>1,'group_fk'=>$this->groupId, 'status_fk'=> UploadStatus::OPEN)); @@ -77,7 +77,7 @@ public function testUpdateTableStatusByAdvisor() $updatedRow = $this->testDb->getDbManager()->getSingleRow('SELECT status_fk FROM upload_clearing WHERE upload_fk=$1 AND group_fk=$2',array($uploadId,$this->groupId)); assertThat($updatedRow['status_fk'],equalTo($newStatus)); } - + /** * @expectedException \Exception */ @@ -87,7 +87,7 @@ public function testUpdateTableStatusToRejectByUser() $uploadBrowseProxy = new UploadBrowseProxy($this->groupId, UserDao::USER, $this->testDb->getDbManager()); $uploadBrowseProxy->updateTable('status_fk', $uploadId=1, $newStatus=UploadStatus::REJECTED); } - + public function testUpdateTableStatusToRejectByAdvisor() { $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>1,'group_fk'=>$this->groupId, 'status_fk'=> UploadStatus::OPEN)); @@ -96,7 +96,7 @@ public function testUpdateTableStatusToRejectByAdvisor() $updatedRow = $this->testDb->getDbManager()->getSingleRow('SELECT status_fk FROM upload_clearing WHERE upload_fk=$1 AND group_fk=$2',array($uploadId,$this->groupId)); assertThat($updatedRow['status_fk'],equalTo($newStatus)); } - + /** * @expectedException \Exception */ @@ -113,7 +113,7 @@ public function testUpdateTableAssigneeByAdvisor() $updatedRow = $this->testDb->getDbManager()->getSingleRow('SELECT assignee FROM upload_clearing WHERE upload_fk=$1 AND group_fk=$2',array($uploadId,$this->groupId)); assertThat($updatedRow['assignee'],equalTo($newAssignee)); } - + /** * @expectedException \Exception */ @@ -122,53 +122,53 @@ public function testUpdateTableAssigneeForbidden() $uploadBrowseProxy = new UploadBrowseProxy($this->groupId, UserDao::USER, $this->testDb->getDbManager()); $uploadBrowseProxy->updateTable('assignee', 1, 123); } - - + + private function wrapperTestMoveUploadToInfinity($uploadId, $order='DESC') { $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>1,'group_fk'=>$this->groupId, UploadBrowseProxy::PRIO_COLUMN=>1)); $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>2,'group_fk'=>$this->groupId, UploadBrowseProxy::PRIO_COLUMN=>2)); - + $uploadBrowseProxy = new UploadBrowseProxy($this->groupId, UserDao::USER, $this->testDb->getDbManager()); $uploadBrowseProxy->moveUploadToInfinity($uploadId, 'DESC'==$order); - + $updatedRow = $this->testDb->getDbManager()->getSingleRow('SELECT upload_fk FROM upload_clearing WHERE group_fk=$1 ORDER BY '.UploadBrowseProxy::PRIO_COLUMN." $order LIMIT 1",array($this->groupId)); assertThat($updatedRow['upload_fk'],equalTo($uploadId)); - } - + } + public function testMoveUploadToInfinityTop() { $this->wrapperTestMoveUploadToInfinity(1, 'DESC'); - } + } public function testMoveUploadToInfinityDown() { $this->wrapperTestMoveUploadToInfinity(2, 'ASC'); } - - + + private function wrapperTestMoveUploadBeyond($moveUpload=4, $beyondUpload=2, $expectedPrio = 1.5) { $this->testDb->getDbManager()->insertTableRow('upload', array('upload_pk'=>4,'upload_filename'=>'for.all4','user_fk'=>1,'upload_mode'=>1,'public_perm'=>Auth::PERM_READ)); $this->testDb->getDbManager()->insertTableRow('upload', array('upload_pk'=>5,'upload_filename'=>'for.all5','user_fk'=>1,'upload_mode'=>1,'public_perm'=>Auth::PERM_READ)); - + $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>1,'group_fk'=>$this->groupId, UploadBrowseProxy::PRIO_COLUMN=>1)); $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>2,'group_fk'=>$this->groupId, UploadBrowseProxy::PRIO_COLUMN=>2)); $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>4,'group_fk'=>$this->groupId, UploadBrowseProxy::PRIO_COLUMN=>4)); $this->testDb->getDbManager()->insertTableRow('upload_clearing', array('upload_fk'=>5,'group_fk'=>$this->groupId, UploadBrowseProxy::PRIO_COLUMN=>5)); - + $uploadBrowseProxy = new UploadBrowseProxy($this->groupId, UserDao::USER, $this->testDb->getDbManager()); $uploadBrowseProxy->moveUploadBeyond($moveUpload, $beyondUpload); $updatedRow = $this->testDb->getDbManager()->getSingleRow('SELECT '.UploadBrowseProxy::PRIO_COLUMN.' FROM upload_clearing WHERE upload_fk=$1 AND group_fk=$2',array($moveUpload,$this->groupId)); assertThat($updatedRow[UploadBrowseProxy::PRIO_COLUMN],equalTo($expectedPrio)); - + } public function testMoveUploadBeyondDown() { $this->wrapperTestMoveUploadBeyond(4,2,1.5); } - + public function testMoveUploadBeyondUp() { $this->wrapperTestMoveUploadBeyond(2,4,4.5); @@ -178,13 +178,13 @@ public function testMoveUploadBeyondFarDown() { $this->wrapperTestMoveUploadBeyond(4,1,0.5); } - + public function testMoveUploadBeyondFarUp() { $this->wrapperTestMoveUploadBeyond(4,5,5.5); } - + public function testGetFolderPartialQuery() { $this->testDb->createPlainTables(array('foldercontents','uploadtree')); @@ -199,7 +199,7 @@ public function testGetFolderPartialQuery() $row = $this->testDb->getDbManager()->getSingleRow("SELECT count(*) FROM $view", $params); assertThat($row['count'],equalTo(1)); } - + public function testGetFolderPartialQueryWithUserInTwoGoodGroups() { $this->testDb->createPlainTables(array('foldercontents','uploadtree')); @@ -216,8 +216,8 @@ public function testGetFolderPartialQueryWithUserInTwoGoodGroups() $row = $this->testDb->getDbManager()->getSingleRow("SELECT count(*) FROM $view", $params); assertThat($row['count'],equalTo(1)); } - - + + /** * @expectedException \Exception */ @@ -227,7 +227,7 @@ public function testGetFolderPartialQueryWithInvalidParamCount() $params = array(); $uploadBrowseProxy->getFolderPartialQuery($params); } - + public function testGetStatus() { $uploadBrowseProxy = new UploadBrowseProxy($this->groupId, UserDao::USER, $this->testDb->getDbManager()); @@ -236,7 +236,7 @@ public function testGetStatus() $uploadBrowseProxy->updateTable('status_fk', $uploadId, $newStatus=UploadStatus::IN_PROGRESS); assertThat($uploadBrowseProxy->getStatus($uploadId), equalTo($newStatus)); } - + /** * @expectedException \Exception */ diff --git a/src/lib/php/Proxy/test/UploadTreeProxyTest.php b/src/lib/php/Proxy/test/UploadTreeProxyTest.php index 9f506827e2..fe9f34cef5 100644 --- a/src/lib/php/Proxy/test/UploadTreeProxyTest.php +++ b/src/lib/php/Proxy/test/UploadTreeProxyTest.php @@ -41,38 +41,38 @@ protected function tearDown() $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); $this->testDb = null; } - + public function testGetNonArtifactDescendantsWithMaterialize() { $uploadTreeProxy = new UploadTreeProxy($uploadId=1, $options=array(), $uploadTreeTableName='uploadtree_a'); $uploadTreeProxy->materialize(); - + $artifact = new ItemTreeBounds(2,'uploadtree_a', $uploadId, 2, 3); $artifactDescendants = $uploadTreeProxy->getNonArtifactDescendants($artifact); assertThat($artifactDescendants, emptyArray()); - + $zip = new ItemTreeBounds(1,'uploadtree_a', $uploadId, 1, 24); $zipDescendants = $uploadTreeProxy->getNonArtifactDescendants($zip); assertThat(array_keys($zipDescendants), arrayContainingInAnyOrder(array(6,7,8,10,11,12)) ); $uploadTreeProxy->unmaterialize(); } - + public function testGetNonArtifactDescendantsWithoutMaterialize() { $uploadTreeProxy = new UploadTreeProxy($uploadId=1, $options=array(), $uploadTreeTableName='uploadtree_a'); - + $artifact = new ItemTreeBounds(2,'uploadtree_a', $uploadId, 2, 3); $artifactDescendants = $uploadTreeProxy->getNonArtifactDescendants($artifact); assertThat($artifactDescendants, emptyArray()); - + $zip = new ItemTreeBounds(1,'uploadtree_a', $uploadId, 1, 24); $zipDescendants = $uploadTreeProxy->getNonArtifactDescendants($zip); assertThat(array_keys($zipDescendants), arrayContainingInAnyOrder(array(6,7,8,10,11,12)) ); } - + protected function prepareUploadTree($upload=4) - { + { $this->dbManager->prepare($stmt = 'insert.uploadtree', "INSERT INTO uploadtree_a (uploadtree_pk, parent, upload_fk, pfile_fk, ufile_mode, lft, rgt, ufile_name, realparent)" . " VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)"); @@ -90,12 +90,12 @@ protected function prepareUploadTree($upload=4) $this->dbManager->freeResult($this->dbManager->execute($stmt, $itemEntry)); } } - - + + public function testOptionRealParent() { $this->prepareUploadTree($upload=4); - + $uploadTreeProxy = new UploadTreeProxy($upload, $options=array(UploadTreeProxy::OPT_REALPARENT=>301), $uploadTreeTableName='uploadtree_a'); $stmt = __METHOD__; $this->dbManager->prepare($stmt, $uploadTreeProxy->asCTE()." SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName()); @@ -105,7 +105,7 @@ public function testOptionRealParent() $zipDescendants = array_reduce($descendants, function($foo,$bar){$foo[]=$bar['uploadtree_pk'];return $foo;}, array()); assertThat($zipDescendants, equalTo(array(302,305,307,308)) ); } - + public function testOptionRange() { $this->prepareUploadTree($upload=4); @@ -119,7 +119,7 @@ public function testOptionRange() $this->dbManager->freeResult($res); $zipDescendantsA = array_reduce($descendants, function($foo,$bar){$foo[]=$bar['uploadtree_pk'];return $foo;}, array()); assertThat($zipDescendantsA, equalTo(array(303)) ); - + $itemBoundsT = new ItemTreeBounds(301, $uploadTreeTableName='uploadtree_a', $upload, 1, 16); $uploadTreeProxyT = new UploadTreeProxy($upload, array(UploadTreeProxy::OPT_RANGE=>$itemBoundsT), $uploadTreeTableName, 'viewTop'); $stmtT = __METHOD__; @@ -130,11 +130,11 @@ public function testOptionRange() $zipDescendantsT = array_reduce($descendantsT, function($foo,$bar){$foo[]=$bar['uploadtree_pk'];return $foo;}, array()); assertThat($zipDescendantsT, equalTo(array(303,306,307,308)) ); } - + public function testOptionExt() { $this->prepareUploadTree($upload=4); - + $uploadTreeProxy = new UploadTreeProxy($upload, $options=array(UploadTreeProxy::OPT_EXT=>'c'), 'uploadtree_a'); $stmt = __METHOD__; $this->dbManager->prepare($stmt, $uploadTreeProxy->asCTE()." SELECT ufile_name FROM ".$uploadTreeProxy->getDbViewName()); @@ -144,11 +144,11 @@ public function testOptionExt() $zipDescendants = array_reduce($descendants, function($foo,$bar){$foo[]=$bar['ufile_name'];return $foo;}, array()); assertThat($zipDescendants, equalTo(array('fileCDE.c')) ); } - + public function testOptionHead() { $this->prepareUploadTree($upload=4); - + $uploadTreeProxy = new UploadTreeProxy($upload, $options=array(UploadTreeProxy::OPT_HEAD=>'filEc'), 'uploadtree_a'); $stmt = __METHOD__; $this->dbManager->prepare($stmt, $uploadTreeProxy->asCTE()." SELECT ufile_name FROM ".$uploadTreeProxy->getDbViewName()); @@ -158,7 +158,7 @@ public function testOptionHead() $zipDescendants = array_reduce($descendants, function($foo,$bar){$foo[]=$bar['ufile_name'];return $foo;}, array()); assertThat($zipDescendants, equalTo(array('fileCDE.c','fileCF.cpp')) ); } - + public function testOptionScanRefParented() { $this->testDb->createPlainTables( array('license_map','license_file') ); @@ -166,9 +166,9 @@ public function testOptionScanRefParented() $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>103,'agent_fk'=>401)); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>102,'agent_fk'=>402)); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId+1,'pfile_fk'=>101,'agent_fk'=>401)); - + $this->prepareUploadTree($upload=4); - + $itemBoundsT = new ItemTreeBounds(301, $uploadTreeTableName='uploadtree_a', $upload, 1, 16); $options = array(UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_AGENT_SET=>array(401), UploadTreeProxy::OPT_SCAN_REF=>$rfId); $uploadTreeProxy = new UploadTreeProxy($upload, $options, $uploadTreeTableName, 'viewTop'); @@ -180,7 +180,7 @@ public function testOptionScanRefParented() $zipDescendantsT = array_reduce($descendantsT, function($foo,$bar){$foo[]=$bar['pfile_fk'];return $foo;}, array()); assertThat($zipDescendantsT, equalTo(array(103)) ); } - + public function testOptionScanRefRanged() { $this->testDb->createPlainTables( array('license_map','license_file') ); @@ -188,9 +188,9 @@ public function testOptionScanRefRanged() $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>103,'agent_fk'=>401)); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>102,'agent_fk'=>402)); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId+1,'pfile_fk'=>104,'agent_fk'=>401)); - + $this->prepareUploadTree($upload=4); - + $options = array(UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_AGENT_SET=>array(401), UploadTreeProxy::OPT_SCAN_REF=>$rfId); $uploadTreeProxy = new UploadTreeProxy($upload, $options, 'uploadtree_a', 'viewTop'); $stmt = __METHOD__; @@ -201,7 +201,7 @@ public function testOptionScanRefRanged() $zipDescendantsT = array_reduce($descendantsT, function($foo,$bar){$foo[]=$bar['pfile_fk'];return $foo;}, array()); assertThat($zipDescendantsT, equalTo(array(103)) ); } - + protected function insertDecisionEvent($decisionId,$eventId,$rfId,$groupId,$item,$pfileId,$type,$removed,$date) { $this->dbManager->insertTableRow('clearing_decision',array('clearing_decision_pk'=>$decisionId,'pfile_fk'=>$pfileId,'uploadtree_fk'=>$item, @@ -221,20 +221,20 @@ public function testOptionConRefParented() $groupId = 301; $decisionId = 501; $eventId = 601; - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED, 'true', '2015-05-11 12:15'); - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED, 'true', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:15'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::WIP, 'true', '2015-05-11 12:15'); - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 303, 101, DecisionTypes::WIP, 'false', '2015-05-11 12:15'); $this->prepareUploadTree($upload=4); - + $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_CONCLUDE_REF=>$rfId); $uploadTreeProxy = new UploadTreeProxy($upload, $options, $uploadTreeTableName='uploadtree_a', 'viewTop'); $stmt = __METHOD__; @@ -246,7 +246,7 @@ public function testOptionConRefParented() $parentOf306 = 305; assertThat($zipDescendantsT, equalTo(array($parentOf306,308)) ); } - + public function testOptionConRefRanged() { $this->testDb->createPlainTables( array('clearing_decision','clearing_decision_event','clearing_event') ); @@ -255,20 +255,20 @@ public function testOptionConRefRanged() $groupId = 301; $decisionId = 501; $eventId = 601; - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED, 'true', '2015-05-11 12:15'); - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED, 'true', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:15'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::WIP, 'true', '2015-05-11 12:15'); - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 303, 101, DecisionTypes::WIP, 'false', '2015-05-11 12:15'); $this->prepareUploadTree($upload=4); - + $itemBoundsT = new ItemTreeBounds(301, $uploadTreeTableName='uploadtree_a', $upload, 1, 16); $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_CONCLUDE_REF=>$rfId); $uploadTreeProxy = new UploadTreeProxy($upload, $options, $uploadTreeTableName, 'viewTop'); @@ -280,7 +280,7 @@ public function testOptionConRefRanged() $zipDescendantsT = array_reduce($descendantsT, function($foo,$bar){$foo[]=$bar['uploadtree_pk'];return $foo;}, array()); assertThat($zipDescendantsT, equalTo(array(306,308)) ); } - + public function testOptionSkipAlreadyClearedRanged() { $this->testDb->createPlainTables( array('license_file','clearing_decision','clearing_decision_event','clearing_event','license_ref') ); @@ -291,15 +291,15 @@ public function testOptionSkipAlreadyClearedRanged() $eventId = 601; $this->dbManager->insertTableRow('license_ref',array('rf_pk'=>$rfId,'rf_shortname'=>'any_license_found')); - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED, 'true', '2015-05-11 12:13'); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>103,'agent_fk'=>401)); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>104,'agent_fk'=>401)); - + $this->prepareUploadTree($upload=4); - + $itemBoundsT = new ItemTreeBounds(301, $uploadTreeTableName='uploadtree_a', $upload, 1, 16); $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED=>true, UploadTreeProxy::OPT_AGENT_SET=>array(401)); $uploadTreeProxy = new UploadTreeProxy($upload, $options, $uploadTreeTableName, 'viewTop'); @@ -311,7 +311,7 @@ public function testOptionSkipAlreadyClearedRanged() $zipDescendantsT = array_reduce($descendantsT, function($foo,$bar){$foo[]=$bar['pfile_fk'];return $foo;}, array()); assertThat($zipDescendantsT, equalTo(array(104)) ); } - + public function testOptionSkipAlreadyClearedParented() { $this->testDb->createPlainTables( array('license_file','clearing_decision','clearing_decision_event','clearing_event','license_ref') ); @@ -322,15 +322,15 @@ public function testOptionSkipAlreadyClearedParented() $eventId = 601; $this->dbManager->insertTableRow('license_ref',array('rf_pk'=>$rfId,'rf_shortname'=>'any_license_found')); - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED, 'true', '2015-05-11 12:13'); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>103,'agent_fk'=>401)); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>104,'agent_fk'=>401)); - + $this->prepareUploadTree($upload=4); - + $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED=>true, UploadTreeProxy::OPT_AGENT_SET=>array(401)); $uploadTreeProxy = new UploadTreeProxy($upload, $options, $uploadTreeTableName='uploadtree_a', 'viewTop'); $stmt = __METHOD__; @@ -341,7 +341,7 @@ public function testOptionSkipAlreadyClearedParented() $zipDescendantsT = array_reduce($descendantsT, function($foo,$bar){$foo[]=$bar['pfile_fk'];return $foo;}, array()); assertThat($zipDescendantsT, equalTo(array(104)) ); } - + public function testOptionSkipTheseThatAreAlreadyCleared() { $this->testDb->createPlainTables( array('license_file','clearing_decision','clearing_decision_event','clearing_event','license_ref') ); @@ -352,15 +352,15 @@ public function testOptionSkipTheseThatAreAlreadyCleared() $eventId = 601; $this->dbManager->insertTableRow('license_ref',array('rf_pk'=>$rfId,'rf_shortname'=>'any_license_found')); - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED, 'true', '2015-05-11 12:13'); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>103,'agent_fk'=>401)); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>104,'agent_fk'=>401)); - + $this->prepareUploadTree($upload=4); - + $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_SKIP_THESE=>UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED, UploadTreeProxy::OPT_AGENT_SET=>array(401)); $uploadTreeProxy = new UploadTreeProxy($upload, $options, $uploadTreeTableName='uploadtree_a', 'viewTop'); $stmt = __METHOD__; @@ -371,7 +371,7 @@ public function testOptionSkipTheseThatAreAlreadyCleared() $zipDescendantsT = array_reduce($descendantsT, function($foo,$bar){$foo[]=$bar['pfile_fk'];return $foo;}, array()); assertThat($zipDescendantsT, equalTo(array(104)) ); } - + public function testOptionSkipAlreadyClearedButScanRanged() { $this->testDb->createPlainTables( array('license_file','clearing_decision','clearing_decision_event','clearing_event','license_ref','license_map') ); @@ -383,18 +383,18 @@ public function testOptionSkipAlreadyClearedButScanRanged() $this->dbManager->insertTableRow('license_ref',array('rf_pk'=>$rfId,'rf_shortname'=>'any_license_found')); $this->dbManager->insertTableRow('license_ref',array('rf_pk'=>$rfId+1,'rf_shortname'=>'license_found')); - + $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED, 'false', '2015-05-11 12:13'); $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED, 'true', '2015-05-11 12:13'); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>103,'agent_fk'=>401)); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId,'pfile_fk'=>104,'agent_fk'=>401)); $this->dbManager->insertTableRow('license_file',array('rf_fk'=>$rfId+1,'pfile_fk'=>101,'agent_fk'=>401)); - + $this->prepareUploadTree($upload=4); - + $itemBoundsT = new ItemTreeBounds(301, $uploadTreeTableName='uploadtree_a', $upload, 1, 16); - $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT, + $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED=>true, UploadTreeProxy::OPT_AGENT_SET=>array(401), UploadTreeProxy::OPT_SCAN_REF=>$rfId); $uploadTreeProxy = new UploadTreeProxy($upload, $options, $uploadTreeTableName, 'viewTop'); $stmt = __METHOD__; @@ -405,15 +405,15 @@ public function testOptionSkipAlreadyClearedButScanRanged() $zipDescendantsT = array_reduce($descendantsT, function($foo,$bar){$foo[]=$bar['pfile_fk'];return $foo;}, array()); assertThat($zipDescendantsT, equalTo(array(104)) ); } - + public function testCount() { $uploadTreeProxy = new UploadTreeProxy(1, array(), 'uploadtree_a'); assertThat($uploadTreeProxy->count(), is(12)); - + $uploadTreeProxy->materialize(); assertThat($uploadTreeProxy->count(), is(12)); - + $uploadTreeProxyAd = new UploadTreeProxy(1, array(UploadTreeProxy::OPT_ITEM_FILTER=>" AND ufile_name LIKE 'Ad%'"), 'uploadtree_a', 'viewWithHead'); assertThat($uploadTreeProxyAd->count(), is(2)); } @@ -423,13 +423,13 @@ public function testGetUploadTreeTableName() $uploadTreeProxy = new UploadTreeProxy(1, array(), $tableName='uploadtree_a'); assertThat($uploadTreeProxy->getUploadTreeTableName(), is(equalTo($tableName))); } - + public function testGetDefaultUploadTreeView() { $this->prepareUploadTree($upload=4); $options = array(UploadTreeProxy::OPT_ITEM_FILTER=>"AND ufile_name='dirA'"); $uploadTreeProxy = new UploadTreeProxy(4, $options, $uploadTreeTableName='uploadtree_a'); - + $stmt = __METHOD__; $this->dbManager->prepare($stmt, $uploadTreeProxy->asCTE()." SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName()); $res = $this->dbManager->execute($stmt, $uploadTreeProxy->getParams()); diff --git a/src/lib/php/Report/tests/ClearedGetterCommonTest.php b/src/lib/php/Report/tests/ClearedGetterCommonTest.php index efe0772a37..d643730db8 100644 --- a/src/lib/php/Report/tests/ClearedGetterCommonTest.php +++ b/src/lib/php/Report/tests/ClearedGetterCommonTest.php @@ -18,8 +18,8 @@ namespace Fossology\Lib\Report; -use Fossology\Lib\Dao\UploadDao; use Fossology\Lib\Dao\TreeDao; +use Fossology\Lib\Dao\UploadDao; use Mockery as M; use Mockery\MockInterface; diff --git a/src/lib/php/Test/test/ReflectoryTest.php b/src/lib/php/Test/test/ReflectoryTest.php index 89f132bacf..27bef74d8c 100644 --- a/src/lib/php/Test/test/ReflectoryTest.php +++ b/src/lib/php/Test/test/ReflectoryTest.php @@ -42,14 +42,14 @@ protected function setUp() protected function tearDown() { $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); } - + public function testInvokeObjectsMethodnameWith() { $instanceWithPrivateMethod = new ClassWithPrivateMethod(); assertThat(Reflectory::invokeObjectsMethodnameWith($instanceWithPrivateMethod, 'add', array(2)),is(1+2)); assertThat(Reflectory::invokeObjectsMethodnameWith($instanceWithPrivateMethod, 'add', array(4)),is(1+2+4)); } - + public function testGetObjectsProperty() { $instanceWithPrivateMethod = new ClassWithPrivateMethod(); @@ -62,6 +62,6 @@ public function testSetObjectsProperty() Reflectory::setObjectsProperty($instanceWithPrivateMethod, 'internal', 3); assertThat($instanceWithPrivateMethod->getInternal(),is(3)); } - - + + } diff --git a/src/lib/php/Test/test/TestLiteDbTest.php b/src/lib/php/Test/test/TestLiteDbTest.php index 3dcb423483..198f7108fe 100644 --- a/src/lib/php/Test/test/TestLiteDbTest.php +++ b/src/lib/php/Test/test/TestLiteDbTest.php @@ -25,19 +25,19 @@ public function testGetDbManager(){ $testDb = new TestLiteDb(); $this->assertInstanceOf('Fossology\Lib\Db\DbManager', $testDb->getDbManager()); } - + public function testCreatePlainTables() { $testDb = new TestLiteDb(); $testDb->createPlainTables(array('tag')); $dbManager = $testDb->getDbManager(); - + $dbManager->queryOnce("insert into tag (tag_pk,tag,tag_desc) values (1,'hello','world')"); $tag1 = $dbManager->getSingleRow('select * from tag where tag_pk=1'); assertThat($tag1,hasKey('tag_desc')); assertThat($tag1['tag_desc'],is('world')); } - + public function testInsertData() { $testDb = new TestLiteDb(); @@ -47,6 +47,6 @@ public function testInsertData() assertThat($tag1,hasKey('perm')); assertThat($tag1['perm'],is(10)); } - - + + } diff --git a/src/lib/php/Test/test/TestPgDbTest.php b/src/lib/php/Test/test/TestPgDbTest.php index b72e191a58..146b46e4a5 100644 --- a/src/lib/php/Test/test/TestPgDbTest.php +++ b/src/lib/php/Test/test/TestPgDbTest.php @@ -20,7 +20,7 @@ class TestPgDbTest extends \PHPUnit\Framework\TestCase { - + public function testIfTestDbIsCreated() { return; @@ -30,7 +30,7 @@ public function testIfTestDbIsCreated() if($cmdRtn != 0) { echo $cmdOut; - } + } $testDb = new TestPgDb(); exec($cmd="psql -Ufossy -hlocalhost -l | grep -q $dbName", $cmdOut, $cmdRtn); assertThat($cmdRtn,is(0)); @@ -41,19 +41,19 @@ public function testGetDbManager() $testDb = new TestPgDb(); $this->assertInstanceOf('Fossology\Lib\Db\DbManager', $testDb->getDbManager()); } - + public function testCreatePlainTables() { $testDb = new TestPgDb(); $testDb->createPlainTables(array('tag')); $dbManager = $testDb->getDbManager(); - + $dbManager->queryOnce("insert into tag (tag_pk,tag,tag_desc) values (1,'hello','world')"); $tag1 = $dbManager->getSingleRow('select * from tag where tag_pk=1'); assertThat($tag1,hasKey('tag_desc')); assertThat($tag1['tag_desc'],is('world')); } - + public function testInsertData() { $testDb = new TestPgDb(); @@ -63,5 +63,5 @@ public function testInsertData() assertThat($tag1,hasKey('perm')); assertThat($tag1['perm'],is(10)); } - + } diff --git a/src/lib/php/Text/tests/EncodingConverterTest.php b/src/lib/php/Text/tests/EncodingConverterTest.php index 67ee063954..3ae7638a39 100644 --- a/src/lib/php/Text/tests/EncodingConverterTest.php +++ b/src/lib/php/Text/tests/EncodingConverterTest.php @@ -18,7 +18,6 @@ namespace Fossology\Lib\Text; - class EncodingConverterTest extends \PHPUnit\Framework\TestCase { diff --git a/src/lib/php/UI/test/FolderNavTest.php b/src/lib/php/UI/test/FolderNavTest.php index 1204fa6619..4c97ecebf4 100644 --- a/src/lib/php/UI/test/FolderNavTest.php +++ b/src/lib/php/UI/test/FolderNavTest.php @@ -54,7 +54,7 @@ protected function tearDown() $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore); M::close(); } - + protected function getFormattedItem($row) { return Reflectory::invokeObjectsMethodnameWith($this->folderNav, 'getFormattedItem', array($row,$this->uri)); @@ -70,7 +70,7 @@ protected function prepareShowFolderTree($parentFolderId='parentFolderId') $this->dbManager->shouldReceive('freeResult')->with($res); return $res; } - + public function testShowFolderTreeWithoutContent() { $res = $this->prepareShowFolderTree($parentFolderId='foo'); @@ -79,7 +79,7 @@ public function testShowFolderTreeWithoutContent() $out = $this->folderNav->showFolderTree($parentFolderId); assertThat($out, equalTo('
  • '.$this->getFormattedItem($rowA).'
')); } - + public function testShowFolderTreeWithContent() { $res = $this->prepareShowFolderTree($parentFolderId='foo'); diff --git a/src/lib/php/Util/TimingLogger.php b/src/lib/php/Util/TimingLogger.php index f2527fd9f6..49ce00947a 100644 --- a/src/lib/php/Util/TimingLogger.php +++ b/src/lib/php/Util/TimingLogger.php @@ -26,7 +26,7 @@ class TimingLogger /** @var Logger */ private $logger; - + /** @var float[] */ private $watchTimes; @@ -42,14 +42,14 @@ public function __construct(Logger $logger) /** * @brief start stopwatch timer - * + * * @param string $watch */ public function tic($watch = self::DEFAULT_WATCH) { $this->watchTimes[$watch] = $this->getTimestamp(); } - + /** * @param string $text * @param string $watch diff --git a/src/lib/php/Util/test/ArrayOperationTest.php b/src/lib/php/Util/test/ArrayOperationTest.php index be421dfff4..68c4ca9f8f 100644 --- a/src/lib/php/Util/test/ArrayOperationTest.php +++ b/src/lib/php/Util/test/ArrayOperationTest.php @@ -18,10 +18,9 @@ namespace Fossology\Lib\Util; - class ArrayOperationTest extends \PHPUnit\Framework\TestCase { - + protected function setUp() { $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); @@ -81,7 +80,7 @@ public function testCallChunkedShouldThrowExceptionWhenChunkSizeIsNotPositive() return array(count($values)); }, array(), 0); } - + public function testMultiSearch() { $haystack = array(100, 101, 102, 101); @@ -91,5 +90,5 @@ public function testMultiSearch() assertThat(ArrayOperation::multiSearch(array(200),$haystack),is(false)); assertThat(ArrayOperation::multiSearch(array(200,102),$haystack),is(2)); } - + } diff --git a/src/lib/php/Util/test/StringOperationTest.php b/src/lib/php/Util/test/StringOperationTest.php index 868c07dbc9..0c9453f6c0 100644 --- a/src/lib/php/Util/test/StringOperationTest.php +++ b/src/lib/php/Util/test/StringOperationTest.php @@ -18,10 +18,9 @@ namespace Fossology\Lib\Util; - class StringOperationTest extends \PHPUnit\Framework\TestCase { - + protected function setUp() { $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); @@ -42,5 +41,5 @@ public function testGetCommonHead() assertThat(StringOperation::getCommonHead('abc',''), equalTo('')); assertThat(StringOperation::getCommonHead('','abc'), equalTo('')); } - + } diff --git a/src/lib/php/Util/test/TimingLoggerTest.php b/src/lib/php/Util/test/TimingLoggerTest.php index 442771dfc4..949def661c 100644 --- a/src/lib/php/Util/test/TimingLoggerTest.php +++ b/src/lib/php/Util/test/TimingLoggerTest.php @@ -32,7 +32,7 @@ public function getTimestamp() class TimingLoggerTest extends \PHPUnit\Framework\TestCase { private $logger; - + protected function setUp() { $this->logger = M::mock('Monolog\Logger'); @@ -75,5 +75,5 @@ public function testTicTocOtherWatch() $hackedTimingLogger->timestamp = $endTime; $hackedTimingLogger->toc($text,$watch); } - + } diff --git a/src/lib/php/View/test/HighlightProcessorTest.php b/src/lib/php/View/test/HighlightProcessorTest.php index 3a9276554a..585927d130 100644 --- a/src/lib/php/View/test/HighlightProcessorTest.php +++ b/src/lib/php/View/test/HighlightProcessorTest.php @@ -282,7 +282,7 @@ function testFlattenHighlightWithIgnoredEntries() new Highlight(7, 9, Highlight::KEYWORD, 'ref2', 0, 0) ))); } - + function testFlattenHighlightWithOverlappingEntriesThatHaveEqualEnd() { $highlight1 = new Highlight(5, 10, Highlight::MATCH, 'ref1', 0, 0); diff --git a/src/lib/php/View/test/HighlightStateTest.php b/src/lib/php/View/test/HighlightStateTest.php index 1025331d01..572325d76b 100644 --- a/src/lib/php/View/test/HighlightStateTest.php +++ b/src/lib/php/View/test/HighlightStateTest.php @@ -19,7 +19,6 @@ namespace Fossology\Lib\View; - class HighlightStateTest extends \PHPUnit\Framework\TestCase { public function testBla() { diff --git a/src/lib/php/View/test/TextRendererTest.php b/src/lib/php/View/test/TextRendererTest.php index 6360f403e5..bfc51e9d5a 100644 --- a/src/lib/php/View/test/TextRendererTest.php +++ b/src/lib/php/View/test/TextRendererTest.php @@ -180,7 +180,7 @@ function testRenderHighlightedTextWithFourSplitPositions() assertThat($renderedText, is("foo bar baz quux")); } - + function testRenderHighlightThatIsIgnorableByBulk() { $highlight1 = new Highlight(14, 14, Highlight::DELETED, 0, 0, 'ref1'); @@ -194,5 +194,5 @@ function testRenderHighlightThatIsIgnorableByBulk() assertThat($cleanText, is("foo bar baz quux")); } - + } diff --git a/src/lib/php/tests/test_common_active.php b/src/lib/php/tests/test_common_active.php index c683e5b57f..dd16b7b9bd 100644 --- a/src/lib/php/tests/test_common_active.php +++ b/src/lib/php/tests/test_common_active.php @@ -31,7 +31,7 @@ class test_common_active extends \PHPUnit\Framework\TestCase /** * \brief initialization */ - protected function setUp() + protected function setUp() { } diff --git a/src/lib/php/tests/test_common_cache.php b/src/lib/php/tests/test_common_cache.php index 547c081a9c..840ebccec4 100644 --- a/src/lib/php/tests/test_common_cache.php +++ b/src/lib/php/tests/test_common_cache.php @@ -37,7 +37,7 @@ class test_common_cached extends \PHPUnit\Framework\TestCase /** * \brief initialization */ - protected function setUp() + protected function setUp() { global $PG_CONN; $sysconfig = dirname(__FILE__).'/sysconfigDirTest'; @@ -112,7 +112,7 @@ function testReportCachePut_upload_id_not_null() $this->assertEquals($CacheValue, $value); $this->resetEnv4ReportCachePut(); } - + /** * \brief test for ReportCachePut upload id is not in $CacheKey */ @@ -140,7 +140,7 @@ function testReportCachePut_upload_id_null() } /** - * \brief test for ReportCacheGet + * \brief test for ReportCacheGet */ function testReportCacheGet() { diff --git a/src/lib/php/tests/test_common_cli.php b/src/lib/php/tests/test_common_cli.php index 44ab680bf7..9afedb25a6 100644 --- a/src/lib/php/tests/test_common_cli.php +++ b/src/lib/php/tests/test_common_cli.php @@ -31,12 +31,12 @@ class test_common_cli extends \PHPUnit\Framework\TestCase /** * \brief initialization */ - protected function setUp() + protected function setUp() { } /** - * \brief test for cli_logger + * \brief test for cli_logger */ function testcli_logger() { @@ -54,7 +54,7 @@ function testcli_logger() $this->assertEquals("$data\n", $file_contents); print "unit test for common-cli.php end\n"; } - + /** * \brief clean the env */ diff --git a/src/lib/php/tests/test_common_dir.php b/src/lib/php/tests/test_common_dir.php index a32b1601cc..74b15a53f3 100644 --- a/src/lib/php/tests/test_common_dir.php +++ b/src/lib/php/tests/test_common_dir.php @@ -34,7 +34,7 @@ protected function setUp() // print "Starting unit test for common-dir.php\n"; print('.'); } - + /** * \brief clean the env */ @@ -82,7 +82,7 @@ public function test_GetFileExt() { $this->assertEquals(GetFileExt('autodestroy.exe.bak'),'bak'); } - + /** * \brief test for DirMode2String */ @@ -94,5 +94,5 @@ public function test_DirMode2String() $result = DirMode2String(0644); $this->assertEquals("---rw-r--r--", $result); } - + } diff --git a/src/lib/php/tests/test_common_license_file.php b/src/lib/php/tests/test_common_license_file.php index 71bd1154da..2c38f1c0fa 100644 --- a/src/lib/php/tests/test_common_license_file.php +++ b/src/lib/php/tests/test_common_license_file.php @@ -42,7 +42,7 @@ class test_common_license_file extends \PHPUnit\Framework\TestCase public $DB_COMMAND = ""; public $DB_NAME = ""; - + /** @var TestLiteDb */ private $testDb; /** @var ModernDbManager */ @@ -53,7 +53,7 @@ class test_common_license_file extends \PHPUnit\Framework\TestCase /** * \brief initialization */ - protected function setUp() + protected function setUp() { global $PG_CONN; global $upload_pk; @@ -93,7 +93,7 @@ protected function setUp() 'AF1DF2C4B32E4115DB5F272D9EFD0E674CF2A0BC', '2239AA7DAC291B6F8D0A56396B1B8530', '4560'))); $this->dbManager->freeResult($this->dbManager->execute($stmt,array( 'B1938B14B9A573D59ABCBD3BF0F9200CE6E79FB6', '55EFE7F9B9D106047718F1CE9173B869', '1892'))); - + /** add nomos agent record **/ $this->dbManager->queryOnce($sql="INSERT INTO agent (agent_name) VALUES('nomos')"); @@ -104,7 +104,7 @@ protected function setUp() . " VALUES ($1,$2,$3,$4,$5,$6,$7)"); $this->dbManager->freeResult($this->dbManager->execute($stmt, array(1, 'test_ref', 'test_ref', 'false', 'true', 'false', 1))); - + /** get pfile id */ $this->dbManager->prepare($stmt='license_ref.select', $sql = "SELECT pfile_pk from pfile where pfile_sha1" @@ -123,7 +123,7 @@ protected function setUp() $sql = "INSERT INTO license_file(rf_fk, agent_fk, pfile_fk) VALUES ($1,$2,$3)"); $this->dbManager->freeResult($this->dbManager->execute($stmt, array(1, $agent_pk, $pfile_pk_parent))); $this->dbManager->freeResult($this->dbManager->execute($stmt, array(2, $agent_pk, $pfile_pk_child))); - + $this->dbManager->queryOnce("INSERT INTO upload (upload_filename,upload_mode,upload_ts, pfile_fk, uploadtree_tablename)" . " VALUES ('$upload_filename',40,now(), '$pfile_pk_parent', '$this->uploadtree_tablename')"); $row = $this->dbManager->getSingleRow("SELECT upload_pk from upload where upload_filename = '$upload_filename'",array(),__METHOD__.'.upload.select'); @@ -131,9 +131,9 @@ protected function setUp() $this->dbManager->prepare($stmtIn=__METHOD__.'.uploadtree.insert', "INSERT INTO uploadtree (parent, upload_fk, pfile_fk, ufile_mode, lft, rgt, ufile_name) VALUES ($1,$2,$3,$4,$5,$6,$7)"); - $this->dbManager->freeResult( + $this->dbManager->freeResult( $this->dbManager->execute($stmtIn,array(NULL, $upload_pk, $pfile_pk_parent, 33188, 1, 2, 'license_test.file.parent'))); - + $this->dbManager->prepare($stmtOut=__METHOD__.'uploadtree.select', "SELECT uploadtree_pk from uploadtree where pfile_fk=$1"); $res = $this->dbManager->execute($stmtOut,array($pfile_pk_parent)); @@ -142,7 +142,7 @@ protected function setUp() $this->uploadtree_pk_parent = $row['uploadtree_pk']; /** add child uploadtree record */ - $this->dbManager->freeResult( + $this->dbManager->freeResult( $this->dbManager->execute($stmtIn,array($this->uploadtree_pk_parent, $upload_pk, $pfile_pk_child, 33188, 1, 2, 'license_test.file.child'))); $res = $this->dbManager->execute($stmtOut,array($pfile_pk_child)); @@ -151,12 +151,12 @@ protected function setUp() $this->uploadtree_pk_child = $row['uploadtree_pk']; $this->uploadtree_tablename = GetUploadtreeTableName($upload_pk); - print('.'); + print('.'); } /** * \brief testing from GetFileLicenses - * in this test case, this pfile have only one license + * in this test case, this pfile have only one license */ function testGetFileLicenses() { @@ -179,7 +179,7 @@ function testGetFileLicenses() /** * \brief testing from GetFileLicenses - * in this test case, this pfile have 2 same license + * in this test case, this pfile have 2 same license */ function testGetFileLicensesDul() { @@ -309,14 +309,14 @@ protected function tearDown() { $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); - + /** delete the agent record */ $sql = "DELETE FROM agent where agent_name = 'nomos';"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); - + pg_close($PG_CONN); exec("$DB_COMMAND -d $DB_NAME"); } diff --git a/src/lib/php/tests/test_common_menu.php b/src/lib/php/tests/test_common_menu.php index de7d6508f9..f71019d09a 100644 --- a/src/lib/php/tests/test_common_menu.php +++ b/src/lib/php/tests/test_common_menu.php @@ -41,7 +41,7 @@ function test_MenuPage() { print "Starting unit test for common-menu.php\n"; print "test function MenuPage()\n"; - + $Page = 10; $TotalPage = 15; $Uri = "http://fossology.org/repo/"; @@ -102,7 +102,7 @@ function test_menu_functions() $countMenuListBefore = count($MenuList); $result = menu_insert($Path, $LastOrder, $URI, $Title, $Target, $HTML); $this->assertEquals($Path,$MenuList[$countMenuListBefore]->FullName); - + print "test function menu_find)\n"; $depth = 2; $result = menu_find("Test1", $depth); diff --git a/src/lib/php/tests/test_common_pkg.php b/src/lib/php/tests/test_common_pkg.php index ad5a801205..96ed547529 100644 --- a/src/lib/php/tests/test_common_pkg.php +++ b/src/lib/php/tests/test_common_pkg.php @@ -43,7 +43,7 @@ protected function setUp() global $DB_COMMAND; global $DB_NAME; print "Starting unit test for common-pkg.php\n"; - + $DB_COMMAND = dirname(dirname(dirname(dirname(__FILE__))))."/testing/db/createTestDB.php"; exec($DB_COMMAND, $dbout, $rc); preg_match("/(\d+)/", $dbout[0], $matches); @@ -61,7 +61,7 @@ function test_GetPkgMimetypes() { print "test function GetPkgMimetypes()\n"; global $PG_CONN; - + #prepare database testdata $mimeType = "application/x-rpm"; /** delete test data pre testing */ @@ -72,7 +72,7 @@ function test_GetPkgMimetypes() $sql = "INSERT INTO mimetype(mimetype_pk, mimetype_name) VALUES(10000, '$mimeType');"; $result = pg_query($PG_CONN, $sql); pg_free_result($result); - + #begin test GetPkgMimetypes() $sql = "select * from mimetype where mimetype_name='application/x-rpm'"; diff --git a/src/lib/php/tests/test_common_sysconfig.php b/src/lib/php/tests/test_common_sysconfig.php index 375aa812b2..31dd22c826 100644 --- a/src/lib/php/tests/test_common_sysconfig.php +++ b/src/lib/php/tests/test_common_sysconfig.php @@ -32,8 +32,8 @@ class test_common_sysconfig extends \PHPUnit\Framework\TestCase { public $PG_CONN; public $DB_COMMAND = ""; - public $DB_NAME = ""; - public $sys_conf = ""; + public $DB_NAME = ""; + public $sys_conf = ""; /** * \brief initialization with db @@ -98,5 +98,6 @@ public function test_check_IP() { $this->assertEquals(check_IP($ip),$correct,$message="result for IP $ip is false"); print('.'); } - } + } } + diff --git a/src/monk/agent_tests/Functional/bulkTest.php b/src/monk/agent_tests/Functional/bulkTest.php index d18d7127d0..e0d23e1263 100644 --- a/src/monk/agent_tests/Functional/bulkTest.php +++ b/src/monk/agent_tests/Functional/bulkTest.php @@ -28,7 +28,6 @@ use Fossology\Lib\Test\TestPgDb; use Monolog\Logger; - class MonkBulkTest extends \PHPUnit\Framework\TestCase { /** @var TestPgDb */ diff --git a/src/monk/agent_tests/Functional/cliTest.php b/src/monk/agent_tests/Functional/cliTest.php index d6ded52be3..41a60d8522 100644 --- a/src/monk/agent_tests/Functional/cliTest.php +++ b/src/monk/agent_tests/Functional/cliTest.php @@ -19,7 +19,6 @@ use Fossology\Lib\Db\DbManager; use Fossology\Lib\Test\TestPgDb; - class MonkCliTest extends \PHPUnit\Framework\TestCase { /** @var TestPgDb */ diff --git a/src/monk/agent_tests/Functional/schedulerTest.php b/src/monk/agent_tests/Functional/schedulerTest.php index 312112d087..8ae1a9905c 100644 --- a/src/monk/agent_tests/Functional/schedulerTest.php +++ b/src/monk/agent_tests/Functional/schedulerTest.php @@ -30,7 +30,6 @@ use Fossology\Lib\Test\TestPgDb; use Monolog\Logger; - class MonkScheduledTest extends \PHPUnit\Framework\TestCase { /** @var TestPgDb */ diff --git a/src/phpunit.xml b/src/phpunit.xml index 2c67b7f47c..637557974d 100644 --- a/src/phpunit.xml +++ b/src/phpunit.xml @@ -8,13 +8,13 @@ - + - www/ui_tests/startUpTest.php lib/php + www/ui_tests/startUpTest.php cli/tests/test_fo_copyright_list.php @@ -33,13 +33,13 @@ . . - ./phpunit-bootstrap.php lib/php/tests lib/c */*tests testing tutorials vendor + ./phpunit-bootstrap.php diff --git a/src/pkgagent/agent/pkgagent.c b/src/pkgagent/agent/pkgagent.c index 82ef8ac913..9140f9560d 100644 --- a/src/pkgagent/agent/pkgagent.c +++ b/src/pkgagent/agent/pkgagent.c @@ -322,7 +322,7 @@ int ProcessUpload (long upload_pk) return -1; } uploadtree_tablename = GetUploadtreeTableName(db_conn, upload_pk); - if (NULL == uploadtree_tablename) strcpy(uploadtree_tablename, "uploadtree_a"); + if (NULL == uploadtree_tablename) uploadtree_tablename = strdup("uploadtree_a"); /* retrieve the records to process */ snprintf(sqlbuf, sizeof(sqlbuf), "SELECT pfile_pk as pfile_pk, pfile_sha1 || '.' || pfile_md5 || '.' || pfile_size AS pfilename, mimetype_name as mimetype from pfile, mimetype, (SELECT distinct(pfile_fk) as PF from %s where upload_fk='%ld') as SS where PF=pfile_pk and (pfile_mimetypefk='%d' or pfile_mimetypefk='%d' OR pfile_mimetypefk='%d') and mimetype_pk=pfile_mimetypefk and (not exists (SELECT 1 from pkg_rpm where pkg_rpm.pfile_fk = pfile_pk)) and (not exists (SELECT 1 from pkg_deb where pkg_deb.pfile_fk = pfile_pk))", uploadtree_tablename, upload_pk, mimetypepk, debmimetypepk, debsrcmimetypepk); @@ -712,7 +712,7 @@ int GetMetadataDebBinary (long upload_pk, struct debpkginfo *pi) if (!upload_pk) return -1; // when upload_pk is empty uploadtree_tablename = GetUploadtreeTableName(db_conn, upload_pk); - if (NULL == uploadtree_tablename) strcpy(uploadtree_tablename, "uploadtree_a"); + if (NULL == uploadtree_tablename) uploadtree_tablename = strdup("uploadtree_a"); /* Get the debian control file's repository path */ /* First get the uploadtree bounds (lft,rgt) for the package */ snprintf(SQL,sizeof(SQL),"SELECT lft,rgt FROM %s WHERE upload_fk = %ld AND pfile_fk = %ld limit 1", diff --git a/src/www/ui_tests/Unit/ui-picker-Test.php b/src/www/ui_tests/Unit/ui-picker-Test.php index 9c8c92a3e4..f0194dcf1c 100644 --- a/src/www/ui_tests/Unit/ui-picker-Test.php +++ b/src/www/ui_tests/Unit/ui-picker-Test.php @@ -27,7 +27,6 @@ if(!function_exists('register_plugin')){ function register_plugin(){}} require_once ($wwwPath.'/ui/ui-picker.php'); - class ui_picker_Test extends \PHPUnit\Framework\TestCase { /** diff --git a/utils/fo-installdeps b/utils/fo-installdeps index 47399c2476..7a9fb5810e 100755 --- a/utils/fo-installdeps +++ b/utils/fo-installdeps @@ -167,7 +167,7 @@ if [[ $RUNTIME ]]; then stretch|buster|sid) apt-get $YesOpt install postgresql-9.6 php7.0 php7.0-pgsql php7.0-cli php7.0-curl php7.0-xml php7.0-zip s-nail;; bionic) - apt-get "$YesOpt" install postgresql-10 php7.2 php7.2-pgsql php7.2-cli php7.2-curl php7.2-xml php7.2-zip s-nail;; + apt-get "$YesOpt" install postgresql-10 php7.2 php7.2-pgsql php7.2-cli php7.2-curl php7.2-xml php7.2-zip s-nail libboost-program-options1.65.1 libboost-regex1.65.1;; *) echo "ERROR: Unknown or Unsupported $DISTRO $CODENAME release, please report to the mailing list"; exit 1;; esac ;;