From fd9f6765a808e2d9c0d70c90ef3f4c28a691e1d8 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Fri, 22 Mar 2019 01:17:35 -0500 Subject: [PATCH 01/47] Update codesniffer version --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 04bc5951c..7692ced1a 100644 --- a/composer.lock +++ b/composer.lock @@ -2244,16 +2244,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.4.0", + "version": "3.4.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "379deb987e26c7cd103a7b387aea178baec96e48" + "reference": "5b4333b4010625d29580eb4a41f1e53251be6baa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/379deb987e26c7cd103a7b387aea178baec96e48", - "reference": "379deb987e26c7cd103a7b387aea178baec96e48", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5b4333b4010625d29580eb4a41f1e53251be6baa", + "reference": "5b4333b4010625d29580eb4a41f1e53251be6baa", "shasum": "" }, "require": { @@ -2286,12 +2286,12 @@ } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", "standards" ], - "time": "2018-12-19T23:57:18+00:00" + "time": "2019-03-19T03:22:27+00:00" }, { "name": "symfony/console", From 59efc0bf697432a6b0df591afade780cb3b20836 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Fri, 22 Mar 2019 01:58:13 -0500 Subject: [PATCH 02/47] Update phpunit --- composer.json | 2 +- composer.lock | 611 +++++++++++++--------- tests/controllers/TalksControllerTest.php | 2 +- tests/controllers/TokenControllerTest.php | 2 +- tests/inc/RequestTest.php | 2 +- tests/models/ApiMapperTest.php | 2 +- tests/models/OauthModelTest.php | 2 +- 7 files changed, 357 insertions(+), 266 deletions(-) diff --git a/composer.json b/composer.json index 6e658ba8b..2dd6ea348 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require-dev": { "exussum12/coverage-checker": "^0.11.0", "jakub-onderka/php-parallel-lint": "^1.0", - "phpunit/phpunit": "^5.7", + "phpunit/phpunit": "^8.0", "roave/security-advisories": "dev-master", "sensiolabs/security-checker": "^5.0", "squizlabs/php_codesniffer": "^3.4" diff --git a/composer.lock b/composer.lock index 7692ced1a..55a35a0fe 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3f032eae257d8113f9c290649044897c", + "content-hash": "e9e27dc789338fd3cf0b670f77d904b1", "packages": [ { "name": "guzzlehttp/guzzle", @@ -589,32 +589,32 @@ }, { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -639,7 +639,7 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2017-07-22T11:58:36+00:00" }, { "name": "exussum12/coverage-checker", @@ -738,25 +738,28 @@ }, { "name": "myclabs/deep-copy", - "version": "1.7.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", - "phpunit/phpunit": "^4.1" + "phpunit/phpunit": "^7.1" }, "type": "library", "autoload": { @@ -779,7 +782,7 @@ "object", "object graph" ], - "time": "2017-10-19T19:58:43+00:00" + "time": "2018-06-11T23:09:50+00:00" }, { "name": "nikic/php-parser", @@ -832,6 +835,108 @@ ], "time": "2018-02-28T20:30:58+00:00" }, + { + "name": "phar-io/manifest", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^2.0", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2018-07-08T19:23:20+00:00" + }, + { + "name": "phar-io/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2018-07-08T19:19:57+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", @@ -888,29 +993,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.3.2", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bf329f6c1aadea3299f08ee804682b7c45b326a2", - "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0", + "php": "^7.0", "phpdocumentor/reflection-common": "^1.0.0", "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -929,7 +1040,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-10T14:09:06+00:00" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -1043,40 +1154,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "4.0.8", + "version": "7.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" + "reference": "0317a769a81845c390e19684d9ba25d7f6aa4707" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0317a769a81845c390e19684d9ba25d7f6aa4707", + "reference": "0317a769a81845c390e19684d9ba25d7f6aa4707", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^5.6 || ^7.0", - "phpunit/php-file-iterator": "^1.3", - "phpunit/php-text-template": "^1.2", - "phpunit/php-token-stream": "^1.4.2 || ^2.0", - "sebastian/code-unit-reverse-lookup": "^1.0", - "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "^1.0 || ^2.0" + "php": "^7.2", + "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.0.1", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^4.1", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" }, "require-dev": { - "ext-xdebug": "^2.1.4", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^8.0" }, "suggest": { - "ext-xdebug": "^2.5.1" + "ext-xdebug": "^2.6.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -1091,7 +1202,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1102,29 +1213,32 @@ "testing", "xunit" ], - "time": "2017-04-02T07:44:40+00:00" + "time": "2019-02-26T07:38:26+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.5", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + "reference": "050bedf145a257b1ff02746c31894800e5122946" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1139,7 +1253,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1149,7 +1263,7 @@ "filesystem", "iterator" ], - "time": "2017-11-27T13:52:08+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", @@ -1194,28 +1308,28 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "8b389aebe1b8b0578430bda0c7c95a829608e059" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b389aebe1b8b0578430bda0c7c95a829608e059", + "reference": "8b389aebe1b8b0578430bda0c7c95a829608e059", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -1230,7 +1344,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1239,33 +1353,33 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "time": "2019-02-20T10:12:59+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.12", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18", + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1288,55 +1402,55 @@ "keywords": [ "tokenizer" ], - "time": "2017-12-04T08:55:13+00:00" + "time": "2018-10-30T05:52:18+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.27", + "version": "8.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" + "reference": "19cbed2120839772c4a00e8b28456b0c77d1a7b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/19cbed2120839772c4a00e8b28456b0c77d1a7b4", + "reference": "19cbed2120839772c4a00e8b28456b0c77d1a7b4", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.0", - "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^4.0.4", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "^1.2.4", - "sebastian/diff": "^1.4.3", - "sebastian/environment": "^1.3.4 || ^2.0", - "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.1", - "sebastian/object-enumerator": "~2.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "^1.0.6|^2.0.1", - "symfony/yaml": "~2.1|~3.0|~4.0" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2" + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.7", + "phar-io/manifest": "^1.0.2", + "phar-io/version": "^2.0", + "php": "^7.2", + "phpspec/prophecy": "^1.7", + "phpunit/php-code-coverage": "^7.0", + "phpunit/php-file-iterator": "^2.0.1", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.1", + "sebastian/comparator": "^3.0", + "sebastian/diff": "^3.0", + "sebastian/environment": "^4.1", + "sebastian/exporter": "^3.1", + "sebastian/global-state": "^3.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^2.0", + "sebastian/version": "^2.0.1" }, "require-dev": { "ext-pdo": "*" }, "suggest": { + "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "~1.1" + "phpunit/php-invoker": "^2.0" }, "bin": [ "phpunit" @@ -1344,7 +1458,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7.x-dev" + "dev-master": "8.0-dev" } }, "autoload": { @@ -1370,67 +1484,7 @@ "testing", "xunit" ], - "time": "2018-02-01T05:50:59+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "3.4.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.6 || ^7.0", - "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^1.2 || ^2.0" - }, - "conflict": { - "phpunit/phpunit": "<5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "abandoned": true, - "time": "2017-06-30T09:13:00+00:00" + "time": "2019-03-16T07:33:46+00:00" }, { "name": "psr/log", @@ -1730,30 +1784,30 @@ }, { "name": "sebastian/comparator", - "version": "1.2.4", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" + "php": "^7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1784,38 +1838,39 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "homepage": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2017-01-29T09:50:25+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", - "version": "1.4.3", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1840,34 +1895,40 @@ "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" ], - "time": "2017-05-22T07:24:03+00:00" + "time": "2019-02-04T06:01:07+00:00" }, { "name": "sebastian/environment", - "version": "2.0.0", + "version": "4.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + "reference": "6fda8ce1974b62b14935adc02a9ed38252eca656" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6fda8ce1974b62b14935adc02a9ed38252eca656", + "reference": "6fda8ce1974b62b14935adc02a9ed38252eca656", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^5.0" + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -1892,34 +1953,34 @@ "environment", "hhvm" ], - "time": "2016-11-26T07:53:53+00:00" + "time": "2019-02-01T05:27:49+00:00" }, { "name": "sebastian/exporter", - "version": "2.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -1959,27 +2020,30 @@ "export", "exporter" ], - "time": "2016-11-19T08:54:04+00:00" + "time": "2017-04-03T13:19:02+00:00" }, { "name": "sebastian/global-state", - "version": "1.1.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "ext-dom": "*", + "phpunit/phpunit": "^8.0" }, "suggest": { "ext-uopz": "*" @@ -1987,7 +2051,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2010,33 +2074,34 @@ "keywords": [ "global state" ], - "time": "2015-10-12T03:26:01+00:00" + "time": "2019-02-01T05:30:01+00:00" }, { "name": "sebastian/object-enumerator", - "version": "2.0.1", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", "shasum": "" }, "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "~5" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -2056,32 +2121,77 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-02-18T15:18:39+00:00" + "time": "2017-08-03T12:35:26+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "773f97c67f28de00d397be301821b06708fca0be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", + "reference": "773f97c67f28de00d397be301821b06708fca0be", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2017-03-29T09:07:27+00:00" }, { "name": "sebastian/recursion-context", - "version": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -2109,29 +2219,29 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-11-19T07:33:16+00:00" + "time": "2017-03-03T06:23:57+00:00" }, { "name": "sebastian/resource-operations", - "version": "1.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2151,7 +2261,7 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28T20:34:47+00:00" + "time": "2018-10-04T04:07:39+00:00" }, { "name": "sebastian/version", @@ -2539,63 +2649,44 @@ "time": "2018-09-21T13:07:52+00:00" }, { - "name": "symfony/yaml", - "version": "v3.4.22", + "name": "theseer/tokenizer", + "version": "1.1.0", "source": { "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d" + "url": "https://github.com/theseer/tokenizer.git", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/ba11776e9e6c15ad5759a07bffb15899bac75c2d", - "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" } ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2019-01-16T10:59:17+00:00" + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2017-04-07T12:08:54+00:00" }, { "name": "webmozart/assert", diff --git a/tests/controllers/TalksControllerTest.php b/tests/controllers/TalksControllerTest.php index 3567d6ebc..bf14bbc44 100644 --- a/tests/controllers/TalksControllerTest.php +++ b/tests/controllers/TalksControllerTest.php @@ -14,7 +14,7 @@ class TalksControllerTest extends TalkBase { private $config; - public function setUp() + public function setUp(): void { $this->config = [ 'email' => [ diff --git a/tests/controllers/TokenControllerTest.php b/tests/controllers/TokenControllerTest.php index b2b4cecde..528cdb412 100644 --- a/tests/controllers/TokenControllerTest.php +++ b/tests/controllers/TokenControllerTest.php @@ -10,7 +10,7 @@ class TokenControllerTest extends TestCase private $pdo; - public function setup() + public function setup(): void { $this->request = $this->getMockBuilder('Request')->disableOriginalConstructor()->getMock(); $this->pdo = $this->getMockBuilder('PDO')->disableOriginalConstructor()->getMock(); diff --git a/tests/inc/RequestTest.php b/tests/inc/RequestTest.php index bfef3897a..c1a1df0f2 100644 --- a/tests/inc/RequestTest.php +++ b/tests/inc/RequestTest.php @@ -10,7 +10,7 @@ class RequestTest extends TestCase /** * Make sure we have everything we need - in this case the config */ - public function setUp() + public function setUp(): void { include __DIR__ . '/../../src/config.php'; $this->config = $config; diff --git a/tests/models/ApiMapperTest.php b/tests/models/ApiMapperTest.php index 97686b82e..2863ac540 100644 --- a/tests/models/ApiMapperTest.php +++ b/tests/models/ApiMapperTest.php @@ -8,7 +8,7 @@ */ class ApiMapperTest extends TestCase { - public function setup() + public function setup(): void { $this->pdo = $this->getMockBuilder('PDO') ->disableOriginalConstructor() diff --git a/tests/models/OauthModelTest.php b/tests/models/OauthModelTest.php index 4ca04029d..8a89831d0 100644 --- a/tests/models/OauthModelTest.php +++ b/tests/models/OauthModelTest.php @@ -4,7 +4,7 @@ class OauthModelTest extends TestCase { - public function setup() + public function setup(): void { $this->pdo = $this->getMockBuilder('PDO') ->disableOriginalConstructor() From b0fa844050886918634f1cade1fd900f3876fb22 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sat, 23 Mar 2019 22:55:41 -0500 Subject: [PATCH 03/47] Take care of deprecated `@expectedException...` This throws a scary warning while testing, so use the right `$this-expectException...` methods! --- .../controllers/EventHostsControllerTest.php | 100 ++++++++---------- tests/controllers/TalkLinkControllerTest.php | 38 ++++--- .../controllers/TalksControllerDeleteTest.php | 15 +-- tests/controllers/TalksControllerTest.php | 98 ++++++++--------- tests/controllers/TokenControllerTest.php | 18 ++-- tests/controllers/UsersControllerTest.php | 57 +++++----- tests/inc/RequestTest.php | 19 ++-- tests/models/OauthModelTest.php | 7 +- 8 files changed, 163 insertions(+), 189 deletions(-) diff --git a/tests/controllers/EventHostsControllerTest.php b/tests/controllers/EventHostsControllerTest.php index e38dec18c..2a5a9870d 100644 --- a/tests/controllers/EventHostsControllerTest.php +++ b/tests/controllers/EventHostsControllerTest.php @@ -7,13 +7,12 @@ class EventHostsControllerTest extends TestCase { - /** - * @expectedException \Exception - * @expectedExceptionCode 401 - * @expectedExceptionMessage You must be logged in to create data - */ public function testThatNotLoggedInUsersCanNotAddAHost() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to create data'); + $this->expectExceptionCode(401); + $controller = new \Event_hostsController(); $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); @@ -22,13 +21,12 @@ public function testThatNotLoggedInUsersCanNotAddAHost() $controller->addHost($request, $db); } - /** - * @expectedException \Exception - * @expectedExceptionCode 401 - * @expectedExceptionMessage You must be logged in to remove data - */ public function testThatRemovingHostWithoutLoginFails() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to remove data'); + $this->expectExceptionCode(401); + $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); $request->user_id = null; @@ -38,13 +36,12 @@ public function testThatRemovingHostWithoutLoginFails() $constructor->removeHostFromEvent($request, $db); } - /** - * @expectedException \Exception - * @expectedExceptionCode 404 - * @expectedExceptionMessage Event not found - */ public function testThatMissingEventThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Event not found'); + $this->expectExceptionCode(404); + $controller = new \Event_hostsController(); $em = $this->getMockBuilder('EventMapper')->disableOriginalConstructor()->getMock(); @@ -61,13 +58,12 @@ public function testThatMissingEventThrowsException() $controller->addHost($request, $db); } - /** - * @expectedException \Exception - * @expectedExceptionCode 403 - * @expectedExceptionMessage You are not allowed to remove yourself from the host-list - */ public function testThatRemovingOneselfThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You are not allowed to remove yourself from the host-list'); + $this->expectExceptionCode(403); + $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); $request->user_id = 1; $request->url_elements = [5 => 1]; @@ -78,13 +74,12 @@ public function testThatRemovingOneselfThrowsException() $constructor->removeHostFromEvent($request, $db); } - /** - * @expectedException \Exception - * @expectedExceptionCode 404 - * @expectedExceptionMessage Event not found - */ public function testThatInvalidEventThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Event not found'); + $this->expectExceptionCode(404); + $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); $request->user_id = 1; $request->url_elements = [ @@ -103,13 +98,12 @@ public function testThatInvalidEventThrowsException() $constructor->removeHostFromEvent($request, $db); } - /** - * @expectedException \Exception - * @expectedExceptionCode 403 - * @expectedExceptionMessage You do not have permission to add hosts to this event - */ public function testThatExceptionIsThrownWhenNonAdminUserTriesToAddHostToEvent() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You do not have permission to add hosts to this event'); + $this->expectExceptionCode(403); + $controller = new \Event_hostsController(); $em = $this->getMockBuilder('EventMapper')->disableOriginalConstructor()->getMock(); @@ -127,13 +121,12 @@ public function testThatExceptionIsThrownWhenNonAdminUserTriesToAddHostToEvent() $controller->addHost($request, $db); } - /** - * @expectedException \Exception - * @expectedExceptionCode 403 - * @expectedExceptionMessage You do not have permission to remove hosts from this event - */ public function testThatUserThatIsNotAdminOnEventWillThrowException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You do not have permission to remove hosts from this event'); + $this->expectExceptionCode(403); + $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); $request->user_id = 1; $request->url_elements = [ @@ -153,13 +146,12 @@ public function testThatUserThatIsNotAdminOnEventWillThrowException() $constructor->removeHostFromEvent($request, $db); } - /** - * @expectedException \Exception - * @expectedExceptionCode 404 - * @expectedExceptionMessage No User found - */ public function testThatExceptionIsThrownWhenUnknownUserShallBeAddedAsHostToEvent() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('No User found'); + $this->expectExceptionCode(404); + $controller = new \Event_hostsController(); $em = $this->getMockBuilder('EventMapper')->disableOriginalConstructor()->getMock(); @@ -183,13 +175,12 @@ public function testThatExceptionIsThrownWhenUnknownUserShallBeAddedAsHostToEven $controller->addHost($request, $db); } - /** - * @expectedException \Exception - * @expectedExceptionCode 404 - * @expectedExceptionMessage No User found - */ public function testThatSettingUnknownUserWillThrowException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('No User found'); + $this->expectExceptionCode(404); + $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); $request->user_id = 1; $request->url_elements = [ @@ -213,13 +204,12 @@ public function testThatSettingUnknownUserWillThrowException() $constructor->removeHostFromEvent($request, $db); } - /** - * @expectedException \Exception - * @expectedExceptionCode 400 - * @expectedExceptionMessage Something went wrong - */ public function testThatExceptionIsThrownWhenEventHostMapperHasProblems() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Something went wrong'); + $this->expectExceptionCode(400); + $controller = new \Event_hostsController(); $em = $this->getMockBuilder('EventMapper')->disableOriginalConstructor()->getMock(); @@ -288,14 +278,12 @@ public function testThatViewGetsCorrectValuesWhenEverythingWorksAsExpected() $controller->addHost($request, $db); } - - /** - * @expectedException \Exception - * @expectedExceptionCode 400 - * @expectedExceptionMessage Something went wrong - */ public function testThatFailureWhileRemovingUserAsHostWillThrowException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Something went wrong'); + $this->expectExceptionCode(400); + $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); $request->user_id = 1; $request->url_elements = [ diff --git a/tests/controllers/TalkLinkControllerTest.php b/tests/controllers/TalkLinkControllerTest.php index 2d3bff78c..88c9f42ac 100644 --- a/tests/controllers/TalkLinkControllerTest.php +++ b/tests/controllers/TalkLinkControllerTest.php @@ -11,11 +11,12 @@ class TalkLinkControllerTest extends TalkBase /** * Test sending delete link where the link id is not found - * @expectedException \Exception - * @expectedExceptionCode 404 */ public function testDeleteTalkLinkWithInvalidID() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(404); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'DELETE' @@ -65,11 +66,12 @@ public function testDeleteTalkLink() /** * Test sending delete link with no permissions - * @expectedException \Exception - * @expectedExceptionCode 403 */ public function testDeleteTalkLinkNoPermissions() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(403); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'DELETE' @@ -102,12 +104,11 @@ public function testGetTalkLink() ); } - /** - * @expectedException \Exception - * @expectedExceptionCode 404 - */ public function testGetTalkLinkFails() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(404); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'GET' @@ -149,12 +150,11 @@ public function testAddTalkLink() ); } - /** - * @expectedException \Exception - * @expectedExceptionCode 400 - */ public function testAddTalkLinkWithInvalidData() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(400); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'POST' @@ -168,12 +168,11 @@ public function testAddTalkLinkWithInvalidData() ); } - /** - * @expectedException \Exception - * @expectedExceptionCode 400 - */ public function testAddTalkLinkFails() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(400); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'POST' @@ -216,12 +215,11 @@ public function testUpdateTalkLink() ); } - /** - * @expectedException \Exception - * @expectedExceptionCode 500 - */ public function testUpdateTalkLinkFails() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(500); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'PUT' diff --git a/tests/controllers/TalksControllerDeleteTest.php b/tests/controllers/TalksControllerDeleteTest.php index 8266752c5..b11ae2e45 100644 --- a/tests/controllers/TalksControllerDeleteTest.php +++ b/tests/controllers/TalksControllerDeleteTest.php @@ -12,11 +12,12 @@ class TalksControllerDeleteTest extends TalkBase { /** * @test - * @expectedExceptionCode 401 - * @expectedException \Exception */ public function removeStarFromTalkFailsWhenNotLoggedIn() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -65,11 +66,12 @@ public function removeStarFromTalksWhenLoggedIn() /** * @test - * @expectedExceptionCode 401 - * @expectedException \Exception */ public function deleteTalkWhenNotLoggedIn() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -127,11 +129,12 @@ public function deleteTalkWhichDoesntExist() /** * @test - * @expectedException \Exception - * @expectedExceptionCode 400 */ public function deleteTalkWthNoAdmin() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(400); + $request = new Request( [], [ diff --git a/tests/controllers/TalksControllerTest.php b/tests/controllers/TalksControllerTest.php index bf14bbc44..827020dcf 100644 --- a/tests/controllers/TalksControllerTest.php +++ b/tests/controllers/TalksControllerTest.php @@ -35,13 +35,12 @@ public function setUp(): void * an exception is thrown * * @return void - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage You must be logged in to create data */ public function testClaimTalkWithNoUserIdThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to create data'); + $request = new Request( [], [ @@ -61,12 +60,12 @@ public function testClaimTalkWithNoUserIdThrowsException() * an exception is thrown * * @return void - * - * @expectedException \Exception - * @expectedExceptionMessage Talk not found */ public function testClaimNonExistantTalkThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Talk not found'); + $request = new Request( [], [ @@ -103,12 +102,12 @@ public function testClaimNonExistantTalkThrowsException() * an exception is thrown * * @return void - * - * @expectedException \Exception - * @expectedExceptionMessage You must provide a display name and a username */ public function testClaimTalkWithoutUsernameThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must provide a display name and a username'); + $request = new Request( [], [ @@ -143,12 +142,12 @@ public function testClaimTalkWithoutUsernameThrowsException() * an exception is thrown * * @return void - * - * @expectedException \Exception - * @expectedExceptionMessage You must provide a display name and a username */ public function testClaimTalkWithoutDisplayNameThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must provide a display name and a username'); + $request = new Request( [], [ @@ -182,12 +181,12 @@ public function testClaimTalkWithoutDisplayNameThrowsException() * display_name that doesn't match a talk speaker, an exception is thrown * * @return void - * - * @expectedException \Exception - * @expectedExceptionMessage No speaker matching that name found */ public function testClaimTalkWithInvalidSpeakerThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('No speaker matching that name found'); + $request = new Request( [], [ @@ -228,12 +227,12 @@ public function testClaimTalkWithInvalidSpeakerThrowsException() * that has been claimed already, and Exception is thrown * * @return void - * - * @expectedException \Exception - * @expectedExceptionMessage Talk already claimed */ public function testClaimTalkAlreadyClaimedThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Talk already claimed'); + $request = new Request( [], [ @@ -278,12 +277,12 @@ public function testClaimTalkAlreadyClaimedThrowsException() * that is different to the logged in user, an Exception is thrown * * @return void - * - * @expectedException Exception - * @expectedExceptionMessage You must be the speaker or event admin to link a user to a talk */ public function testClaimTalkForSomeoneElseThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be the speaker or event admin to link a user to a talk'); + $request = new Request( [], [ @@ -346,12 +345,12 @@ public function testClaimTalkForSomeoneElseThrowsException() * that doesn't exist, an Exception is thrown * * @return void - * - * @expectedException Exception - * @expectedExceptionMessage Specified user not found */ public function testAssignTalkAsHostToNonExistentUserThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Specified user not found'); + $request = new Request( [], [ @@ -531,13 +530,12 @@ public function testAssignTalkAsHostIsSuccessful() /** * Ensures that if the setSpeakerForTalk method is called by the same user who made the claim * then an exception is thrown - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage You already have a pending claim for this talk. Please wait for an event admin to approve your claim. */ public function testApproveAssignmentAsUserWhoClaimedThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You already have a pending claim for this talk. Please wait for an event admin to approve your claim.'); + $request = new Request( [], [ @@ -598,13 +596,12 @@ public function testApproveAssignmentAsUserWhoClaimedThrowsException() /** * Ensures that if the setSpeakerForTalk method is called by a non-admin user * then an exception is thrown - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage You must be an event admin to approve this claim */ public function testApproveAssignmentAsNonAdminUserThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be an event admin to approve this claim'); + $request = new Request( [], [ @@ -666,13 +663,12 @@ public function testApproveAssignmentAsNonAdminUserThrowsException() /** * Ensures that if the setSpeakerForTalk method is called by the host who assigned the talk * then an exception is thrown - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage You must be the talk speaker to approve this assignment */ public function testApproveClaimAsHostWhoAssignedThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be the talk speaker to approve this assignment'); + $request = new Request( [], [ @@ -981,12 +977,11 @@ public function getComments() ]; } - /** - * @expectedException Exception - * @expectedExceptionCode 401 - */ public function testNotLoggedInPostAction() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -1000,12 +995,11 @@ public function testNotLoggedInPostAction() $talks_controller->postAction($request, $db); } - /** - * @expectedException Exception - * @expectedExceptionCode 400 - */ public function testNotSendingMessage() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(400); + $request = new Request( [], [ @@ -1032,12 +1026,11 @@ public function testNotSendingMessage() $talks_controller->postAction($request, $db); } - /** - * @expectedException Exception - * @expectedExceptionCode 400 - */ public function testNotSendingRating() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(400); + $request = new Request( [], [ @@ -1324,12 +1317,11 @@ public function testSearchByTitle() $this->assertSame($expected, $output); } - /** - * @expectedException Exception - * @expectedExceptionCode 405 - */ public function testGenericTalkList() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(405); + $request = new Request( [], [ diff --git a/tests/controllers/TokenControllerTest.php b/tests/controllers/TokenControllerTest.php index 528cdb412..1fb6ef66c 100644 --- a/tests/controllers/TokenControllerTest.php +++ b/tests/controllers/TokenControllerTest.php @@ -16,25 +16,23 @@ public function setup(): void $this->pdo = $this->getMockBuilder('PDO')->disableOriginalConstructor()->getMock(); } - /** - * @expectedException \Exception - * @expectedExceptionCode 401 - * @expectedExceptionMessage You must be logged in - */ public function testThatDeletingATokenWithoutLoginThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in'); + $this->expectExceptionCode(401); + $usersController = new \TokenController(); $usersController->revokeToken($this->request, $this->pdo); } - /** - * @expectedException \Exception - * @expectedExceptionCode 401 - * @expectedExceptionMessage You must be logged in - */ public function testThatRetrievingTokensWithoutLoginThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in'); + $this->expectExceptionCode(401); + $usersController = new \TokenController(); $usersController->listTokensForUser($this->request, $this->pdo); diff --git a/tests/controllers/UsersControllerTest.php b/tests/controllers/UsersControllerTest.php index 997dae781..3f1714d9f 100644 --- a/tests/controllers/UsersControllerTest.php +++ b/tests/controllers/UsersControllerTest.php @@ -12,13 +12,12 @@ class UsersControllerTest extends TestCase * an exception is thrown * * @return void - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage You must be logged in to delete data */ public function testDeleteUserWithNoUserIdThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to delete data'); + $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); $usersController = new \UsersController(); @@ -32,13 +31,12 @@ public function testDeleteUserWithNoUserIdThrowsException() * non-admin, an exception is thrown * * @return void - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage You do not have permission to do that */ public function testDeleteUserWithNonAdminIdThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You do not have permission to do that'); + $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); $request->user_id = 2; $usersController = new \UsersController(); @@ -64,13 +62,12 @@ public function testDeleteUserWithNonAdminIdThrowsException() * admin, but the delete fails, then an exception is thrown * * @return void - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage There was a problem trying to delete the user */ public function testDeleteUserWithAdminAccessThrowsExceptionOnFailedDelete() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('There was a problem trying to delete the user'); + $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); $request->user_id = 1; $usersController = new \UsersController(); @@ -236,14 +233,13 @@ public function testThatUserDataIsNotDoubleEscapedOnUserEdit() * an exception is thrown * * @return void - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage You must be logged in to change a user account - * @expectedExceptionCode 401 */ public function testSetTrustedWithNoUserIdThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to change a user account'); + $this->expectExceptionCode(401); + $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/4/trusted", 'REQUEST_METHOD' => 'POST']); $usersController = new \UsersController(); @@ -258,14 +254,13 @@ public function testSetTrustedWithNoUserIdThrowsException() * non-admin, an exception is thrown * * @return void - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage You must be an admin to change a user's trusted state - * @expectedExceptionCode 403 */ public function testSetTrustedWithNonAdminIdThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage("You must be an admin to change a user's trusted state"); + $this->expectExceptionCode(403); + $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/4/trusted", 'REQUEST_METHOD' => 'POST']); $request->user_id = 2; $usersController = new \UsersController(); @@ -291,14 +286,13 @@ public function testSetTrustedWithNonAdminIdThrowsException() * but without a trusted state, an exception is thrown * * @return void - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage You must provide a trusted state - * @expectedExceptionCode 400 */ public function testSetTrustedWithoutStateThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must provide a trusted state'); + $this->expectExceptionCode(400); + $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); $request->method('getUserId')->willReturn(2); $request->method('getParameter') @@ -326,14 +320,13 @@ public function testSetTrustedWithoutStateThrowsException() * but the update fails, an exception is thrown * * @return void - * - * @test - * @expectedException \Exception - * @expectedExceptionMessage Unable to update status - * @expectedExceptionCode 500 */ public function testSetTrustedWithFailureThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Unable to update status'); + $this->expectExceptionCode(500); + $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); $request->method('getUserId')->willReturn(2); $request->method('getParameter') diff --git a/tests/inc/RequestTest.php b/tests/inc/RequestTest.php index c1a1df0f2..3e110734c 100644 --- a/tests/inc/RequestTest.php +++ b/tests/inc/RequestTest.php @@ -420,12 +420,13 @@ public function schemeProvider() * @return void * * @test - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid Authorization Header - * @expectedExceptionCode 400 */ public function ifIdentificationDoesNotHaveTwoPartsExceptionIsThrown() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid Authorization Header'); + $this->expectExceptionCode(400); + $request = new \Request($this->config, ['HTTPS' => 'on']); $request->identifyUser('This is a bad header'); } @@ -437,12 +438,13 @@ public function ifIdentificationDoesNotHaveTwoPartsExceptionIsThrown() * @return void * * @test - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Unknown Authorization Header Received - * @expectedExceptionCode 400 */ public function ifIdentificationHeaderDoesNotStartWithOauthThrowException() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Unknown Authorization Header Received'); + $this->expectExceptionCode(400); + $request = new \Request($this->config, ['HTTPS' => 'on']); $request->identifyUser('Auth Me'); } @@ -492,11 +494,12 @@ public function getOauthModelProvidesAnOauthModel() * @return void * * @test - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Db Must be provided to get Oauth Model */ public function callingGetOauthModelWithoutADatabaseAdapterThrowsAnException() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Db Must be provided to get Oauth Model'); + $request = new \Request($this->config, []); $request->getOauthModel(); } diff --git a/tests/models/OauthModelTest.php b/tests/models/OauthModelTest.php index 8a89831d0..4e16e0e53 100644 --- a/tests/models/OauthModelTest.php +++ b/tests/models/OauthModelTest.php @@ -34,12 +34,11 @@ public function testWrongPasswordReturnsFalse() ); } - /** - * @expectedException Exception - * @expectedExceptionCode 401 - */ public function testWrongUserThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionCode(401); + $stmt = $this->getMockBuilder(PDOStatement::class)->getMock(); $stmt->method('execute')->willReturn(true); $stmt->method('fetch')->willReturn( From ec85bdf99cab6775860284056e0ec0d7247292e0 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sat, 23 Mar 2019 22:59:15 -0500 Subject: [PATCH 04/47] Remove unused 'use' statement --- tests/controllers/EventHostsControllerTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/controllers/EventHostsControllerTest.php b/tests/controllers/EventHostsControllerTest.php index 2a5a9870d..cbfeafcaf 100644 --- a/tests/controllers/EventHostsControllerTest.php +++ b/tests/controllers/EventHostsControllerTest.php @@ -2,7 +2,6 @@ namespace JoindinTest\Controller; -use Mockery as M; use PHPUnit\Framework\TestCase; class EventHostsControllerTest extends TestCase From afa66e5899aed935fa434b1bb0131d41a1a31aca Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sat, 23 Mar 2019 23:52:08 -0500 Subject: [PATCH 05/47] Add missing exception messages to tests --- tests/controllers/TalkLinkControllerTest.php | 6 ++++++ tests/controllers/TalksControllerDeleteTest.php | 3 +++ tests/controllers/TalksControllerTest.php | 4 ++++ tests/models/OauthModelTest.php | 1 + 4 files changed, 14 insertions(+) diff --git a/tests/controllers/TalkLinkControllerTest.php b/tests/controllers/TalkLinkControllerTest.php index 88c9f42ac..a0140e3a7 100644 --- a/tests/controllers/TalkLinkControllerTest.php +++ b/tests/controllers/TalkLinkControllerTest.php @@ -15,6 +15,7 @@ class TalkLinkControllerTest extends TalkBase public function testDeleteTalkLinkWithInvalidID() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('Talk Link ID not found'); $this->expectExceptionCode(404); $this->makeRequest( @@ -70,6 +71,7 @@ public function testDeleteTalkLink() public function testDeleteTalkLinkNoPermissions() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('You do not have permission to add links to this talk'); $this->expectExceptionCode(403); $this->makeRequest( @@ -107,6 +109,7 @@ public function testGetTalkLink() public function testGetTalkLinkFails() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('ID not found'); $this->expectExceptionCode(404); $this->makeRequest( @@ -153,6 +156,7 @@ public function testAddTalkLink() public function testAddTalkLinkWithInvalidData() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('Missing required fields URL OR Display Name'); $this->expectExceptionCode(400); $this->makeRequest( @@ -171,6 +175,7 @@ public function testAddTalkLinkWithInvalidData() public function testAddTalkLinkFails() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('The Link has not been inserted'); $this->expectExceptionCode(400); $this->makeRequest( @@ -218,6 +223,7 @@ public function testUpdateTalkLink() public function testUpdateTalkLinkFails() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('Update of Link ID Failed'); $this->expectExceptionCode(500); $this->makeRequest( diff --git a/tests/controllers/TalksControllerDeleteTest.php b/tests/controllers/TalksControllerDeleteTest.php index b11ae2e45..947b3a9a2 100644 --- a/tests/controllers/TalksControllerDeleteTest.php +++ b/tests/controllers/TalksControllerDeleteTest.php @@ -16,6 +16,7 @@ class TalksControllerDeleteTest extends TalkBase public function removeStarFromTalkFailsWhenNotLoggedIn() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to remove data'); $this->expectExceptionCode(401); $request = new Request( @@ -70,6 +71,7 @@ public function removeStarFromTalksWhenLoggedIn() public function deleteTalkWhenNotLoggedIn() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to remove data'); $this->expectExceptionCode(401); $request = new Request( @@ -133,6 +135,7 @@ public function deleteTalkWhichDoesntExist() public function deleteTalkWthNoAdmin() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('You do not have permission to do that'); $this->expectExceptionCode(400); $request = new Request( diff --git a/tests/controllers/TalksControllerTest.php b/tests/controllers/TalksControllerTest.php index 827020dcf..274ab6f4c 100644 --- a/tests/controllers/TalksControllerTest.php +++ b/tests/controllers/TalksControllerTest.php @@ -980,6 +980,7 @@ public function getComments() public function testNotLoggedInPostAction() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to create data'); $this->expectExceptionCode(401); $request = new Request( @@ -998,6 +999,7 @@ public function testNotLoggedInPostAction() public function testNotSendingMessage() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('The field "comment" is required'); $this->expectExceptionCode(400); $request = new Request( @@ -1029,6 +1031,7 @@ public function testNotSendingMessage() public function testNotSendingRating() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('The field "rating" is required'); $this->expectExceptionCode(400); $request = new Request( @@ -1320,6 +1323,7 @@ public function testSearchByTitle() public function testGenericTalkList() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('Generic talks listing not supported'); $this->expectExceptionCode(405); $request = new Request( diff --git a/tests/models/OauthModelTest.php b/tests/models/OauthModelTest.php index 4e16e0e53..f1710759a 100644 --- a/tests/models/OauthModelTest.php +++ b/tests/models/OauthModelTest.php @@ -37,6 +37,7 @@ public function testWrongPasswordReturnsFalse() public function testWrongUserThrowsException() { $this->expectException(\Exception::class); + $this->expectExceptionMessage('Not verified'); $this->expectExceptionCode(401); $stmt = $this->getMockBuilder(PDOStatement::class)->getMock(); From 1f951e4944e5f777abe739b88a02997060b51f58 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 00:44:29 -0500 Subject: [PATCH 06/47] Add missing exception codes to tests --- tests/controllers/TalksControllerTest.php | 11 +++++++++++ tests/controllers/UsersControllerTest.php | 3 +++ tests/inc/RequestTest.php | 1 + 3 files changed, 15 insertions(+) diff --git a/tests/controllers/TalksControllerTest.php b/tests/controllers/TalksControllerTest.php index 274ab6f4c..e6ad6188d 100644 --- a/tests/controllers/TalksControllerTest.php +++ b/tests/controllers/TalksControllerTest.php @@ -40,6 +40,7 @@ public function testClaimTalkWithNoUserIdThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You must be logged in to create data'); + $this->expectExceptionCode(401); $request = new Request( [], @@ -65,6 +66,7 @@ public function testClaimNonExistantTalkThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Talk not found'); + $this->expectExceptionCode(404); $request = new Request( [], @@ -107,6 +109,7 @@ public function testClaimTalkWithoutUsernameThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You must provide a display name and a username'); + $this->expectExceptionCode(400); $request = new Request( [], @@ -147,6 +150,7 @@ public function testClaimTalkWithoutDisplayNameThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You must provide a display name and a username'); + $this->expectExceptionCode(400); $request = new Request( [], @@ -186,6 +190,7 @@ public function testClaimTalkWithInvalidSpeakerThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('No speaker matching that name found'); + $this->expectExceptionCode(422); $request = new Request( [], @@ -232,6 +237,7 @@ public function testClaimTalkAlreadyClaimedThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Talk already claimed'); + $this->expectExceptionCode(422); $request = new Request( [], @@ -282,6 +288,7 @@ public function testClaimTalkForSomeoneElseThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You must be the speaker or event admin to link a user to a talk'); + $this->expectExceptionCode(401); $request = new Request( [], @@ -350,6 +357,7 @@ public function testAssignTalkAsHostToNonExistentUserThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Specified user not found'); + $this->expectExceptionCode(404); $request = new Request( [], @@ -535,6 +543,7 @@ public function testApproveAssignmentAsUserWhoClaimedThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You already have a pending claim for this talk. Please wait for an event admin to approve your claim.'); + $this->expectExceptionCode(401); $request = new Request( [], @@ -601,6 +610,7 @@ public function testApproveAssignmentAsNonAdminUserThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You must be an event admin to approve this claim'); + $this->expectExceptionCode(401); $request = new Request( [], @@ -668,6 +678,7 @@ public function testApproveClaimAsHostWhoAssignedThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You must be the talk speaker to approve this assignment'); + $this->expectExceptionCode(401); $request = new Request( [], diff --git a/tests/controllers/UsersControllerTest.php b/tests/controllers/UsersControllerTest.php index 3f1714d9f..9a8ca9c49 100644 --- a/tests/controllers/UsersControllerTest.php +++ b/tests/controllers/UsersControllerTest.php @@ -17,6 +17,7 @@ public function testDeleteUserWithNoUserIdThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You must be logged in to delete data'); + $this->expectExceptionCode(401); $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); @@ -36,6 +37,7 @@ public function testDeleteUserWithNonAdminIdThrowsException() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You do not have permission to do that'); + $this->expectExceptionCode(403); $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); $request->user_id = 2; @@ -67,6 +69,7 @@ public function testDeleteUserWithAdminAccessThrowsExceptionOnFailedDelete() { $this->expectException(\Exception::class); $this->expectExceptionMessage('There was a problem trying to delete the user'); + $this->expectExceptionCode(400); $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); $request->user_id = 1; diff --git a/tests/inc/RequestTest.php b/tests/inc/RequestTest.php index 3e110734c..726f8e24a 100644 --- a/tests/inc/RequestTest.php +++ b/tests/inc/RequestTest.php @@ -499,6 +499,7 @@ public function callingGetOauthModelWithoutADatabaseAdapterThrowsAnException() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Db Must be provided to get Oauth Model'); + $this->expectExceptionCode(0); $request = new \Request($this->config, []); $request->getOauthModel(); From 0a2b5873ec497a79771b4f2e748195fa467cbbfc Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 00:49:34 -0500 Subject: [PATCH 07/47] Fix spelling error in test name --- tests/controllers/EventHostsControllerTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/controllers/EventHostsControllerTest.php b/tests/controllers/EventHostsControllerTest.php index cbfeafcaf..d794ae121 100644 --- a/tests/controllers/EventHostsControllerTest.php +++ b/tests/controllers/EventHostsControllerTest.php @@ -347,7 +347,7 @@ public function testThatRemovingUserAsHostSetsCorrectValues() $this->assertNull($constructor->removeHostFromEvent($request, $db)); } - public function testThatGetingEventHostWapperMithoutSettingFirstWorksAsExpected() + public function testThatGettingEventHostWapperMithoutSettingFirstWorksAsExpected() { $controller = new \Event_hostsController(); @@ -362,7 +362,7 @@ public function testThatGetingEventHostWapperMithoutSettingFirstWorksAsExpected( $this->assertSame($automatedEventHostMapper, $controller->getEventHostMapper($request, $db)); } - public function testThatGetingUserMapperWithoutSettingFirstWorksAsExpected() + public function testThatGettingUserMapperWithoutSettingFirstWorksAsExpected() { $controller = new \Event_hostsController(); @@ -377,7 +377,7 @@ public function testThatGetingUserMapperWithoutSettingFirstWorksAsExpected() $this->assertSame($automatedUserMapper, $controller->getUserMapper($request, $db)); } - public function testThatGetingEventMapperWithoutSettingFirstWorksAsExpected() + public function testThatGettingEventMapperWithoutSettingFirstWorksAsExpected() { $controller = new \Event_hostsController(); From e569d4be0e850a77f81b1d21871af480f197ed8d Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 01:47:46 -0500 Subject: [PATCH 08/47] Convert getMock to createMock since the old getMock is no longer part of PHPUnit --- tests/routers/RouteTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/routers/RouteTest.php b/tests/routers/RouteTest.php index ab7132d5a..125d3a97a 100644 --- a/tests/routers/RouteTest.php +++ b/tests/routers/RouteTest.php @@ -168,7 +168,7 @@ public function testDispatch(array $config, $controller, $action, Request $reque */ private function getRequest($urlElement) { - $request = $this->getMock('Request', array('getUrlElement'), array(), '', false); + $request = $this->createMock('Request', array('getUrlElement'), array(), '', false); $request->expects($this->any()) ->method('getUrlElement') From 02218ea0a76040d7d5b9d1cf7e4dbbe6f38f1620 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 22:15:50 -0500 Subject: [PATCH 09/47] Rename test to include the "test" prefix This is to match our other tests --- tests/controllers/ContactControllerTest.php | 3 +- .../controllers/TalksControllerDeleteTest.php | 30 +--- tests/inc/ContainerFactoryTest.php | 14 +- tests/inc/RequestTest.php | 136 +++++------------- tests/inc/TalkCommentEmailServiceTest.php | 16 +-- tests/services/NullSpamCheckServiceTest.php | 5 +- 6 files changed, 52 insertions(+), 152 deletions(-) diff --git a/tests/controllers/ContactControllerTest.php b/tests/controllers/ContactControllerTest.php index e2274c4cd..771c5cadb 100644 --- a/tests/controllers/ContactControllerTest.php +++ b/tests/controllers/ContactControllerTest.php @@ -8,7 +8,6 @@ class ContactControllerTest extends TestCase { /** * @dataProvider dataProvider - * @test * * @param bool $isClientPermittedPasswordGrant * @param array $returnValueMap @@ -20,7 +19,7 @@ class ContactControllerTest extends TestCase * * @throws \Exception */ - public function contactWorksAsExpected( + public function testContactWorksAsExpected( $isClientPermittedPasswordGrant, array $returnValueMap = [], $isCommentAcceptable = false, diff --git a/tests/controllers/TalksControllerDeleteTest.php b/tests/controllers/TalksControllerDeleteTest.php index 947b3a9a2..c2af64f61 100644 --- a/tests/controllers/TalksControllerDeleteTest.php +++ b/tests/controllers/TalksControllerDeleteTest.php @@ -10,10 +10,7 @@ class TalksControllerDeleteTest extends TalkBase { - /** - * @test - */ - public function removeStarFromTalkFailsWhenNotLoggedIn() + public function testRemoveStarFromTalkFailsWhenNotLoggedIn() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You must be logged in to remove data'); @@ -33,10 +30,7 @@ public function removeStarFromTalkFailsWhenNotLoggedIn() $talks_controller->deleteTalkStarred($request, $db); } - /** - * @test - */ - public function removeStarFromTalksWhenLoggedIn() + public function testRemoveStarFromTalksWhenLoggedIn() { $request = new Request( [], @@ -65,10 +59,7 @@ public function removeStarFromTalksWhenLoggedIn() $talks_controller->deleteTalkStarred($request, $db); } - /** - * @test - */ - public function deleteTalkWhenNotLoggedIn() + public function testDeleteTalkWhenNotLoggedIn() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You must be logged in to remove data'); @@ -88,10 +79,7 @@ public function deleteTalkWhenNotLoggedIn() $talks_controller->deleteTalk($request, $db); } - /** - * @test - */ - public function deleteTalkWhichDoesntExist() + public function testDeleteTalkWhichDoesntExist() { $httpRequest = [ 'REQUEST_URI' => 'http://api.dev.joind.in/v2.1/talks/79', @@ -129,10 +117,7 @@ public function deleteTalkWhichDoesntExist() $this->assertNull($talks_controller->deleteTalk($request, $db)); } - /** - * @test - */ - public function deleteTalkWthNoAdmin() + public function testDeleteTalkWthNoAdmin() { $this->expectException(\Exception::class); $this->expectExceptionMessage('You do not have permission to do that'); @@ -163,10 +148,7 @@ public function deleteTalkWthNoAdmin() $talks_controller->deleteTalk($request, $db); } - /** - * @test - */ - public function deleteTalkWithAdmin() + public function testDeleteTalkWithAdmin() { $httpRequest = [ 'REQUEST_URI' => 'http://api.dev.joind.in/v2.1/talks/79', diff --git a/tests/inc/ContainerFactoryTest.php b/tests/inc/ContainerFactoryTest.php index e4726ab54..7189a3020 100644 --- a/tests/inc/ContainerFactoryTest.php +++ b/tests/inc/ContainerFactoryTest.php @@ -26,45 +26,39 @@ class ContainerFactoryTest extends TestCase 'website_url' => 'www.example.com' ]; - /** - * @test - */ - public function containerIsCreated() + public function testContainerIsCreated() { $this->assertInstanceOf(ContainerInterface::class, \ContainerFactory::build($this->config)); } /** - * @test * @covers ContainerFactory::build * * @dataProvider dataProvider * @param string $service */ - public function serviceIsDefined($service) + public function testServiceIsDefined($service) { $container = \ContainerFactory::build($this->config, true); $this->assertTrue($container->has($service)); } /** - * @test * @covers ContainerFactory::build * * @dataProvider dataProvider * @param string $service */ - public function servicesCanBeCreated($service) + public function testServicesCanBeCreated($service) { $container = \ContainerFactory::build($this->config, true); $this->assertInstanceOf($service, $container->get($service)); } /** - * @test * @covers ContainerFactory::build */ - public function spamCheckServiceIsNullCheckerWhenDisabled() + public function testSpamCheckServiceIsNullCheckerWhenDisabled() { $container = \ContainerFactory::build([], true); $this->assertTrue($container->has(\SpamCheckServiceInterface::class)); diff --git a/tests/inc/RequestTest.php b/tests/inc/RequestTest.php index 726f8e24a..e1e2b173a 100644 --- a/tests/inc/RequestTest.php +++ b/tests/inc/RequestTest.php @@ -22,10 +22,9 @@ public function setUp(): void * * @return void * - * @test * @backupGlobals */ - public function getParameterReturnsValueOfRequestedParameter() + public function testGetParameterReturnsValueOfRequestedParameter() { $queryString = http_build_query( array( @@ -48,10 +47,8 @@ public function getParameterReturnsValueOfRequestedParameter() * was not set. * * @return void - * - * @test */ - public function getParameterReturnsDefaultIfParameterNotSet() + public function testGetParameterReturnsDefaultIfParameterNotSet() { $uniq = uniqid(); $request = new \Request($this->config, []); @@ -68,11 +65,10 @@ public function getParameterReturnsDefaultIfParameterNotSet() * * @return void * - * @test * @dataProvider methodProvider * @backupGlobals */ - public function requestMethodIsProperlyLoaded($method) + public function testRequestMethodIsProperlyLoaded($method) { $request = new \Request($this->config, ['REQUEST_METHOD' => $method]); @@ -86,10 +82,9 @@ public function requestMethodIsProperlyLoaded($method) * * @return void * - * @test * @dataProvider methodProvider */ - public function setVerbAllowsForSettingRequestVerb($verb) + public function testSetVerbAllowsForSettingRequestVerb($verb) { $request = new \Request($this->config, []); $request->setVerb($verb); @@ -102,9 +97,8 @@ public function setVerbAllowsForSettingRequestVerb($verb) * * @return void * - * @test */ - public function setVerbIsFluent() + public function testSetVerbIsFluent() { $request = new \Request($this->config, []); $this->assertSame($request, $request->setVerb(uniqid())); @@ -133,10 +127,8 @@ public function methodProvider() * not found on getUrlElement * * @return void - * - * @test */ - public function getUrlElementReturnsDefaultIfIndexIsNotFound() + public function testGetUrlElementReturnsDefaultIfIndexIsNotFound() { $request = new \Request($this->config, []); @@ -152,10 +144,9 @@ public function getUrlElementReturnsDefaultIfIndexIsNotFound() * * @return void * - * @test * @backupGlobals */ - public function getUrlElementReturnsRequestedElementFromPath() + public function testGetUrlElementReturnsRequestedElementFromPath() { $server = ['PATH_INFO' => 'foo/bar/baz']; $request = new \Request($this->config, $server); @@ -169,10 +160,9 @@ public function getUrlElementReturnsRequestedElementFromPath() * * @return void * - * @test * @backupGlobals */ - public function acceptsHeadersAreParsedCorrectly() + public function testAcceptsHeadersAreParsedCorrectly() { $server = ['HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8']; @@ -191,10 +181,9 @@ public function acceptsHeadersAreParsedCorrectly() * * @return void * - * @test * @backupGlobals */ - public function preferredContentTypeOfReturnsADesiredFormatIfItIsAccepted() + public function testPreferredContentTypeOfReturnsADesiredFormatIfItIsAccepted() { $server = ['HTTP_ACCEPT' => 'text/text,application/xhtml+xml,application/json;q=0.9,*/*;q=0.8']; @@ -217,10 +206,9 @@ public function preferredContentTypeOfReturnsADesiredFormatIfItIsAccepted() * * @return void * - * @test * @backupGlobals */ - public function ifPreferredFormatIsNotAcceptedReturnJson() + public function testIfPreferredFormatIsNotAcceptedReturnJson() { $server =['HTTP_ACCEPT' => 'text/text,application/xhtml+xml,application/json;q=0.9,*/*;q=0.8']; @@ -239,10 +227,9 @@ public function ifPreferredFormatIsNotAcceptedReturnJson() * * @return void * - * @test * @backupGlobals */ - public function hostIsSetCorrectlyFromTheHeaders() + public function testHostIsSetCorrectlyFromTheHeaders() { $server = ['HTTP_HOST' => 'joind.in']; $request = new \Request($this->config, $server); @@ -255,10 +242,8 @@ public function hostIsSetCorrectlyFromTheHeaders() * Ensures that the setHost method is fluent * * @return void - * - * @test */ - public function setHostIsFluent() + public function testSetHostIsFluent() { $request = new \Request($this->config, []); $this->assertSame($request, $request->setHost(uniqid())); @@ -268,10 +253,8 @@ public function setHostIsFluent() * Ensures that setHost can be used to set a host * * @return void - * - * @test */ - public function hostCanBeSetWithSetHost() + public function testHostCanBeSetWithSetHost() { $host = uniqid() . '.com'; $request = new \Request($this->config, []); @@ -288,11 +271,10 @@ public function hostCanBeSetWithSetHost() * * @return void * - * @test * @dataProvider postPutProvider * @backupGlobals */ - public function jsonBodyIsParsedAsParameters($method) + public function testJsonBodyIsParsedAsParameters($method) { $body = json_encode( array( @@ -340,10 +322,8 @@ public function postPutProvider() * Ensures that the scheme is set to http unless https is on * * @return void - * - * @test */ - public function schemeIsHttpByDefault() + public function testSchemeIsHttpByDefault() { $request = new \Request($this->config, []); @@ -357,10 +337,9 @@ public function schemeIsHttpByDefault() * * @return void * - * @test * @backupGlobals */ - public function schemeIsHttpsIfHttpsValueIsOn() + public function testSchemeIsHttpsIfHttpsValueIsOn() { $server = ['HTTPS' => 'on']; $request = new \Request($this->config, $server); @@ -373,10 +352,8 @@ public function schemeIsHttpsIfHttpsValueIsOn() * Ensures setScheme provides a fluent interface * * @return void - * - * @test */ - public function setSchemeIsFluent() + public function testSetSchemeIsFluent() { $request = new \Request($this->config, []); $this->assertSame($request, $request->setScheme('http://')); @@ -389,10 +366,9 @@ public function setSchemeIsFluent() * * @return void * - * @test * @dataProvider schemeProvider */ - public function schemeCanBeSetBySetSchemeMethod($scheme) + public function testSchemeCanBeSetBySetSchemeMethod($scheme) { $request = new \Request($this->config, []); $request->setScheme($scheme); @@ -418,10 +394,8 @@ public function schemeProvider() * doesn't have two parts * * @return void - * - * @test */ - public function ifIdentificationDoesNotHaveTwoPartsExceptionIsThrown() + public function testIfIdentificationDoesNotHaveTwoPartsExceptionIsThrown() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid Authorization Header'); @@ -436,10 +410,8 @@ public function ifIdentificationDoesNotHaveTwoPartsExceptionIsThrown() * start with oauth * * @return void - * - * @test */ - public function ifIdentificationHeaderDoesNotStartWithOauthThrowException() + public function testIfIdentificationHeaderDoesNotStartWithOauthThrowException() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Unknown Authorization Header Received'); @@ -453,10 +425,8 @@ public function ifIdentificationHeaderDoesNotStartWithOauthThrowException() * Ensures that identifyUser returns false if the request is HTTP * * @return void - * - * @test */ - public function ifRequestIsntHTTPSReturnsFalse() + public function testIfRequestIsntHTTPSReturnsFalse() { $config = array_merge($this->config, array('mode' => 'production')); $request = new \Request($config, []); @@ -469,10 +439,8 @@ public function ifRequestIsntHTTPSReturnsFalse() * is returned * * @return void - * - * @test */ - public function getOauthModelProvidesAnOauthModel() + public function testGetOauthModelProvidesAnOauthModel() { // Please see below for explanation of why we're mocking a "mock" PDO // class @@ -492,10 +460,8 @@ public function getOauthModelProvidesAnOauthModel() * set, and no PDO adapter is provided, an exception is thrown * * @return void - * - * @test */ - public function callingGetOauthModelWithoutADatabaseAdapterThrowsAnException() + public function testCallingGetOauthModelWithoutADatabaseAdapterThrowsAnException() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Db Must be provided to get Oauth Model'); @@ -509,10 +475,8 @@ public function callingGetOauthModelWithoutADatabaseAdapterThrowsAnException() * Ensures that the setOauthModel method is fluent * * @return void - * - * @test */ - public function setOauthModelMethodIsFluent() + public function testSetOauthModelMethodIsFluent() { /* @var $mockOauth \OAuthModel */ $mockOauth = $this->getMockBuilder('OAuthModel')->disableOriginalConstructor()->getMock(); @@ -526,10 +490,8 @@ public function setOauthModelMethodIsFluent() * to be set and retrieved * * @return void - * - * @test */ - public function setOauthModelAllowsSettingOfOauthModel() + public function testSetOauthModelAllowsSettingOfOauthModel() { /* @var $mockOauth \OAuthModel */ $mockOauth = $this->getMockBuilder('OAuthModel')->disableOriginalConstructor()->getMock(); @@ -544,10 +506,8 @@ public function setOauthModelAllowsSettingOfOauthModel() * using the oauth token type * * @return void - * - * @test */ - public function identifyUserWithOauthTokenTypeSetsUserIdForValidHeader() + public function testIdentifyUserWithOauthTokenTypeSetsUserIdForValidHeader() { $request = new \Request($this->config, ['HTTPS' => 'on']); $mockOauth = $this->getMockBuilder('OAuthModel')->disableOriginalConstructor()->getMock(); @@ -569,10 +529,8 @@ public function identifyUserWithOauthTokenTypeSetsUserIdForValidHeader() * using the bearer token type * * @return void - * - * @test */ - public function identifyUserWithBearerTokenTypeSetsUserIdForValidHeader() + public function testIdentifyUserWithBearerTokenTypeSetsUserIdForValidHeader() { $request = new \Request($this->config, ['HTTPS' => 'on']); $mockOauth = $this->getMockBuilder('OAuthModel')->disableOriginalConstructor()->getMock(); @@ -593,10 +551,8 @@ public function identifyUserWithBearerTokenTypeSetsUserIdForValidHeader() * Ensures that the setUserId method is fluent * * @return void - * - * @test */ - public function setUserIdIsFluent() + public function testSetUserIdIsFluent() { $request = new \Request($this->config, []); $this->assertSame($request, $request->setUserId('TheUserToSet')); @@ -607,10 +563,8 @@ public function setUserIdIsFluent() * retrieved with getUserId * * @return void - * - * @test */ - public function setUserIdAllowsForSettingOfUserId() + public function testSetUserIdAllowsForSettingOfUserId() { $request = new \Request($this->config, []); $user = uniqid(); @@ -623,10 +577,8 @@ public function setUserIdAllowsForSettingOfUserId() * Ensures the setPathInfo method allows setting of a path * * @return void - * - * @test */ - public function setPathInfoAllowsSettingOfPathInfo() + public function testSetPathInfoAllowsSettingOfPathInfo() { $path = uniqid() . '/' . uniqid() . '/' . uniqid(); $parts = explode('/', $path); @@ -645,10 +597,8 @@ public function setPathInfoAllowsSettingOfPathInfo() * Ensures the setPath method is fluent * * @return void - * - * @test */ - public function setPathIsFluent() + public function testSetPathIsFluent() { $request = new \Request($this->config, []); $this->assertSame($request, $request->setPathInfo(uniqid())); @@ -658,10 +608,8 @@ public function setPathIsFluent() * Ensures the setAccept header sets the accept variable * * @return void - * - * @test */ - public function setAcceptSetsTheAcceptVariable() + public function testSetAcceptSetsTheAcceptVariable() { $accept = uniqid() . ',' . uniqid() . ',' . uniqid(); $acceptParts = explode(',', $accept); @@ -679,10 +627,8 @@ public function setAcceptSetsTheAcceptVariable() * Ensures that the setAccept method is fluent * * @return void - * - * @test */ - public function setAcceptsIsFluent() + public function testSetAcceptsIsFluent() { $request = new \Request($this->config, []); $this->assertSame($request, $request->setAccept(uniqid())); @@ -692,10 +638,8 @@ public function setAcceptsIsFluent() * Ensures the setBase method allows setting of the base variable * * @return void - * - * @test */ - public function setBaseAllowsSettingOfBase() + public function testSetBaseAllowsSettingOfBase() { $request = new \Request($this->config, []); $base = uniqid(); @@ -708,10 +652,8 @@ public function setBaseAllowsSettingOfBase() * Ensures the setBase method is fluent * * @return void - * - * @test */ - public function setBaseIsFluent() + public function testSetBaseIsFluent() { $request = new \Request($this->config, []); $this->assertSame($request, $request->setBase(uniqid())); @@ -790,8 +732,6 @@ public function getViewProvider() * @param string $accept An HTTP Accept header * @param \ApiView|null $view A plan getter/setter test * @param boolean $skip Set to true to skip the test - * - * @test */ public function testGetView( array $parameters = array(), @@ -852,8 +792,6 @@ public function getSetFormatChoicesProvider() * * @param array $expected * @param array|null $choices - * - * @test */ public function testGetSetFormatChoices( array $expected, @@ -895,10 +833,8 @@ public function testGetSetAccessToken() /** * Adding coverage for the case where PATH_INFO doesn't exist in $_SERVER but * REQUEST_URI does. - * - * @test */ - public function constructorParsesRequestUri() + public function testConstructorParsesRequestUri() { $server = ['REQUEST_URI' => '/v2/one/two?three=four']; $request = new \Request($this->config, $server); diff --git a/tests/inc/TalkCommentEmailServiceTest.php b/tests/inc/TalkCommentEmailServiceTest.php index 41a9e9101..cf877b057 100644 --- a/tests/inc/TalkCommentEmailServiceTest.php +++ b/tests/inc/TalkCommentEmailServiceTest.php @@ -26,10 +26,8 @@ class TalkCommentEmailServiceTest extends Testcase /** * Check that we can create the service - * - * @test */ - public function createService() + public function testCreateService() { $recipients = ["test@joind.in"]; $talk = new TalkModel(["talk_title" => "sample talk"]); @@ -41,10 +39,8 @@ public function createService() /** * Test email override - * - * @test */ - public function createServiceWithEmailRedirect() + public function testCreateServiceWithEmailRedirect() { $config = $this->config; $config["email"]["forward_all_to"] = "blackhole@joind.in"; @@ -58,10 +54,8 @@ public function createServiceWithEmailRedirect() /** * Test replacements work into templates - * - * @test */ - public function templateReplacements() + public function testTemplateReplacements() { $recipients = ["test@joind.in"]; $talk = new TalkModel(["talk_title" => "sample talk"]); @@ -86,10 +80,8 @@ public function templateReplacements() /** * Should be able to get markdown to HTML - * - * @test */ - public function markdownTransform() + public function testMarkdownTransform() { $markdown = "A *sunny* day"; $recipients = ["test@joind.in"]; diff --git a/tests/services/NullSpamCheckServiceTest.php b/tests/services/NullSpamCheckServiceTest.php index 70eb7c7a7..dc8300b6d 100644 --- a/tests/services/NullSpamCheckServiceTest.php +++ b/tests/services/NullSpamCheckServiceTest.php @@ -6,10 +6,7 @@ class NullSpamCheckServiceTest extends TestCase { - /** - * @test - */ - public function spamCheckShouldReturnTrue() + public function testSpamCheckShouldReturnTrue() { $service = new \NullSpamCheckService(); $this->assertTrue($service->isCommentAcceptable([], '0.0.0.0', 'userAgent')); From 1a5c0c297af3c44f65c3ff879ffcd6ea4e83aef3 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 22:41:51 -0500 Subject: [PATCH 10/47] Remove test that doesn't really test anything This tests internal attribue names using a deprecated method. It's not really testing anything anyway. --- tests/models/ApiMapperTest.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/models/ApiMapperTest.php b/tests/models/ApiMapperTest.php index 2863ac540..aca03c252 100644 --- a/tests/models/ApiMapperTest.php +++ b/tests/models/ApiMapperTest.php @@ -18,14 +18,6 @@ public function setup(): void ->getMock(); } - public function testThatMapperInstanceHasDependencies() - { - $mapper = new ApiMapper($this->pdo, $this->request); - - $this->assertAttributeEquals($this->pdo, '_db', $mapper); - $this->assertAttributeEquals($this->request, '_request', $mapper); - } - public function testThatApiMapperHasNoDefaultFields() { $mapper = new ApiMapper($this->pdo, $this->request); From 4d807e441fbbfa2d2e1d0db885db5bf53d868b8b Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 22:51:23 -0500 Subject: [PATCH 11/47] Remove deprecated assertions that test internal details These shouldn't be tested anyway. --- tests/controllers/EventHostsControllerTest.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/controllers/EventHostsControllerTest.php b/tests/controllers/EventHostsControllerTest.php index d794ae121..a41f57f5a 100644 --- a/tests/controllers/EventHostsControllerTest.php +++ b/tests/controllers/EventHostsControllerTest.php @@ -354,11 +354,9 @@ public function testThatGettingEventHostWapperMithoutSettingFirstWorksAsExpected $db = $this->getMockBuilder('\PDO')->disableOriginalConstructor()->getMock(); $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); - - $this->assertAttributeEquals(null, 'eventHostMapper', $controller); $automatedEventHostMapper = $controller->getEventHostMapper($request, $db); + $this->assertInstanceOf('EventHostMapper', $automatedEventHostMapper); - $this->assertAttributeSame($automatedEventHostMapper, 'eventHostMapper', $controller); $this->assertSame($automatedEventHostMapper, $controller->getEventHostMapper($request, $db)); } @@ -369,11 +367,9 @@ public function testThatGettingUserMapperWithoutSettingFirstWorksAsExpected() $db = $this->getMockBuilder('\PDO')->disableOriginalConstructor()->getMock(); $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); - - $this->assertAttributeEquals(null, 'userMapper', $controller); $automatedUserMapper = $controller->getUserMapper($request, $db); + $this->assertInstanceOf('UserMapper', $automatedUserMapper); - $this->assertAttributeSame($automatedUserMapper, 'userMapper', $controller); $this->assertSame($automatedUserMapper, $controller->getUserMapper($request, $db)); } @@ -384,11 +380,9 @@ public function testThatGettingEventMapperWithoutSettingFirstWorksAsExpected() $db = $this->getMockBuilder('\PDO')->disableOriginalConstructor()->getMock(); $request = $this->getMockBuilder('\Request')->disableOriginalConstructor()->getMock(); - - $this->assertAttributeEquals(null, 'eventMapper', $controller); $automatedEventMapper = $controller->getEventMapper($request, $db); + $this->assertInstanceOf('EventMapper', $automatedEventMapper); - $this->assertAttributeSame($automatedEventMapper, 'eventMapper', $controller); $this->assertSame($automatedEventMapper, $controller->getEventMapper($request, $db)); } } From 641aac27aa0289094c5206e6133d4d25415dcdaa Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 23:01:09 -0500 Subject: [PATCH 12/47] Add coverage to composer scripts --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2dd6ea348..c618cb87a 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,8 @@ "@lint", "@sniff", "@security", - "@test" + "@test", + "@coverage" ] }, "config": { From 8bb3b42508fb0cbf055b60eb154ac074120d4311 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 23:04:43 -0500 Subject: [PATCH 13/47] Remove temp fix that is resovled with the new version of PHPUnit --- composer.json | 3 +- tests/compatibility/File.php | 569 ----------------------------------- 2 files changed, 1 insertion(+), 571 deletions(-) delete mode 100644 tests/compatibility/File.php diff --git a/composer.json b/composer.json index c618cb87a..9504f953f 100644 --- a/composer.json +++ b/composer.json @@ -49,8 +49,7 @@ "tests/models", "tests/routers", "tests/views" - ], - "files": ["tests/compatibility/File.php"] + ] }, "scripts": { "test": "phpunit -c . tests/", diff --git a/tests/compatibility/File.php b/tests/compatibility/File.php deleted file mode 100644 index 2aa752aaf..000000000 --- a/tests/compatibility/File.php +++ /dev/null @@ -1,569 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SebastianBergmann\CodeCoverage\Report\Html; - -use SebastianBergmann\CodeCoverage\Node\File as FileNode; -use SebastianBergmann\CodeCoverage\Util; - -/** - * This is a temporary fix for phpunit 5 coverage running in php 7 - * This will throw an exception requiring removal when phpunit is upgraded - * past 6.1.1 that has the fix. - */ - -if (PHP_MAJOR_VERSION >= 7) { - if (class_exists('\PHPUnit\Runner\Version')) { - $version = new \PHPUnit\Runner\Version(); - $version = explode(".", $version->id()); - if ($version[0] >= 6 && $version[1] > 1) { - throw new \Exception( - "This file is no longer needed with version of php and phpunit, please remove from composer.json" - ); - } - } -} - -/** - * Renders a file node. - */ -class File extends Renderer -{ - /** - * @var int - */ - private $htmlspecialcharsFlags; - - /** - * Constructor. - * - * @param string $templatePath - * @param string $generator - * @param string $date - * @param int $lowUpperBound - * @param int $highLowerBound - */ - public function __construct($templatePath, $generator, $date, $lowUpperBound, $highLowerBound) - { - parent::__construct( - $templatePath, - $generator, - $date, - $lowUpperBound, - $highLowerBound - ); - - $this->htmlspecialcharsFlags = ENT_COMPAT; - - $this->htmlspecialcharsFlags = $this->htmlspecialcharsFlags | ENT_HTML401 | ENT_SUBSTITUTE; - } - - /** - * @param FileNode $node - * @param string $file - */ - public function render(FileNode $node, $file) - { - $template = new \Text_Template($this->templatePath . 'file.html', '{{', '}}'); - - $template->setVar( - [ - 'items' => $this->renderItems($node), - 'lines' => $this->renderSource($node) - ] - ); - - $this->setCommonTemplateVariables($template, $node); - - $template->renderTo($file); - } - - /** - * @param FileNode $node - * - * @return string - */ - protected function renderItems(FileNode $node) - { - $template = new \Text_Template($this->templatePath . 'file_item.html', '{{', '}}'); - - $methodItemTemplate = new \Text_Template( - $this->templatePath . 'method_item.html', - '{{', - '}}' - ); - - $items = $this->renderItemTemplate( - $template, - [ - 'name' => 'Total', - 'numClasses' => $node->getNumClassesAndTraits(), - 'numTestedClasses' => $node->getNumTestedClassesAndTraits(), - 'numMethods' => $node->getNumMethods(), - 'numTestedMethods' => $node->getNumTestedMethods(), - 'linesExecutedPercent' => $node->getLineExecutedPercent(false), - 'linesExecutedPercentAsString' => $node->getLineExecutedPercent(), - 'numExecutedLines' => $node->getNumExecutedLines(), - 'numExecutableLines' => $node->getNumExecutableLines(), - 'testedMethodsPercent' => $node->getTestedMethodsPercent(false), - 'testedMethodsPercentAsString' => $node->getTestedMethodsPercent(), - 'testedClassesPercent' => $node->getTestedClassesAndTraitsPercent(false), - 'testedClassesPercentAsString' => $node->getTestedClassesAndTraitsPercent(), - 'crap' => 'CRAP' - ] - ); - - $items .= $this->renderFunctionItems( - $node->getFunctions(), - $methodItemTemplate - ); - - $items .= $this->renderTraitOrClassItems( - $node->getTraits(), - $template, - $methodItemTemplate - ); - - $items .= $this->renderTraitOrClassItems( - $node->getClasses(), - $template, - $methodItemTemplate - ); - - return $items; - } - - /** - * @param array $items - * @param \Text_Template $template - * @param \Text_Template $methodItemTemplate - * - * @return string - */ - protected function renderTraitOrClassItems(array $items, \Text_Template $template, \Text_Template $methodItemTemplate) - { - if (empty($items)) { - return ''; - } - - $buffer = ''; - - foreach ($items as $name => $item) { - $numMethods = count($item['methods']); - $numTestedMethods = 0; - - foreach ($item['methods'] as $method) { - if ($method['executedLines'] == $method['executableLines']) { - $numTestedMethods++; - } - } - - if ($item['executableLines'] > 0) { - $numClasses = 1; - $numTestedClasses = $numTestedMethods == $numMethods ? 1 : 0; - $linesExecutedPercentAsString = Util::percent( - $item['executedLines'], - $item['executableLines'], - true - ); - } else { - $numClasses = 'n/a'; - $numTestedClasses = 'n/a'; - $linesExecutedPercentAsString = 'n/a'; - } - - $buffer .= $this->renderItemTemplate( - $template, - [ - 'name' => $name, - 'numClasses' => $numClasses, - 'numTestedClasses' => $numTestedClasses, - 'numMethods' => $numMethods, - 'numTestedMethods' => $numTestedMethods, - 'linesExecutedPercent' => Util::percent( - $item['executedLines'], - $item['executableLines'], - false - ), - 'linesExecutedPercentAsString' => $linesExecutedPercentAsString, - 'numExecutedLines' => $item['executedLines'], - 'numExecutableLines' => $item['executableLines'], - 'testedMethodsPercent' => Util::percent( - $numTestedMethods, - $numMethods, - false - ), - 'testedMethodsPercentAsString' => Util::percent( - $numTestedMethods, - $numMethods, - true - ), - 'testedClassesPercent' => Util::percent( - $numTestedMethods == $numMethods ? 1 : 0, - 1, - false - ), - 'testedClassesPercentAsString' => Util::percent( - $numTestedMethods == $numMethods ? 1 : 0, - 1, - true - ), - 'crap' => $item['crap'] - ] - ); - - foreach ($item['methods'] as $method) { - $buffer .= $this->renderFunctionOrMethodItem( - $methodItemTemplate, - $method, - ' ' - ); - } - } - - return $buffer; - } - - /** - * @param array $functions - * @param \Text_Template $template - * - * @return string - */ - protected function renderFunctionItems(array $functions, \Text_Template $template) - { - if (empty($functions)) { - return ''; - } - - $buffer = ''; - - foreach ($functions as $function) { - $buffer .= $this->renderFunctionOrMethodItem( - $template, - $function - ); - } - - return $buffer; - } - - /** - * @param \Text_Template $template - * - * @return string - */ - protected function renderFunctionOrMethodItem(\Text_Template $template, array $item, $indent = '') - { - $numTestedItems = $item['executedLines'] == $item['executableLines'] ? 1 : 0; - - return $this->renderItemTemplate( - $template, - [ - 'name' => sprintf( - '%s%s', - $indent, - $item['startLine'], - htmlspecialchars($item['signature']), - isset($item['functionName']) ? $item['functionName'] : $item['methodName'] - ), - 'numMethods' => 1, - 'numTestedMethods' => $numTestedItems, - 'linesExecutedPercent' => Util::percent( - $item['executedLines'], - $item['executableLines'], - false - ), - 'linesExecutedPercentAsString' => Util::percent( - $item['executedLines'], - $item['executableLines'], - true - ), - 'numExecutedLines' => $item['executedLines'], - 'numExecutableLines' => $item['executableLines'], - 'testedMethodsPercent' => Util::percent( - $numTestedItems, - 1, - false - ), - 'testedMethodsPercentAsString' => Util::percent( - $numTestedItems, - 1, - true - ), - 'crap' => $item['crap'] - ] - ); - } - - /** - * @param FileNode $node - * - * @return string - */ - protected function renderSource(FileNode $node) - { - $coverageData = $node->getCoverageData(); - $testData = $node->getTestData(); - $codeLines = $this->loadFile($node->getPath()); - $lines = ''; - $i = 1; - - foreach ($codeLines as $line) { - $trClass = ''; - $popoverContent = ''; - $popoverTitle = ''; - - if (array_key_exists($i, $coverageData)) { - $numTests = ($coverageData[$i] ? count($coverageData[$i]) : 0); - - if ($coverageData[$i] === null) { - $trClass = ' class="warning"'; - } elseif ($numTests == 0) { - $trClass = ' class="danger"'; - } else { - $lineCss = 'covered-by-large-tests'; - $popoverContent = '
    '; - - if ($numTests > 1) { - $popoverTitle = $numTests . ' tests cover line ' . $i; - } else { - $popoverTitle = '1 test covers line ' . $i; - } - - foreach ($coverageData[$i] as $test) { - if ($lineCss == 'covered-by-large-tests' && $testData[$test]['size'] == 'medium') { - $lineCss = 'covered-by-medium-tests'; - } elseif ($testData[$test]['size'] == 'small') { - $lineCss = 'covered-by-small-tests'; - } - - switch ($testData[$test]['status']) { - case 0: - switch ($testData[$test]['size']) { - case 'small': - $testCSS = ' class="covered-by-small-tests"'; - break; - - case 'medium': - $testCSS = ' class="covered-by-medium-tests"'; - break; - - default: - $testCSS = ' class="covered-by-large-tests"'; - break; - } - break; - - case 1: - case 2: - $testCSS = ' class="warning"'; - break; - - case 3: - $testCSS = ' class="danger"'; - break; - - case 4: - $testCSS = ' class="danger"'; - break; - - default: - $testCSS = ''; - } - - $popoverContent .= sprintf( - '%s', - $testCSS, - htmlspecialchars($test) - ); - } - - $popoverContent .= '
'; - $trClass = ' class="' . $lineCss . ' popin"'; - } - } - - if (!empty($popoverTitle)) { - $popover = sprintf( - ' data-title="%s" data-content="%s" data-placement="bottom" data-html="true"', - $popoverTitle, - htmlspecialchars($popoverContent) - ); - } else { - $popover = ''; - } - - $lines .= sprintf( - ' %s' . "\n", - $trClass, - $popover, - $i, - $i, - $i, - $line - ); - - $i++; - } - - return $lines; - } - - /** - * @param string $file - * - * @return array - */ - protected function loadFile($file) - { - $buffer = file_get_contents($file); - $tokens = token_get_all($buffer); - $result = ['']; - $i = 0; - $stringFlag = false; - $fileEndsWithNewLine = substr($buffer, -1) == "\n"; - - unset($buffer); - - foreach ($tokens as $j => $token) { - if (is_string($token)) { - if ($token === '"' && $tokens[$j - 1] !== '\\') { - $result[$i] .= sprintf( - '%s', - htmlspecialchars($token) - ); - - $stringFlag = !$stringFlag; - } else { - $result[$i] .= sprintf( - '%s', - htmlspecialchars($token) - ); - } - - continue; - } - - list($token, $value) = $token; - - $value = str_replace( - ["\t", ' '], - ['    ', ' '], - htmlspecialchars($value, $this->htmlspecialcharsFlags) - ); - - if ($value === "\n") { - $result[++$i] = ''; - } else { - $lines = explode("\n", $value); - - foreach ($lines as $jj => $line) { - $line = trim($line); - - if ($line !== '') { - if ($stringFlag) { - $colour = 'string'; - } else { - switch ($token) { - case T_INLINE_HTML: - $colour = 'html'; - break; - - case T_COMMENT: - case T_DOC_COMMENT: - $colour = 'comment'; - break; - - case T_ABSTRACT: - case T_ARRAY: - case T_AS: - case T_BREAK: - case T_CALLABLE: - case T_CASE: - case T_CATCH: - case T_CLASS: - case T_CLONE: - case T_CONTINUE: - case T_DEFAULT: - case T_ECHO: - case T_ELSE: - case T_ELSEIF: - case T_EMPTY: - case T_ENDDECLARE: - case T_ENDFOR: - case T_ENDFOREACH: - case T_ENDIF: - case T_ENDSWITCH: - case T_ENDWHILE: - case T_EXIT: - case T_EXTENDS: - case T_FINAL: - case T_FINALLY: - case T_FOREACH: - case T_FUNCTION: - case T_GLOBAL: - case T_IF: - case T_IMPLEMENTS: - case T_INCLUDE: - case T_INCLUDE_ONCE: - case T_INSTANCEOF: - case T_INSTEADOF: - case T_INTERFACE: - case T_ISSET: - case T_LOGICAL_AND: - case T_LOGICAL_OR: - case T_LOGICAL_XOR: - case T_NAMESPACE: - case T_NEW: - case T_PRIVATE: - case T_PROTECTED: - case T_PUBLIC: - case T_REQUIRE: - case T_REQUIRE_ONCE: - case T_RETURN: - case T_STATIC: - case T_THROW: - case T_TRAIT: - case T_TRY: - case T_UNSET: - case T_USE: - case T_VAR: - case T_WHILE: - case T_YIELD: - $colour = 'keyword'; - break; - - default: - $colour = 'default'; - } - } - - $result[$i] .= sprintf( - '%s', - $colour, - $line - ); - } - - if (isset($lines[$jj + 1])) { - $result[++$i] = ''; - } - } - } - } - - if ($fileEndsWithNewLine) { - unset($result[count($result)-1]); - } - - return $result; - } -} From 872274327d7b4226acabbb0e64dd9dd311a075de Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 23:08:21 -0500 Subject: [PATCH 14/47] Add auto-generated phpunit cache file to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a9080af31..246ceff2b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ vendor/.git node_modules vendor diff.txt +.phpunit.result.cache From ed3d95b35998346debd31a7471d23d03ade5ae40 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 24 Mar 2019 23:15:14 -0500 Subject: [PATCH 15/47] Use script-lang-aware codeblocks in documentation --- README.md | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1a2fa9d24..8a875c3e5 100644 --- a/README.md +++ b/README.md @@ -34,20 +34,28 @@ We have tests that make HTTP requests from the outside of the API, functional te To run the frisby tests (frisby.js), you will first need to install node.js and npm on you computer. Then run: - cd tests/frisby - npm install +```bash +cd tests/frisby +npm install +``` To run the tests on your computer against your Vagrant VM, from the `tests/frisby` directory run: - npm test +```bash +npm test +``` We also have a set of "destructive" tests, these create, edit and delete data as well as just reading it. These aren't safe to run on a live platform, but are very valuable in testing. Before you run them, you will need to run this query against your database: - insert into oauth_consumers (consumer_key, consumer_secret, user_id, enable_password_grant) values ('0000', '1111', '1', '1'); +```sql +insert into oauth_consumers (consumer_key, consumer_secret, user_id, enable_password_grant) values ('0000', '1111', '1', '1'); +``` Then run: - npm run test_write +```bash +npm run test_write +``` #### Proxying the frisy tests @@ -74,7 +82,9 @@ as any files that should not be included. If you need to include a new patch, then create the SQL needed and add it to the next patch number in the `db` directory. You need to include a line that looks like this at the end of your script: - INSERT INTO patch_history SET patch_number = 17; +```sql +INSERT INTO patch_history SET patch_number = 17; +``` The number in that line should match the filename of your new patch number - check out the existing database patches in the project for examples. @@ -85,7 +95,9 @@ Joind.in coding style. This is the PSR-2 coding standard with no namespaces. You can run php codesniffer using phing on an individual file like so: - phing phpcs-human -Dfilename.php +```bash +phing phpcs-human -Dfilename.php +``` This will run codesniffer on any file within the regular source for Joind.in or the API-v2 source. Wildcards work as does specifying part of the path in case the @@ -93,7 +105,9 @@ filename alone results in sniffing more files than you wanted. To see a summary of the codesniff errors and warnings across the entire project, run - phing phpcs-human-summary +```bash +phing phpcs-human-summary +``` #### Inline Documentation @@ -122,7 +136,9 @@ projects too. You can define the gitignore file with a command that looks like this, where the last argument is the file that holds the patterns to ignore: - $ git config --global core.excludesfile ~/.gitignore_global +```bash +git config --global core.excludesfile ~/.gitignore_global +``` Octocat gives [a good starting point](https://gist.github.com/octocat/9257657) for what to include, but you can also ignore the files used by your editor: From 471ed893b2c7069548d73eab83ef03ae5a2959c8 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sat, 30 Mar 2019 15:58:48 -0500 Subject: [PATCH 16/47] Update codesniffer to have similar output to web2 codesniffer --- README.md | 4 ++-- composer.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8a875c3e5..15cf36671 100644 --- a/README.md +++ b/README.md @@ -92,11 +92,11 @@ The number in that line should match the filename of your new patch number - che Please do your best to ensure that any code you contributed adheres to the Joind.in coding style. This is the PSR-2 coding standard with -no namespaces. You can run php codesniffer using phing on an +no namespaces. You can run php codesniffer on an individual file like so: ```bash -phing phpcs-human -Dfilename.php +vendor/bin/phpcs path/of/filename.php ``` This will run codesniffer on any file within the regular source for Joind.in or the diff --git a/composer.json b/composer.json index 9504f953f..250f8d12b 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "scripts": { "test": "phpunit -c . tests/", "lint": "parallel-lint --exclude vendor .", - "sniff": "phpcs --standard=tools/codesniffer/JoindInPSR2/ruleset.xml --ignore=**/config.php,**/database.php,vendor,tools,tests/bootstrap.php --extensions=php --report-checkstyle=build/logs/checkstyle.xml --runtime-set ignore_warnings_on_exit true -p .", + "sniff": "phpcs --standard=tools/codesniffer/JoindInPSR2/ruleset.xml --ignore=**/config.php,**/database.php,vendor,tools,tests/bootstrap.php --extensions=php --runtime-set ignore_warnings_on_exit true -p .", "security": "security-checker security:check composer.lock", "coverage": [ "git diff origin/master... -- > diff.txt", From e2a47ed8628ac7da167488f63c22ea446c7a7e21 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sat, 30 Mar 2019 15:59:26 -0500 Subject: [PATCH 17/47] Fix spelling --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 15cf36671..83695d727 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ There's more documentation here: http://joindin.github.io/joindin-api/ - it's po We are happy for you to make whatever use of the API you wish (bear in mind we run everything from a single donated server so please implement some caching on your side and be considerate of the traffic levels you send to us). Please mention the source of your data, but do not use "joind.in" in your project name or imply that the joind.in project endorses your project. - ## Tools and Tests ### API Tests @@ -57,8 +56,7 @@ Then run: npm run test_write ``` - -#### Proxying the frisy tests +#### Proxying the frisby tests If you want to proxy the frisby tests via Charles or another proxy, then export `HTTP_PROXY` first: @@ -66,7 +64,6 @@ If you want to proxy the frisby tests via Charles or another proxy, then export You can now run `npm run test_write` or `npm test` as required and all the network requests will go via the proxy. - ### Unit Tests There are some tests set up, which use PHPUnit; these can be found in the From c523acd8ad267311bf5a13ff1832d17ec68a557c Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sat, 30 Mar 2019 16:07:39 -0500 Subject: [PATCH 18/47] Remove setting deprecated since PHPUnit 5.2 --- phpunit.xml.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8a273b09f..391eaf779 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,6 @@ Date: Sat, 30 Mar 2019 16:17:10 -0500 Subject: [PATCH 19/47] Replace deprecated phpunit setting with new setting --- composer.json | 1 + composer.lock | 52 +++++++++++++++++++++++++++++++++++++++++++++++- phpunit.xml.dist | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 250f8d12b..131438b04 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "require-dev": { "exussum12/coverage-checker": "^0.11.0", "jakub-onderka/php-parallel-lint": "^1.0", + "phpunit/php-invoker": "^2.0", "phpunit/phpunit": "^8.0", "roave/security-advisories": "dev-master", "sensiolabs/security-checker": "^5.0", diff --git a/composer.lock b/composer.lock index 55a35a0fe..2e5dc1df4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e9e27dc789338fd3cf0b670f77d904b1", + "content-hash": "474fba3bfb184cc3704c63440eb59f08", "packages": [ { "name": "guzzlehttp/guzzle", @@ -1265,6 +1265,56 @@ ], "time": "2018-09-13T20:33:42+00:00" }, + { + "name": "phpunit/php-invoker", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "4a01883f660b10d4a19a14de5efd19b22eac2d93" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/4a01883f660b10d4a19a14de5efd19b22eac2d93", + "reference": "4a01883f660b10d4a19a14de5efd19b22eac2d93", + "shasum": "" + }, + "require": { + "ext-pcntl": "*", + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^6.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "time": "2018-01-27T06:52:17+00:00" + }, { "name": "phpunit/php-text-template", "version": "1.2.1", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 391eaf779..ee838b180 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,7 +4,7 @@ backupStaticAttributes="false" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTestSize="true" + enforceTimeLimit="true" bootstrap="./tests/bootstrap.php" colors="true" verbose="true"> From 91dc948f8caac5783c447476c1579305c91a07b5 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 31 Mar 2019 13:00:52 -0500 Subject: [PATCH 20/47] Remove no-longer valid log option 'title' --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ee838b180..13302cd1c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,7 +12,7 @@ tests/ - From 2710717971ee3fadac78e9ed13c63e0808e89db4 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 31 Mar 2019 13:01:44 -0500 Subject: [PATCH 21/47] Remove no-longer valid log option 'charset' --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 13302cd1c..8d1865d0b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,7 +13,7 @@ From f1b1a2ab661906a3e630a9e6fded50f4ef42fef1 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 31 Mar 2019 13:02:13 -0500 Subject: [PATCH 22/47] Remove no-longer valid log option 'yui' --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8d1865d0b..2665ced49 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,7 +13,7 @@ From 6346455344617f8726ac721b33acef2ade331ccd Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 31 Mar 2019 13:03:21 -0500 Subject: [PATCH 23/47] emove no-longer valid log option 'highlight' --- phpunit.xml.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2665ced49..07b491854 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,7 +13,6 @@ From ddc5794f65f2136c4c1f809fa3d9acd888e368a2 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 31 Mar 2019 13:09:39 -0500 Subject: [PATCH 24/47] Remove no-longer-allowed logIncompleteSkipped attribute in log --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 07b491854..a43d18fea 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,7 +15,7 @@ - + From 379d0b35689cf6a94bc9229bde306a928c92aa6d Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 31 Mar 2019 13:14:53 -0500 Subject: [PATCH 25/47] Update exussum12/coverage-checker --- composer.json | 2 +- composer.lock | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 131438b04..bd52247d3 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "swiftmailer/swiftmailer": "^v5.4.9" }, "require-dev": { - "exussum12/coverage-checker": "^0.11.0", + "exussum12/coverage-checker": "^0.11.1", "jakub-onderka/php-parallel-lint": "^1.0", "phpunit/php-invoker": "^2.0", "phpunit/phpunit": "^8.0", diff --git a/composer.lock b/composer.lock index 2e5dc1df4..1df77ac05 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "474fba3bfb184cc3704c63440eb59f08", + "content-hash": "aa39c44bc21c5240443f9824530e6297", "packages": [ { "name": "guzzlehttp/guzzle", @@ -643,16 +643,16 @@ }, { "name": "exussum12/coverage-checker", - "version": "0.11.0", + "version": "0.11.1", "source": { "type": "git", "url": "https://github.com/exussum12/coverageChecker.git", - "reference": "de7f6731220b0b321bff755c44a131d5d7c39583" + "reference": "7dc187771389ad0fa80c154e4477154ec91a8692" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/exussum12/coverageChecker/zipball/de7f6731220b0b321bff755c44a131d5d7c39583", - "reference": "de7f6731220b0b321bff755c44a131d5d7c39583", + "url": "https://api.github.com/repos/exussum12/coverageChecker/zipball/7dc187771389ad0fa80c154e4477154ec91a8692", + "reference": "7dc187771389ad0fa80c154e4477154ec91a8692", "shasum": "" }, "require": { @@ -686,7 +686,7 @@ } ], "description": "Allows checking the code coverage of a single pull request", - "time": "2018-08-30T18:15:26+00:00" + "time": "2019-03-18T18:49:09+00:00" }, { "name": "jakub-onderka/php-parallel-lint", @@ -786,24 +786,24 @@ }, { "name": "nikic/php-parser", - "version": "v3.1.5", + "version": "v4.2.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce" + "reference": "5221f49a608808c1e4d436df32884cbc1b821ac0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/5221f49a608808c1e4d436df32884cbc1b821ac0", + "reference": "5221f49a608808c1e4d436df32884cbc1b821ac0", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.5" + "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" + "phpunit/phpunit": "^6.5 || ^7.0" }, "bin": [ "bin/php-parse" @@ -811,7 +811,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -833,7 +833,7 @@ "parser", "php" ], - "time": "2018-02-28T20:30:58+00:00" + "time": "2019-02-16T20:54:15+00:00" }, { "name": "phar-io/manifest", From bb08764529bd849adcdd41c485a1e38dd606c4f4 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 31 Mar 2019 13:19:10 -0500 Subject: [PATCH 26/47] Update phpunit --- composer.lock | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/composer.lock b/composer.lock index 1df77ac05..0a7683ea2 100644 --- a/composer.lock +++ b/composer.lock @@ -589,27 +589,29 @@ }, { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "a2c590166b2133a4633738648b6b064edae0814a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", + "reference": "a2c590166b2133a4633738648b6b064edae0814a", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { @@ -634,12 +636,12 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2019-03-17T17:37:11+00:00" }, { "name": "exussum12/coverage-checker", @@ -1456,16 +1458,16 @@ }, { "name": "phpunit/phpunit", - "version": "8.0.5", + "version": "8.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "19cbed2120839772c4a00e8b28456b0c77d1a7b4" + "reference": "925109f8bbe6dae28fbc7bb07446a53abd3b1c25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/19cbed2120839772c4a00e8b28456b0c77d1a7b4", - "reference": "19cbed2120839772c4a00e8b28456b0c77d1a7b4", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/925109f8bbe6dae28fbc7bb07446a53abd3b1c25", + "reference": "925109f8bbe6dae28fbc7bb07446a53abd3b1c25", "shasum": "" }, "require": { @@ -1534,7 +1536,7 @@ "testing", "xunit" ], - "time": "2019-03-16T07:33:46+00:00" + "time": "2019-03-26T14:00:24+00:00" }, { "name": "psr/log", @@ -2583,16 +2585,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + "reference": "82ebae02209c21113908c229e9883c419720738a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", "shasum": "" }, "require": { @@ -2604,7 +2606,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -2637,7 +2639,7 @@ "polyfill", "portable" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-mbstring", From f861c4d4083be2342ab5466d161387d32e474a04 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 31 Mar 2019 14:23:10 -0500 Subject: [PATCH 27/47] Rename and move ruleset to phpcs.xml in the project root --- composer.json | 2 +- .../JoindInPSR2/ruleset.xml => phpcs.xml.dist | 0 tools/codesniffer/README | 11 ----------- 3 files changed, 1 insertion(+), 12 deletions(-) rename tools/codesniffer/JoindInPSR2/ruleset.xml => phpcs.xml.dist (100%) delete mode 100644 tools/codesniffer/README diff --git a/composer.json b/composer.json index bd52247d3..fbdcb9ba3 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "scripts": { "test": "phpunit -c . tests/", "lint": "parallel-lint --exclude vendor .", - "sniff": "phpcs --standard=tools/codesniffer/JoindInPSR2/ruleset.xml --ignore=**/config.php,**/database.php,vendor,tools,tests/bootstrap.php --extensions=php --runtime-set ignore_warnings_on_exit true -p .", + "sniff": "phpcs --ignore=**/config.php,**/database.php,vendor,tools,tests/bootstrap.php --extensions=php --runtime-set ignore_warnings_on_exit true -p .", "security": "security-checker security:check composer.lock", "coverage": [ "git diff origin/master... -- > diff.txt", diff --git a/tools/codesniffer/JoindInPSR2/ruleset.xml b/phpcs.xml.dist similarity index 100% rename from tools/codesniffer/JoindInPSR2/ruleset.xml rename to phpcs.xml.dist diff --git a/tools/codesniffer/README b/tools/codesniffer/README deleted file mode 100644 index eb53512f2..000000000 --- a/tools/codesniffer/README +++ /dev/null @@ -1,11 +0,0 @@ -PHP CodeSniffer standard for joind.in - -This is an override of the PSR2 code sniffer standard to remove the requirement -that each class must be in a namespace - -Usage: -From the src/ directory, run: - phpcs --standard=tools/codesniffer/JoindInPSR2 path/to/file/or/directory - -e.g. to check the api-v2/views directory: - phpcs --standard=tools/codesniffer/JoindInPSR2 src/views From 9c353aa88b7859e04aa92a8a3eb81610d59d705c Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sun, 31 Mar 2019 14:25:33 -0500 Subject: [PATCH 28/47] Match ruleset schema to what squizlabs uses --- phpcs.xml.dist | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 3bfaba0b8..faf381119 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,5 +1,9 @@ - + The Joind.in coding standard (PSR2, no namespace).