diff --git a/.gitignore b/.gitignore index a9080af31..4b20fb6a0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ vendor/.git node_modules vendor diff.txt +.phpunit.result.cache +.phpcs-cache diff --git a/README.md b/README.md index 1a2fa9d24..7ad7d3f85 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 @@ -34,23 +33,30 @@ 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 +#### Proxying the frisby tests If you want to proxy the frisby tests via Charles or another proxy, then export `HTTP_PROXY` first: @@ -58,42 +64,61 @@ 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 -tests directory. There is a phing task -configured to run them - from the root directory simply run `phing phpunit` to run -the tests. Unfortunately, there will be no output about whether the tests passed -or failed from the phing target. A better way to test when you are developing is -to run the tests from within the tests directory by just typing -`phpunit`. The phpunit.xml in each directory will configure the bootstrap as well -as any files that should not be included. +### Testing Code +We use [PHPUnit](https://phpunit.de/documentation.html) for running unit tests against the joindin-api codebase. +To run PHPUnit tests, you can go the classic route: +```bash +vendor/bin/phpunit -c . tests/ +``` +You can also use composer to run your tests: +```bash +composer test +``` +### Code Coverage +Code coverage requires that [xdebug](https://xdebug.org/) be running. If you are using the joindin-vm Vagrant box, you can run your tests from within vagrant: +```bash +vagrant ssh +xon # note: this turns on xdebug +cd ~/joindin-vm/joindin-api +composer test +``` +You can see your code coverage report by going to http://localhost:63342/joindin-api/build/coverage/index.html ### Database Patches 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. ### Coding Style 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 -individual file like so: +Joind.in coding style -- this is the PSR-2 coding standard with no namespaces. +You can run php codesniffer on an individual file like so: - phing phpcs-human -Dfilename.php +```bash +vendor/bin/phpcs path/of/filename.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 filename alone results in sniffing more files than you wanted. +To see the codesniff errors and warnings across the entire project, run + +```bash +composer sniff +``` + To see a summary of the codesniff errors and warnings across the entire project, run - phing phpcs-human-summary +```bash +composer sniff -- --report=summary +``` #### Inline Documentation @@ -122,7 +147,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: diff --git a/build.xml b/build.xml index 1b92dd925..acf69b810 100644 --- a/build.xml +++ b/build.xml @@ -46,35 +46,9 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/composer.json b/composer.json index 6e658ba8b..80aab22e1 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,10 @@ "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/phpunit": "^5.7", + "phpunit/php-invoker": "^2.0", + "phpunit/phpunit": "^8.1", "roave/security-advisories": "dev-master", "sensiolabs/security-checker": "^5.0", "squizlabs/php_codesniffer": "^3.4" @@ -49,13 +50,12 @@ "tests/models", "tests/routers", "tests/views" - ], - "files": ["tests/compatibility/File.php"] + ] }, "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 --runtime-set ignore_warnings_on_exit true -p .", "security": "security-checker security:check composer.lock", "coverage": [ "git diff origin/master... -- > diff.txt", @@ -66,7 +66,8 @@ "@lint", "@sniff", "@security", - "@test" + "@test", + "@coverage" ] }, "config": { diff --git a/composer.lock b/composer.lock index 04bc5951c..e076e6519 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": "12c92c46a113c5ecb173a88a94495e6f", "packages": [ { "name": "guzzlehttp/guzzle", @@ -589,32 +589,34 @@ }, { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "a2c590166b2133a4633738648b6b064edae0814a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", + "reference": "a2c590166b2133a4633738648b6b064edae0814a", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -634,25 +636,25 @@ } ], "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": "2015-06-14T21:17:01+00:00" + "time": "2019-03-17T17:37:11+00:00" }, { "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 +688,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", @@ -738,25 +740,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,28 +784,28 @@ "object", "object graph" ], - "time": "2017-10-19T19:58:43+00:00" + "time": "2018-06-11T23:09:50+00:00" }, { "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" @@ -808,7 +813,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -830,7 +835,109 @@ "parser", "php" ], - "time": "2018-02-28T20:30:58+00:00" + "time": "2019-02-16T20:54:15+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", @@ -888,29 +995,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 +1042,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 +1156,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 +1204,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1102,29 +1215,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 +1255,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1149,7 +1265,57 @@ "filesystem", "iterator" ], - "time": "2017-11-27T13:52:08+00:00" + "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", @@ -1194,28 +1360,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 +1396,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1239,33 +1405,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 +1454,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.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" + "reference": "37cfab19fdda1554f2830be83a566ade4e2ae098" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/37cfab19fdda1554f2830be83a566ade4e2ae098", + "reference": "37cfab19fdda1554f2830be83a566ade4e2ae098", "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 +1510,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7.x-dev" + "dev-master": "8.1-dev" } }, "autoload": { @@ -1370,67 +1536,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-04-05T05:27:33+00:00" }, { "name": "psr/log", @@ -1730,30 +1836,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 +1890,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 +1947,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 +2005,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 +2072,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 +2103,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2010,33 +2126,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 +2173,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 +2271,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 +2313,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", @@ -2244,16 +2406,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 +2448,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", @@ -2423,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": { @@ -2444,7 +2606,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -2477,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", @@ -2539,63 +2701,44 @@ "time": "2018-09-21T13:07:52+00:00" }, { - "name": "symfony/yaml", - "version": "v3.4.22", + "name": "theseer/tokenizer", + "version": "1.1.2", "source": { "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d" + "url": "https://github.com/theseer/tokenizer.git", + "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/ba11776e9e6c15ad5759a07bffb15899bac75c2d", - "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/1c42705be2b6c1de5904f8afacef5895cab44bf8", + "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8", "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": "2019-04-04T09:56:43+00:00" }, { "name": "webmozart/assert", diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 000000000..a2ca92612 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,31 @@ + + + The Joind.in coding standard (PSR2, no namespace). + + **/config.php + **/database.php + build + tools + tests/bootstrap.php + vendor + + + + + + + src/ + tests/ + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8a273b09f..a43d18fea 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,9 +3,8 @@ @@ -13,11 +12,10 @@ tests/ - - + diff --git a/tests/assets/PDOMock.php b/tests/assets/PDOMock.php deleted file mode 100644 index f0a006726..000000000 --- a/tests/assets/PDOMock.php +++ /dev/null @@ -1,8 +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 = ''; - $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( - '
%d
%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; - } -} diff --git a/tests/controllers/ContactControllerTest.php b/tests/controllers/ContactControllerTest.php index e2274c4cd..bc1dd93ad 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, @@ -37,9 +36,7 @@ public function contactWorksAsExpected( $request ->expects($this->any()) ->method('getParameter') - ->will( - $this->returnValueMap($returnValueMap) - ); + ->willReturnMap($returnValueMap); $db = $this->getMockBuilder('\PDO')->disableOriginalConstructor()->getMock(); diff --git a/tests/controllers/EventHostsControllerTest.php b/tests/controllers/EventHostsControllerTest.php index e38dec18c..a41f57f5a 100644 --- a/tests/controllers/EventHostsControllerTest.php +++ b/tests/controllers/EventHostsControllerTest.php @@ -2,18 +2,16 @@ namespace JoindinTest\Controller; -use Mockery as M; use PHPUnit\Framework\TestCase; 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 +20,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 +35,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 +57,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 +73,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 +97,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 +120,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 +145,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 +174,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 +203,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 +277,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 = [ @@ -360,48 +347,42 @@ public function testThatRemovingUserAsHostSetsCorrectValues() $this->assertNull($constructor->removeHostFromEvent($request, $db)); } - public function testThatGetingEventHostWapperMithoutSettingFirstWorksAsExpected() + public function testThatGettingEventHostWapperMithoutSettingFirstWorksAsExpected() { $controller = new \Event_hostsController(); $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)); } - public function testThatGetingUserMapperWithoutSettingFirstWorksAsExpected() + public function testThatGettingUserMapperWithoutSettingFirstWorksAsExpected() { $controller = new \Event_hostsController(); $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)); } - public function testThatGetingEventMapperWithoutSettingFirstWorksAsExpected() + public function testThatGettingEventMapperWithoutSettingFirstWorksAsExpected() { $controller = new \Event_hostsController(); $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)); } } diff --git a/tests/controllers/TalkBase.php b/tests/controllers/TalkBase.php index d5e3ea63d..062d39c88 100644 --- a/tests/controllers/TalkBase.php +++ b/tests/controllers/TalkBase.php @@ -5,45 +5,52 @@ use EventMapper; use JoindinTest\Inc\mockPDO; use OAuthModel; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Request; use TalkCommentMapper; use TalkMapper; use TalkModel; use UserMapper; -use PHPUnit\Framework\TestCase; class TalkBase extends TestCase { - protected function createTalkMapper(mockPDO $db, Request $request, $expetcedCalls = 1) + protected $talk_mapper; + + protected function setUp(): void + { + $this->talk_mapper = $this + ->getMockBuilder(TalkMapper::class) + ->disableOriginalConstructor() + ->getMock(); + + parent::setUp(); + } + + protected function createTalkMapper(mockPDO $db, Request $request, $expectedCalls = 1) { $talk_mapper = $this->getMockBuilder(TalkMapper::class) ->setConstructorArgs(array($db,$request)) ->getMock(); $talk_mapper - ->expects($this->exactly($expetcedCalls)) + ->expects($this->exactly($expectedCalls)) ->method('getTalkById') - ->will( - $this->returnValue( - new TalkModel( - [ - 'talk_title' => 'talk_title', - 'url_friendly_talk_title' => 'url_friendly_talk_title', - 'talk_description' => 'talk_desc', - 'type' => 'talk_type', - 'start_date' => 'date_given', - 'duration' => 'duration', - 'stub' => 'stub', - 'average_rating' => 'avg_rating', - 'comments_enabled' => 'comments_enabled', - 'comment_count' => 'comment_count', - 'starred' => 'starred', - 'starred_count' => 'starred_count', - 'event_id' => 1 - ] - ) - ) + ->willReturn( + new TalkModel([ + 'talk_title' => 'talk_title', + 'url_friendly_talk_title' => 'url_friendly_talk_title', + 'talk_description' => 'talk_desc', + 'type' => 'talk_type', + 'start_date' => 'date_given', + 'duration' => 'duration', + 'stub' => 'stub', + 'average_rating' => 'avg_rating', + 'comments_enabled' => 'comments_enabled', + 'comment_count' => 'comment_count', + 'starred' => 'starred', + 'starred_count' => 'starred_count', + 'event_id' => 1 + ]) ); return $talk_mapper; @@ -51,38 +58,34 @@ protected function createTalkMapper(mockPDO $db, Request $request, $expetcedCall protected function createVerboseTalkMapper(mockPDO $db, Request $request) { - $talk_mapper = $this->getMockBuilder(TalkMapper::Class) + $talk_mapper = $this->getMockBuilder(TalkMapper::class) ->setConstructorArgs([$db,$request]) ->getMock(); $talk_mapper ->expects($this->once()) ->method('getTalkById') - ->will( - $this->returnValue( - new TalkModel( - [ - 'talk_title' => 'talk_title', - 'url_friendly_talk_title' => 'url_friendly_talk_title', - 'talk_description' => 'talk_desc', - 'type' => 'talk_type', - 'start_date' => 'date_given', - 'duration' => 'duration', - 'stub' => 'stub', - 'average_rating' => 'avg_rating', - 'comments_enabled' => 'comments_enabled', - 'comment_count' => 'comment_count', - 'starred' => 'starred', - 'starred_count' => 'starred_count', - 'event_id' => 1, - 'slides_link' => 'http://slideshare.net', - 'talk_media' => [ - ['slides_link' => 'http://slideshare.net'], - ['code_link' => 'https://github.com'], - ], - ] - ) - ) + ->willReturn( + new TalkModel([ + 'talk_title' => 'talk_title', + 'url_friendly_talk_title' => 'url_friendly_talk_title', + 'talk_description' => 'talk_desc', + 'type' => 'talk_type', + 'start_date' => 'date_given', + 'duration' => 'duration', + 'stub' => 'stub', + 'average_rating' => 'avg_rating', + 'comments_enabled' => 'comments_enabled', + 'comment_count' => 'comment_count', + 'starred' => 'starred', + 'starred_count' => 'starred_count', + 'event_id' => 1, + 'slides_link' => 'http://slideshare.net', + 'talk_media' => [ + ['slides_link' => 'http://slideshare.net'], + ['code_link' => 'https://github.com'], + ], + ]) ); return $talk_mapper; @@ -90,25 +93,21 @@ protected function createVerboseTalkMapper(mockPDO $db, Request $request) protected function createUserMapper(mockPDO $db, Request $request) { - $user_mapper = $this->getMockBuilder(UserMapper::Class) + $user_mapper = $this->getMockBuilder(UserMapper::class) ->setConstructorArgs(array($db,$request)) ->getMock(); $user_mapper ->expects($this->atLeastOnce()) ->method('getUserById') - ->will( - $this->returnValue( + ->willReturn([ + 'users' => [ [ - 'users' => [ - [ - 'username' => 'janebloggs', - 'full_name' => 'Jane Bloggs' - ] - ] + 'username' => 'janebloggs', + 'full_name' => 'Jane Bloggs' ] - ) - ); + ] + ]); return $user_mapper; } @@ -121,27 +120,19 @@ protected function createEventMapper(mockPDO $db, Request $request) $event_mapper ->method('getEventById') - ->will( - $this->returnValue( + ->willReturn([ + 'events' => [ [ - 'events' => [ - [ - 'name' => 'Test Event' - ] - ] + 'name' => 'Test Event' ] - ) - ); + ] + ]); $event_mapper ->method('getHostsEmailAddresses') - ->will( - $this->returnValue( - [ - 'none@example.com' - ] - ) - ); + ->willReturn([ + 'none@example.com', + ]); return $event_mapper; } @@ -162,11 +153,9 @@ protected function createOathModel(mockPDO $db, Request $request, $consumerName $oathModel ->method('getConsumerName') - ->willReturn( - [ - $consumerName - ] - ); + ->willReturn([ + $consumerName + ]); return $oathModel; } diff --git a/tests/controllers/TalkLinkControllerTest.php b/tests/controllers/TalkLinkControllerTest.php index 2d3bff78c..a0140e3a7 100644 --- a/tests/controllers/TalkLinkControllerTest.php +++ b/tests/controllers/TalkLinkControllerTest.php @@ -11,11 +11,13 @@ 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->expectExceptionMessage('Talk Link ID not found'); + $this->expectExceptionCode(404); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'DELETE' @@ -65,11 +67,13 @@ public function testDeleteTalkLink() /** * Test sending delete link with no permissions - * @expectedException \Exception - * @expectedExceptionCode 403 */ 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( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'DELETE' @@ -102,12 +106,12 @@ public function testGetTalkLink() ); } - /** - * @expectedException \Exception - * @expectedExceptionCode 404 - */ public function testGetTalkLinkFails() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('ID not found'); + $this->expectExceptionCode(404); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'GET' @@ -149,12 +153,12 @@ public function testAddTalkLink() ); } - /** - * @expectedException \Exception - * @expectedExceptionCode 400 - */ public function testAddTalkLinkWithInvalidData() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Missing required fields URL OR Display Name'); + $this->expectExceptionCode(400); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'POST' @@ -168,12 +172,12 @@ public function testAddTalkLinkWithInvalidData() ); } - /** - * @expectedException \Exception - * @expectedExceptionCode 400 - */ public function testAddTalkLinkFails() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('The Link has not been inserted'); + $this->expectExceptionCode(400); + $this->makeRequest( 'http://api.dev.joind.in/v2.1/talks/3/links/1234', 'POST' @@ -216,12 +220,12 @@ public function testUpdateTalkLink() ); } - /** - * @expectedException \Exception - * @expectedExceptionCode 500 - */ public function testUpdateTalkLinkFails() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Update of Link ID Failed'); + $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..a0e0ee339 100644 --- a/tests/controllers/TalksControllerDeleteTest.php +++ b/tests/controllers/TalksControllerDeleteTest.php @@ -10,13 +10,12 @@ class TalksControllerDeleteTest extends TalkBase { - /** - * @test - * @expectedExceptionCode 401 - * @expectedException \Exception - */ - public function removeStarFromTalkFailsWhenNotLoggedIn() + public function testRemoveStarFromTalkFailsWhenNotLoggedIn() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to remove data'); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -31,10 +30,7 @@ public function removeStarFromTalkFailsWhenNotLoggedIn() $talks_controller->deleteTalkStarred($request, $db); } - /** - * @test - */ - public function removeStarFromTalksWhenLoggedIn() + public function testRemoveStarFromTalksWhenLoggedIn() { $request = new Request( [], @@ -51,25 +47,22 @@ public function removeStarFromTalksWhenLoggedIn() $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talkMapper = $this->createTalkMapper($db, $request, 0); - $talkMapper->method('setUserNonStarred') + $this->talkMapper = $this->createTalkMapper($db, $request, 0); + $this->talkMapper->method('setUserNonStarred') ->willReturn(true); $talks_controller = new TalksController(); - $talks_controller->setTalkMapper( - $talkMapper - ); + $talks_controller->setTalkMapper($this->talkMapper); $talks_controller->deleteTalkStarred($request, $db); } - /** - * @test - * @expectedExceptionCode 401 - * @expectedException \Exception - */ - public function deleteTalkWhenNotLoggedIn() + public function testDeleteTalkWhenNotLoggedIn() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to remove data'); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -84,10 +77,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', @@ -105,16 +95,12 @@ public function deleteTalkWhichDoesntExist() $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->getMockBuilder(TalkMapper::class) - ->setConstructorArgs([$db,$request]) - ->getMock(); - - $talk_mapper + $this->talk_mapper ->method('getTalkById') ->willReturn(false); $talks_controller = new TalksController(); - $talks_controller->setTalkMapper($talk_mapper); + $talks_controller->setTalkMapper($this->talk_mapper); $view = $this->getMockBuilder(ApiView::class)->getMock(); $request->method('getView')->willReturn($view); @@ -125,13 +111,12 @@ public function deleteTalkWhichDoesntExist() $this->assertNull($talks_controller->deleteTalk($request, $db)); } - /** - * @test - * @expectedException \Exception - * @expectedExceptionCode 400 - */ - public function deleteTalkWthNoAdmin() + public function testDeleteTalkWthNoAdmin() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You do not have permission to do that'); + $this->expectExceptionCode(400); + $request = new Request( [], [ @@ -157,10 +142,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', @@ -178,13 +160,12 @@ public function deleteTalkWithAdmin() $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper ->method('thisUserHasAdminOn') ->willReturn(true); $talks_controller = new TalksController(); - $talks_controller->setTalkMapper($talk_mapper); + $talks_controller->setTalkMapper($this->talk_mapper); $view = $this->getMockBuilder(ApiView::class)->getMock(); $request->method('getView')->willReturn($view); diff --git a/tests/controllers/TalksControllerTest.php b/tests/controllers/TalksControllerTest.php index 3567d6ebc..0cb9672b7 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' => [ @@ -35,13 +35,13 @@ public function setUp() * 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'); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -61,12 +61,13 @@ 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'); + $this->expectExceptionCode(404); + $request = new Request( [], [ @@ -81,16 +82,16 @@ public function testClaimNonExistantTalkThrowsException() $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->getMockBuilder(TalkMapper::class) + $this->talk_mapper = $this->getMockBuilder(TalkMapper::class) ->setConstructorArgs(array($db,$request)) ->getMock(); - $talk_mapper + $this->talk_mapper ->expects($this->once()) ->method('getTalkById') - ->will($this->returnValue(false)); + ->willReturn(false); - $talks_controller->setTalkMapper($talk_mapper); + $talks_controller->setTalkMapper($this->talk_mapper); $event_mapper = $this->createEventMapper($db, $request); $talks_controller->setEventMapper($event_mapper); @@ -103,12 +104,13 @@ public function testClaimNonExistantTalkThrowsException() * an exception is thrown * * @return void - * - * @expectedException \Exception - * @expectedExceptionMessage You must provide a display name and a username */ - public function testClaimTalkWithoutUsernameThrowsException() + public function testClaimTalkWithoutUsernameThrowsException(): void { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must provide a display name and a username'); + $this->expectExceptionCode(400); + $request = new Request( [], [ @@ -125,8 +127,8 @@ public function testClaimTalkWithoutUsernameThrowsException() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talks_controller->setTalkMapper($talk_mapper); + $this->talk_mapper = $this->createTalkMapper($db, $request); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $talks_controller->setUserMapper($user_mapper); @@ -143,12 +145,13 @@ 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'); + $this->expectExceptionCode(400); + $request = new Request( [], [ @@ -165,8 +168,8 @@ public function testClaimTalkWithoutDisplayNameThrowsException() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talks_controller->setTalkMapper($talk_mapper); + $this->talk_mapper = $this->createTalkMapper($db, $request); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $talks_controller->setUserMapper($user_mapper); @@ -182,12 +185,13 @@ 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'); + $this->expectExceptionCode(422); + $request = new Request( [], [ @@ -205,14 +209,12 @@ public function testClaimTalkWithInvalidSpeakerThrowsException() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue(false) - ); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn(false); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $talks_controller->setUserMapper($user_mapper); @@ -228,12 +230,13 @@ 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'); + $this->expectExceptionCode(422); + $request = new Request( [], [ @@ -250,19 +253,15 @@ public function testClaimTalkAlreadyClaimedThrowsException() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => 1, - 'ID' => 1 - ] - ) - ); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn([ + 'speaker_id' => 1, + 'ID' => 1 + ]); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $talks_controller->setUserMapper($user_mapper); @@ -278,12 +277,13 @@ 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'); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -300,29 +300,25 @@ public function testClaimTalkForSomeoneElseThrowsException() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) - ); - $talk_mapper + ->willReturn([ + 'speaker_id' => null, + 'ID' => 1 + ]); + $this->talk_mapper ->expects($this->once()) ->method('thisUserHasAdminOn') - ->will($this->returnValue(false)); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn(false); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(6)); + ->willReturn(6); $talks_controller->setUserMapper($user_mapper); $pending_talk_claim_mapper = $this->getMockBuilder('\PendingTalkClaimMapper') @@ -331,7 +327,7 @@ public function testClaimTalkForSomeoneElseThrowsException() $pending_talk_claim_mapper ->expects($this->once()) ->method('claimExists') - ->will($this->returnValue(false)); + ->willReturn(false); $talks_controller->setPendingTalkClaimMapper($pending_talk_claim_mapper); @@ -346,12 +342,13 @@ 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'); + $this->expectExceptionCode(404); + $request = new Request( [], [ @@ -368,25 +365,21 @@ public function testAssignTalkAsHostToNonExistentUserThrowsException() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) - ); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn([ + 'speaker_id' => null, + 'ID' => 1 + ]); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(false)); + ->willReturn(false); $talks_controller->setUserMapper($user_mapper); $event_mapper = $this->createEventMapper($db, $request); @@ -419,25 +412,21 @@ public function testClaimTalkAsUserIsSuccessful() $talks_controller = new TalksController($this->config); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) - ); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn([ + 'speaker_id' => null, + 'ID' => 1 + ]); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(2)); + ->willReturn(2); $talks_controller->setUserMapper($user_mapper); $pending_talk_claim_mapper = $this->getMockBuilder('\PendingTalkClaimMapper') @@ -446,12 +435,12 @@ public function testClaimTalkAsUserIsSuccessful() $pending_talk_claim_mapper ->expects($this->once()) ->method('claimExists') - ->will($this->returnValue(false)); + ->willReturn(false); $pending_talk_claim_mapper ->expects($this->once()) ->method('claimTalkAsSpeaker') - ->will($this->returnValue(true)); + ->willReturn(true); $talks_controller->setPendingTalkClaimMapper($pending_talk_claim_mapper); $event_mapper = $this->createEventMapper($db, $request); @@ -484,29 +473,25 @@ public function testAssignTalkAsHostIsSuccessful() $talks_controller = new TalksController($this->config); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) - ); - $talk_mapper + ->willReturn([ + 'speaker_id' => null, + 'ID' => 1 + ]); + $this->talk_mapper ->expects($this->once()) ->method('thisUserHasAdminOn') - ->will($this->returnValue(true)); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn(true); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(1)); + ->willReturn(1); $talks_controller->setUserMapper($user_mapper); $pending_talk_claim_mapper = $this->getMockBuilder('\PendingTalkClaimMapper') @@ -515,11 +500,11 @@ public function testAssignTalkAsHostIsSuccessful() $pending_talk_claim_mapper ->expects($this->once()) ->method('claimExists') - ->will($this->returnValue(false)); + ->willReturn(false); $pending_talk_claim_mapper ->expects($this->once()) ->method('assignTalkAsHost') - ->will($this->returnValue(true)); + ->willReturn(true); $talks_controller->setPendingTalkClaimMapper($pending_talk_claim_mapper); $event_mapper = $this->createEventMapper($db, $request); @@ -531,13 +516,13 @@ 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.'); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -554,29 +539,25 @@ public function testApproveAssignmentAsUserWhoClaimedThrowsException() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) - ); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn([ + 'speaker_id' => null, + 'ID' => 1 + ]); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(2)); - $talk_mapper + ->willReturn(2); + $this->talk_mapper ->expects($this->once()) ->method('thisUserHasAdminOn') - ->will($this->returnValue(false)); + ->willReturn(false); $talks_controller->setUserMapper($user_mapper); $pending_talk_claim_mapper = $this->getMockBuilder('\PendingTalkClaimMapper') @@ -585,7 +566,7 @@ public function testApproveAssignmentAsUserWhoClaimedThrowsException() $pending_talk_claim_mapper ->expects($this->once()) ->method('claimExists') - ->will($this->returnValue(\PendingTalkClaimMapper::SPEAKER_CLAIM)); + ->willReturn(\PendingTalkClaimMapper::SPEAKER_CLAIM); $talks_controller->setPendingTalkClaimMapper($pending_talk_claim_mapper); @@ -598,13 +579,13 @@ 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'); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -621,29 +602,25 @@ public function testApproveAssignmentAsNonAdminUserThrowsException() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) - ); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn([ + 'speaker_id' => null, + 'ID' => 1 + ]); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(3)); - $talk_mapper + ->willReturn(3); + $this->talk_mapper ->expects($this->once()) ->method('thisUserHasAdminOn') - ->will($this->returnValue(false)); + ->willReturn(false); $talks_controller->setUserMapper($user_mapper); $pending_talk_claim_mapper = $this->getMockBuilder('\PendingTalkClaimMapper') @@ -652,7 +629,7 @@ public function testApproveAssignmentAsNonAdminUserThrowsException() $pending_talk_claim_mapper ->expects($this->once()) ->method('claimExists') - ->will($this->returnValue(\PendingTalkClaimMapper::SPEAKER_CLAIM)); + ->willReturn(\PendingTalkClaimMapper::SPEAKER_CLAIM); $talks_controller->setPendingTalkClaimMapper($pending_talk_claim_mapper); @@ -666,13 +643,13 @@ 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'); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -689,25 +666,21 @@ public function testApproveClaimAsHostWhoAssignedThrowsException() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) - ); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn([ + 'speaker_id' => null, + 'ID' => 1 + ]); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(1)); + ->willReturn(1); $talks_controller->setUserMapper($user_mapper); $pending_talk_claim_mapper = $this->getMockBuilder('\PendingTalkClaimMapper') @@ -716,7 +689,7 @@ public function testApproveClaimAsHostWhoAssignedThrowsException() $pending_talk_claim_mapper ->expects($this->once()) ->method('claimExists') - ->will($this->returnValue(\PendingTalkClaimMapper::HOST_ASSIGN)); + ->willReturn(\PendingTalkClaimMapper::HOST_ASSIGN); $talks_controller->setPendingTalkClaimMapper($pending_talk_claim_mapper); @@ -748,29 +721,25 @@ public function testApproveAssignmentAsUserSucceeds() $talks_controller = new TalksController(); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) - ); - $talk_mapper + ->willReturn([ + 'speaker_id' => null, + 'ID' => 1 + ]); + $this->talk_mapper ->expects($this->once()) ->method('assignTalkToSpeaker') - ->will($this->returnValue(true)); - $talks_controller->setTalkMapper($talk_mapper); + ->willReturn(true); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(2)); + ->willReturn(2); $talks_controller->setUserMapper($user_mapper); $pending_talk_claim_mapper = $this->getMockBuilder('\PendingTalkClaimMapper') @@ -779,11 +748,11 @@ public function testApproveAssignmentAsUserSucceeds() $pending_talk_claim_mapper ->expects($this->once()) ->method('claimExists') - ->will($this->returnValue(\PendingTalkClaimMapper::HOST_ASSIGN)); + ->willReturn(\PendingTalkClaimMapper::HOST_ASSIGN); $pending_talk_claim_mapper ->expects($this->once()) ->method('approveAssignmentAsSpeaker') - ->will($this->returnValue(true)); + ->willReturn(true); @@ -818,34 +787,30 @@ public function testApproveClaimAsHostSucceeds() $talks_controller = new TalksController($this->config); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) - ); - $talk_mapper + ->willReturn([ + 'speaker_id' => null, + 'ID' => 1 + ]); + $this->talk_mapper ->expects($this->once()) ->method('thisUserHasAdminOn') - ->will($this->returnValue(true)); - $talk_mapper + ->willReturn(true); + $this->talk_mapper ->expects($this->once()) ->method('assignTalkToSpeaker') - ->will($this->returnValue(true)); + ->willReturn(true); - $talks_controller->setTalkMapper($talk_mapper); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->createUserMapper($db, $request); $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(1)); + ->willReturn(1); $talks_controller->setUserMapper($user_mapper); $pending_talk_claim_mapper = $this->getMockBuilder('\PendingTalkClaimMapper') @@ -854,11 +819,11 @@ public function testApproveClaimAsHostSucceeds() $pending_talk_claim_mapper ->expects($this->once()) ->method('claimExists') - ->will($this->returnValue(\PendingTalkClaimMapper::SPEAKER_CLAIM)); + ->willReturn(\PendingTalkClaimMapper::SPEAKER_CLAIM); $pending_talk_claim_mapper ->expects($this->once()) ->method('approveClaimAsHost') - ->will($this->returnValue(true)); + ->willReturn(true); $talks_controller->setPendingTalkClaimMapper($pending_talk_claim_mapper); @@ -914,14 +879,14 @@ public function testCommentOnTalk( $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper ->method('getSpeakerEmailsByTalkId') ->willReturn($speakerEmails); $talks_controller->setTalkMapper( - $talk_mapper + $this->talk_mapper ); $talk_comment = $this->createTalkCommentMapper($db, $request); @@ -981,12 +946,12 @@ public function getComments() ]; } - /** - * @expectedException Exception - * @expectedExceptionCode 401 - */ public function testNotLoggedInPostAction() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must be logged in to create data'); + $this->expectExceptionCode(401); + $request = new Request( [], [ @@ -1000,12 +965,12 @@ public function testNotLoggedInPostAction() $talks_controller->postAction($request, $db); } - /** - * @expectedException Exception - * @expectedExceptionCode 400 - */ public function testNotSendingMessage() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('The field "comment" is required'); + $this->expectExceptionCode(400); + $request = new Request( [], [ @@ -1021,23 +986,21 @@ public function testNotSendingMessage() ]; $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper = $this->createTalkMapper($db, $request); $talks_controller = new TalksController(); - $talks_controller->setTalkMapper( - $talk_mapper - ); + $talks_controller->setTalkMapper($this->talk_mapper); $talks_controller->postAction($request, $db); } - /** - * @expectedException Exception - * @expectedExceptionCode 400 - */ public function testNotSendingRating() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('The field "rating" is required'); + $this->expectExceptionCode(400); + $request = new Request( [], [ @@ -1053,13 +1016,11 @@ public function testNotSendingRating() ]; $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper = $this->createTalkMapper($db, $request); $talks_controller = new TalksController(); - $talks_controller->setTalkMapper( - $talk_mapper - ); + $talks_controller->setTalkMapper($this->talk_mapper); $talks_controller->postAction($request, $db); } @@ -1087,24 +1048,22 @@ public function testRejectClaimAsHostSucceeds() $talks_controller = new TalksController($this->config); $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); - $talk_mapper + $this->talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper ->expects($this->once()) ->method('getSpeakerFromTalk') - ->will( - $this->returnValue( - [ - 'speaker_id' => null, - 'ID' => 1 - ] - ) + ->willReturn( + [ + 'speaker_id' => null, + 'ID' => 1 + ] ); - $talk_mapper + $this->talk_mapper ->expects($this->once()) ->method('thisUserHasAdminOn') - ->will($this->returnValue(true)); + ->willReturn(true); - $talks_controller->setTalkMapper($talk_mapper); + $talks_controller->setTalkMapper($this->talk_mapper); $user_mapper = $this->getMockBuilder('\UserMapper') ->setConstructorArgs(array($db,$request)) @@ -1113,7 +1072,7 @@ public function testRejectClaimAsHostSucceeds() $user_mapper ->expects($this->once()) ->method('getUserIdFromUsername') - ->will($this->returnValue(1)); + ->willReturn(1); $talks_controller->setUserMapper($user_mapper); $pending_talk_claim_mapper = $this->getMockBuilder('\PendingTalkClaimMapper') @@ -1122,11 +1081,11 @@ public function testRejectClaimAsHostSucceeds() $pending_talk_claim_mapper ->expects($this->once()) ->method('claimExists') - ->will($this->returnValue(\PendingTalkClaimMapper::SPEAKER_CLAIM)); + ->willReturn(\PendingTalkClaimMapper::SPEAKER_CLAIM); $pending_talk_claim_mapper ->expects($this->once()) ->method('rejectClaimAsHost') - ->will($this->returnValue(true)); + ->willReturn(true); $talks_controller->setPendingTalkClaimMapper($pending_talk_claim_mapper); @@ -1149,19 +1108,19 @@ public function testDifferentTalkMedia() $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createTalkMapper($db, $request); + $this->talk_mapper = $this->createTalkMapper($db, $request); $expected = [ ['slides_link' => 'http://slideshare.net'], ['code_link' => 'https://github.com/link/to/repo'], ]; - $talk_mapper + $this->talk_mapper ->method('getTalkMediaLinks') ->willReturn($expected); $talks_controller = new TalkLinkController(); - $talks_controller->setTalkMapper($talk_mapper); + $talks_controller->setTalkMapper($this->talk_mapper); $output = $talks_controller->getTalkLinks($request, $db); $this->assertSame( @@ -1186,7 +1145,7 @@ public function testVerboseTalkOutput() $db = $this->getMockBuilder(mockPDO::class)->getMock(); - $talk_mapper = $this->createVerboseTalkMapper($db, $request); + $this->talk_mapper = $this->createVerboseTalkMapper($db, $request); $expected = [ ['slides_link' => 'http://slideshare.net'], @@ -1194,7 +1153,7 @@ public function testVerboseTalkOutput() ]; $talks_controller = new TalksController(); - $talks_controller->setTalkMapper($talk_mapper); + $talks_controller->setTalkMapper($this->talk_mapper); $output = $talks_controller->getAction($request, $db); @@ -1324,12 +1283,12 @@ public function testSearchByTitle() $this->assertSame($expected, $output); } - /** - * @expectedException Exception - * @expectedExceptionCode 405 - */ public function testGenericTalkList() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Generic talks listing not supported'); + $this->expectExceptionCode(405); + $request = new Request( [], [ diff --git a/tests/controllers/TokenControllerTest.php b/tests/controllers/TokenControllerTest.php index b2b4cecde..1fb6ef66c 100644 --- a/tests/controllers/TokenControllerTest.php +++ b/tests/controllers/TokenControllerTest.php @@ -10,31 +10,29 @@ 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(); } - /** - * @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..135c57a12 100644 --- a/tests/controllers/UsersControllerTest.php +++ b/tests/controllers/UsersControllerTest.php @@ -12,13 +12,13 @@ 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'); + $this->expectExceptionCode(401); + $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); $usersController = new \UsersController(); @@ -32,13 +32,13 @@ 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'); + $this->expectExceptionCode(403); + $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); $request->user_id = 2; $usersController = new \UsersController(); @@ -53,7 +53,7 @@ public function testDeleteUserWithNonAdminIdThrowsException() $userMapper ->expects($this->once()) ->method('isSiteAdmin') - ->will($this->returnValue(false)); + ->willReturn(false); $usersController->setUserMapper($userMapper); $usersController->deleteUser($request, $db); @@ -64,13 +64,13 @@ 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'); + $this->expectExceptionCode(400); + $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); $request->user_id = 1; $usersController = new \UsersController(); @@ -85,12 +85,12 @@ public function testDeleteUserWithAdminAccessThrowsExceptionOnFailedDelete() $userMapper ->expects($this->once()) ->method('isSiteAdmin') - ->will($this->returnValue(true)); + ->willReturn(true); $userMapper ->expects($this->once()) ->method('delete') - ->will($this->returnValue(false)); + ->willReturn(false); $usersController->setUserMapper($userMapper); $usersController->deleteUser($request, $db); @@ -119,12 +119,12 @@ public function testDeleteUserWithAdminAccessDeletesSuccessfully() $userMapper ->expects($this->once()) ->method('isSiteAdmin') - ->will($this->returnValue(true)); + ->willReturn(true); $userMapper ->expects($this->once()) ->method('delete') - ->will($this->returnValue(true)); + ->willReturn(true); $usersController->setUserMapper($userMapper); $this->assertNull($usersController->deleteUser($request, $db)); @@ -236,14 +236,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 +257,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(); @@ -278,7 +276,7 @@ public function testSetTrustedWithNonAdminIdThrowsException() $userMapper ->expects($this->once()) ->method('isSiteAdmin') - ->will($this->returnValue(false)); + ->willReturn(false); $usersController->setUserMapper($userMapper); $usersController->setTrusted($request, $db); @@ -291,14 +289,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 +323,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') @@ -350,7 +346,7 @@ public function testSetTrustedWithFailureThrowsException() $userMapper ->expects($this->once()) ->method('isSiteAdmin') - ->will($this->returnValue(true)); + ->willReturn(true); $userMapper ->expects($this->once()) @@ -400,7 +396,7 @@ public function testSetTrustedWithSuccessCreatesView() $userMapper ->expects($this->once()) ->method('isSiteAdmin') - ->will($this->returnValue(true)); + ->willReturn(true); $userMapper ->expects($this->once()) 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/HeaderTest.php b/tests/inc/HeaderTest.php index 837b63479..57e90d507 100644 --- a/tests/inc/HeaderTest.php +++ b/tests/inc/HeaderTest.php @@ -1,12 +1,4 @@ setGlue(','); $header->parseParams(); $entityArray = $header->buildEntityArray(); - $this->assertEquals(3, count($entityArray['For'])); - $this->assertEquals(3, count($entityArray['User-agent'])); + $this->assertCount(3, $entityArray['For']); + $this->assertCount(3, $entityArray['User-agent']); } public function testBuildEntityArrayWithValueOnly() { @@ -57,6 +49,6 @@ public function testBuildEntityArrayWithValueOnly() $partsArray = $header->toArray(); $this->assertEquals('10.0.0.1', $partsArray[0]); $entityArray = $header->buildEntityArray(); - $this->assertEquals(3, count($entityArray[0])); + $this->assertCount(3, $entityArray[0]); } } diff --git a/tests/inc/RequestTest.php b/tests/inc/RequestTest.php index bfef3897a..decade7e9 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; @@ -22,10 +22,9 @@ public function setUp() * * @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( @@ -314,7 +296,7 @@ public function jsonBodyIsParsedAsParameters($method) ->getMock(); $request->expects($this->once()) ->method('getRawBody') - ->will($this->returnValue($body)); + ->willReturn($body); $request->setVerb($method); $request->parseParameters($server); @@ -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,14 +394,13 @@ public function schemeProvider() * doesn't have two parts * * @return void - * - * @test - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid Authorization Header - * @expectedExceptionCode 400 */ - public function ifIdentificationDoesNotHaveTwoPartsExceptionIsThrown() + public function testIfIdentificationDoesNotHaveTwoPartsExceptionIsThrown() { + $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'); } @@ -435,14 +410,13 @@ public function ifIdentificationDoesNotHaveTwoPartsExceptionIsThrown() * start with oauth * * @return void - * - * @test - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Unknown Authorization Header Received - * @expectedExceptionCode 400 */ - public function ifIdentificationHeaderDoesNotStartWithOauthThrowException() + public function testIfIdentificationHeaderDoesNotStartWithOauthThrowException() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Unknown Authorization Header Received'); + $this->expectExceptionCode(400); + $request = new \Request($this->config, ['HTTPS' => 'on']); $request->identifyUser('Auth Me'); } @@ -451,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, []); @@ -467,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 @@ -490,13 +460,13 @@ public function getOauthModelProvidesAnOauthModel() * set, and no PDO adapter is provided, an exception is thrown * * @return void - * - * @test - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Db Must be provided to get Oauth Model */ - public function callingGetOauthModelWithoutADatabaseAdapterThrowsAnException() + public function testCallingGetOauthModelWithoutADatabaseAdapterThrowsAnException() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Db Must be provided to get Oauth Model'); + $this->expectExceptionCode(0); + $request = new \Request($this->config, []); $request->getOauthModel(); } @@ -505,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(); @@ -522,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(); @@ -540,17 +506,15 @@ 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(); $mockOauth->expects($this->once()) ->method('verifyAccessToken') ->with('authPart') - ->will($this->returnValue('TheUserId')); + ->willReturn('TheUserId'); $request->setOauthModel($mockOauth); @@ -565,17 +529,15 @@ 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(); $mockOauth->expects($this->once()) ->method('verifyAccessToken') ->with('authPart') - ->will($this->returnValue('TheUserId')); + ->willReturn('TheUserId'); $request->setOauthModel($mockOauth); @@ -589,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')); @@ -603,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(); @@ -619,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); @@ -641,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())); @@ -654,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); @@ -675,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())); @@ -688,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(); @@ -704,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())); @@ -786,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(), @@ -848,8 +792,6 @@ public function getSetFormatChoicesProvider() * * @param array $expected * @param array|null $choices - * - * @test */ public function testGetSetFormatChoices( array $expected, @@ -891,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/models/ApiMapperTest.php b/tests/models/ApiMapperTest.php index 97686b82e..aca03c252 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() @@ -18,14 +18,6 @@ public function setup() ->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); diff --git a/tests/models/OauthModelTest.php b/tests/models/OauthModelTest.php index 4ca04029d..f1710759a 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() @@ -34,12 +34,12 @@ public function testWrongPasswordReturnsFalse() ); } - /** - * @expectedException Exception - * @expectedExceptionCode 401 - */ public function testWrongUserThrowsException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Not verified'); + $this->expectExceptionCode(401); + $stmt = $this->getMockBuilder(PDOStatement::class)->getMock(); $stmt->method('execute')->willReturn(true); $stmt->method('fetch')->willReturn( diff --git a/tests/routers/RouteTest.php b/tests/routers/RouteTest.php index ab7132d5a..6da37565e 100644 --- a/tests/routers/RouteTest.php +++ b/tests/routers/RouteTest.php @@ -168,12 +168,12 @@ 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') ->with(1) - ->will($this->returnValue($urlElement)); + ->willReturn($urlElement); return $request; } 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')); diff --git a/tests/views/ApiViewTest.php b/tests/views/ApiViewTest.php index 26d2744f7..e10912454 100644 --- a/tests/views/ApiViewTest.php +++ b/tests/views/ApiViewTest.php @@ -63,6 +63,10 @@ public function testThatHeadersAreSet() $expectedHeaders = [ 'Foo: bar', ]; + + if (!function_exists('xdebug_get_headers')) { + $this->markTestSkipped('Test will run when xdebug enabled'); + } $this->assertEquals($expectedHeaders, xdebug_get_headers()); } @@ -72,6 +76,10 @@ public function testThatHeadersAreSet() */ public function testThatHeadersAreSetViaSetHeaders() { + if (!function_exists('xdebug_get_headers')) { + $this->markTestSkipped('Test will run when xdebug enabled'); + } + $view = new ApiView(); $view->setHeader('Bar', 'Foo'); @@ -101,7 +109,12 @@ public function testThatSettingHeadersDoesntOverwriteIntendedHeaders() $expectedHeaders = [ 'Location: http://example.org', ]; - $this->assertEquals($expectedHeaders, xdebug_get_headers()); + $this->assertEquals(201, http_response_code()); + + if (!function_exists('xdebug_get_headers')) { + $this->markTestSkipped('Test will run when xdebug enabled'); + } + $this->assertEquals($expectedHeaders, xdebug_get_headers()); } } diff --git a/tools/codesniffer/JoindInPSR2/ruleset.xml b/tools/codesniffer/JoindInPSR2/ruleset.xml deleted file mode 100644 index 3bfaba0b8..000000000 --- a/tools/codesniffer/JoindInPSR2/ruleset.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - The Joind.in coding standard (PSR2, no namespace). - - - - - - - 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