From 9c4c39fb0b0e4a147ec444a852ccdac7a79cd9d1 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 6 Feb 2019 22:48:00 -0500 Subject: [PATCH] [WIP] Make it compatible with PHP 5.5; fix PHPStorm warnings --- .gitignore | 4 +- composer.json | 8 +- composer.lock | 975 +++++++-------------- src/Activities/ActivityEvent.php | 2 +- src/Activities/CreateHandler.php | 6 +- src/Activities/DeleteHandler.php | 4 +- src/Activities/FollowHandler.php | 11 +- src/Activities/InboxActivityEvent.php | 2 +- src/Activities/NonActivityHandler.php | 25 +- src/Activities/OutboxActivityEvent.php | 2 +- src/Activities/ValidationHandler.php | 30 +- src/ActivityPub.php | 9 +- src/Auth/AuthListener.php | 2 +- src/Auth/AuthService.php | 2 +- src/Auth/SignatureListener.php | 2 +- src/Collections/CollectionsService.php | 56 -- src/Config/ActivityPubConfig.php | 4 +- src/Config/ActivityPubConfigBuilder.php | 15 +- src/Config/ActivityPubModule.php | 7 +- src/Controllers/GetController.php | 6 +- src/Controllers/PostController.php | 5 +- src/Crypto/HttpSignatureService.php | 30 +- src/Crypto/RsaKeypair.php | 8 +- src/Database/PrefixNamingStrategy.php | 2 +- src/Entities/ActivityPubObject.php | 20 +- src/Entities/Field.php | 10 +- src/Entities/PrivateKey.php | 6 +- src/Http/Router.php | 2 +- src/Objects/CollectionsService.php | 53 +- src/Objects/ContextProvider.php | 17 +- src/Objects/IdProvider.php | 6 +- src/Objects/ObjectsService.php | 15 +- src/Utils/DateTimeProvider.php | 4 +- src/Utils/RandomProvider.php | 4 +- src/Utils/SimpleDateTimeProvider.php | 2 +- src/Utils/Util.php | 2 +- test/Activities/CreateHandlerTest.php | 16 +- test/Activities/DeleteHandlerTest.php | 41 +- test/Activities/FollowHandlerTest.php | 15 +- test/Activities/NonActivityHandlerTest.php | 10 +- test/Activities/UpdateHandlerTest.php | 53 +- test/Activities/ValidationHandlerTest.php | 21 +- test/ActivityPubTest.php | 2 +- test/Auth/AuthListenerTest.php | 10 +- test/Auth/AuthServiceTest.php | 6 +- test/Auth/SignatureListenerTest.php | 39 +- test/Config/ActivityPubModuleTest.php | 6 +- test/Controllers/GetControllerTest.php | 116 +-- test/Controllers/PostControllerTest.php | 114 ++- test/Crypto/HttpSignatureServiceTest.php | 6 +- test/Crypto/RsaKeypairTest.php | 16 +- test/Entities/EntityTest.php | 2 +- test/Http/RouterTest.php | 16 +- test/Objects/CollectionsServiceTest.php | 18 +- test/Objects/IdProviderTest.php | 10 +- test/Objects/ObjectsServiceTest.php | 9 +- test/TestConfig/APTestCase.php | 12 + test/TestConfig/ArrayDataSet.php | 12 +- test/TestConfig/SQLiteTestCase.php | 11 +- test/TestUtils/TestActivityPubObject.php | 2 +- test/TestUtils/TestDateTimeProvider.php | 2 +- test/TestUtils/TestField.php | 5 +- test/Utils/UtilTest.php | 6 +- test/bootstrap.php | 2 +- test/config.xml | 2 +- 65 files changed, 817 insertions(+), 1121 deletions(-) delete mode 100644 src/Collections/CollectionsService.php create mode 100644 test/TestConfig/APTestCase.php diff --git a/.gitignore b/.gitignore index 8af3c9b..82da157 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ vendor/ -test/db.sqlite \ No newline at end of file +test/db.sqlite +./.idea/ +/.idea diff --git a/composer.json b/composer.json index 33467e6..e9a5b37 100644 --- a/composer.json +++ b/composer.json @@ -30,11 +30,13 @@ "symfony/dependency-injection": "^4.2", "symfony/http-kernel": "^4.2", "symfony/psr-http-message-bridge": "^1.1", - "zendframework/zend-diactoros": "^1.8" + "zendframework/zend-diactoros": "^1.8", + "ext-json": "*" }, "require-dev": { - "phpunit/dbunit": "^4.0", - "phpunit/phpunit": "^7.4" + "phpunit/dbunit": "^2.0", + "phpunit/phpunit": "^4.0", + "ext-pdo": "*" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index b2e2eae..28795cb 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": "d765cce5f542dc7c2bee097427f2318e", + "content-hash": "2d1f5780856feb51761f2c0a5a39cf07", "packages": [ { "name": "doctrine/annotations", @@ -1096,16 +1096,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "2.0.13", + "version": "2.0.14", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "42603ce3f42a27f7e14e54feab95db7b680ad473" + "reference": "8ebfcadbf30524aeb75b2c446bc2519d5b321478" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/42603ce3f42a27f7e14e54feab95db7b680ad473", - "reference": "42603ce3f42a27f7e14e54feab95db7b680ad473", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/8ebfcadbf30524aeb75b2c446bc2519d5b321478", + "reference": "8ebfcadbf30524aeb75b2c446bc2519d5b321478", "shasum": "" }, "require": { @@ -1184,7 +1184,7 @@ "x.509", "x509" ], - "time": "2018-12-16T17:45:25+00:00" + "time": "2019-01-27T19:37:29+00:00" }, { "name": "psr/container", @@ -1374,16 +1374,16 @@ }, { "name": "symfony/console", - "version": "v4.2.1", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "4dff24e5d01e713818805c1862d2e3f901ee7dd0" + "reference": "1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/4dff24e5d01e713818805c1862d2e3f901ee7dd0", - "reference": "4dff24e5d01e713818805c1862d2e3f901ee7dd0", + "url": "https://api.github.com/repos/symfony/console/zipball/1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4", + "reference": "1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4", "shasum": "" }, "require": { @@ -1395,6 +1395,9 @@ "symfony/dependency-injection": "<3.4", "symfony/process": "<3.3" }, + "provide": { + "psr/log-implementation": "1.0" + }, "require-dev": { "psr/log": "~1.0", "symfony/config": "~3.4|~4.0", @@ -1404,7 +1407,7 @@ "symfony/process": "~3.4|~4.0" }, "suggest": { - "psr/log-implementation": "For using the console logger", + "psr/log": "For using the console logger", "symfony/event-dispatcher": "", "symfony/lock": "", "symfony/process": "" @@ -1439,7 +1442,7 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-11-27T07:40:44+00:00" + "time": "2019-01-25T14:35:16+00:00" }, { "name": "symfony/contracts", @@ -1511,16 +1514,16 @@ }, { "name": "symfony/debug", - "version": "v4.2.2", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "64cb33c81e37d19b7715d4a6a4d49c1c382066dd" + "reference": "cf9b2e33f757deb884ce474e06d2647c1c769b65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/64cb33c81e37d19b7715d4a6a4d49c1c382066dd", - "reference": "64cb33c81e37d19b7715d4a6a4d49c1c382066dd", + "url": "https://api.github.com/repos/symfony/debug/zipball/cf9b2e33f757deb884ce474e06d2647c1c769b65", + "reference": "cf9b2e33f757deb884ce474e06d2647c1c769b65", "shasum": "" }, "require": { @@ -1563,20 +1566,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2019-01-03T09:07:35+00:00" + "time": "2019-01-25T14:35:16+00:00" }, { "name": "symfony/dependency-injection", - "version": "v4.2.2", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "a28dda9df1d5494367454cad91e44751ac53921c" + "reference": "72c14cbc0c27706b9b4c33b9cd7a280972ff4806" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/a28dda9df1d5494367454cad91e44751ac53921c", - "reference": "a28dda9df1d5494367454cad91e44751ac53921c", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/72c14cbc0c27706b9b4c33b9cd7a280972ff4806", + "reference": "72c14cbc0c27706b9b4c33b9cd7a280972ff4806", "shasum": "" }, "require": { @@ -1636,20 +1639,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2019-01-05T16:37:49+00:00" + "time": "2019-01-30T17:51:38+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.2.2", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "887de6d34c86cf0cb6cbf910afb170cdb743cb5e" + "reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/887de6d34c86cf0cb6cbf910afb170cdb743cb5e", - "reference": "887de6d34c86cf0cb6cbf910afb170cdb743cb5e", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1", + "reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1", "shasum": "" }, "require": { @@ -1700,20 +1703,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-01-05T16:37:49+00:00" + "time": "2019-01-16T20:35:37+00:00" }, { "name": "symfony/http-foundation", - "version": "v4.2.2", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "a633d422a09242064ba24e44a6e1494c5126de86" + "reference": "8d2318b73e0a1bc75baa699d00ebe2ae8b595a39" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/a633d422a09242064ba24e44a6e1494c5126de86", - "reference": "a633d422a09242064ba24e44a6e1494c5126de86", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8d2318b73e0a1bc75baa699d00ebe2ae8b595a39", + "reference": "8d2318b73e0a1bc75baa699d00ebe2ae8b595a39", "shasum": "" }, "require": { @@ -1754,20 +1757,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-01-05T16:37:49+00:00" + "time": "2019-01-29T09:49:29+00:00" }, { "name": "symfony/http-kernel", - "version": "v4.2.2", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "83de6543328917c18d5498eeb6bb6d36f7aab31b" + "reference": "d56b1706abaa771eb6acd894c6787cb88f1dc97d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/83de6543328917c18d5498eeb6bb6d36f7aab31b", - "reference": "83de6543328917c18d5498eeb6bb6d36f7aab31b", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/d56b1706abaa771eb6acd894c6787cb88f1dc97d", + "reference": "d56b1706abaa771eb6acd894c6787cb88f1dc97d", "shasum": "" }, "require": { @@ -1843,7 +1846,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2019-01-06T16:19:23+00:00" + "time": "2019-02-03T12:47:33+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2089,156 +2092,6 @@ } ], "packages-dev": [ - { - "name": "myclabs/deep-copy", - "version": "1.8.1", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "replace": { - "myclabs/deep-copy": "self.version" - }, - "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2018-06-11T23:09:50+00:00" - }, - { - "name": "phar-io/manifest", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-phar": "*", - "phar-io/version": "^2.0", - "php": "^5.6 || ^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2018-07-08T19:23:20+00:00" - }, - { - "name": "phar-io/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/version.git", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Library for handling version information and constraints", - "time": "2018-07-08T19:19:57+00:00" - }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", @@ -2456,140 +2309,28 @@ }, { "name": "phpunit/dbunit", - "version": "4.0.0", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/dbunit.git", - "reference": "e77b469c3962b5a563f09a2a989f1c9bd38b8615" + "reference": "5c35d74549c21ba55d0ea74ba89d191a51f8cf25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/e77b469c3962b5a563f09a2a989f1c9bd38b8615", - "reference": "e77b469c3962b5a563f09a2a989f1c9bd38b8615", + "url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/5c35d74549c21ba55d0ea74ba89d191a51f8cf25", + "reference": "5c35d74549c21ba55d0ea74ba89d191a51f8cf25", "shasum": "" }, "require": { "ext-pdo": "*", "ext-simplexml": "*", - "php": "^7.1", - "phpunit/phpunit": "^7.0", - "symfony/yaml": "^3.0 || ^4.0" + "php": "^5.4 || ^7.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0", + "symfony/yaml": "^2.1 || ^3.0" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" + "bin": [ + "dbunit" ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "PHPUnit extension for database interaction testing", - "homepage": "https://github.com/sebastianbergmann/dbunit/", - "keywords": [ - "database", - "testing", - "xunit" - ], - "abandoned": true, - "time": "2018-02-07T06:47:59+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "6.1.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1 || ^4.0", - "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "suggest": { - "ext-xdebug": "^2.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.1-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": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2018-10-31T16:06:48+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "050bedf145a257b1ff02746c31894800e5122946" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", - "reference": "050bedf145a257b1ff02746c31894800e5122946", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.1" - }, "type": "library", "extra": { "branch-alias": { @@ -2608,7 +2349,118 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "DbUnit port for PHP/PHPUnit to support database interaction testing.", + "homepage": "https://github.com/sebastianbergmann/dbunit/", + "keywords": [ + "database", + "testing", + "xunit" + ], + "abandoned": true, + "time": "2016-12-02T14:39:14+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "^1.3.2", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.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": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-10-06T15:47:00+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.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" } ], @@ -2618,7 +2470,7 @@ "filesystem", "iterator" ], - "time": "2018-09-13T20:33:42+00:00" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -2663,28 +2515,28 @@ }, { "name": "phpunit/php-timer", - "version": "2.0.0", + "version": "1.0.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", - "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -2699,7 +2551,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", + "email": "sb@sebastian-bergmann.de", "role": "lead" } ], @@ -2708,33 +2560,33 @@ "keywords": [ "timer" ], - "time": "2018-02-01T13:07:23+00:00" + "time": "2017-02-26T11:10:40+00:00" }, { "name": "phpunit/php-token-stream", - "version": "3.0.1", + "version": "1.4.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18" + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18", - "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.1" + "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "~4.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -2757,57 +2609,45 @@ "keywords": [ "tokenizer" ], - "time": "2018-10-30T05:52:18+00:00" + "time": "2017-12-04T08:55:13+00:00" }, { "name": "phpunit/phpunit", - "version": "7.5.1", + "version": "4.8.36", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c23d78776ad415d5506e0679723cb461d71f488f" + "reference": "46023de9a91eec7dfb06cc56cb4e260017298517" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c23d78776ad415d5506e0679723cb461d71f488f", - "reference": "c23d78776ad415d5506e0679723cb461d71f488f", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517", + "reference": "46023de9a91eec7dfb06cc56cb4e260017298517", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.1", "ext-dom": "*", "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "^1.7", - "phar-io/manifest": "^1.0.2", - "phar-io/version": "^2.0", - "php": "^7.1", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0.7", - "phpunit/php-file-iterator": "^2.0.1", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.0", - "sebastian/comparator": "^3.0", - "sebastian/diff": "^3.0", - "sebastian/environment": "^4.0", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0", - "sebastian/version": "^2.0.1" - }, - "conflict": { - "phpunit/phpunit-mock-objects": "*" - }, - "require-dev": { - "ext-pdo": "*" + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "^1.3.1", + "phpunit/php-code-coverage": "~2.1", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "^1.0.6", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.2.2", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.3", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0" + "phpunit/php-invoker": "~1.1" }, "bin": [ "phpunit" @@ -2815,7 +2655,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.5-dev" + "dev-master": "4.8.x-dev" } }, "autoload": { @@ -2841,84 +2681,38 @@ "testing", "xunit" ], - "time": "2018-12-12T07:20:32+00:00" + "time": "2017-06-21T08:07:12+00:00" }, { - "name": "psr/http-factory", - "version": "1.0.0", + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.8", "source": { "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "378bfe27931ecc54ff824a20d6f6bfc303bbd04c" + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/378bfe27931ecc54ff824a20d6f6bfc303bbd04c", - "reference": "378bfe27931ecc54ff824a20d6f6bfc303bbd04c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", "shasum": "" }, "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "time": "2018-07-30T21:54:04+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" + "doctrine/instantiator": "^1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2", + "sebastian/exporter": "~1.2" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.3.x-dev" } }, "autoload": { @@ -2933,39 +2727,44 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "email": "sb@sebastian-bergmann.de", + "role": "lead" } ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-10-02T06:51:40+00:00" }, { "name": "sebastian/comparator", - "version": "3.0.2", + "version": "1.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", "shasum": "" }, "require": { - "php": "^7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2 || ~2.0" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -2996,39 +2795,38 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", + "homepage": "http://www.github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2018-07-12T15:12:46+00:00" + "time": "2017-01-29T09:50:25+00:00" }, { "name": "sebastian/diff", - "version": "3.0.1", + "version": "1.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "366541b989927187c4ca70490a35615d3fef2dce" + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/366541b989927187c4ca70490a35615d3fef2dce", - "reference": "366541b989927187c4ca70490a35615d3fef2dce", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^7.0", - "symfony/process": "^2 || ^3.3 || ^4" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3053,37 +2851,34 @@ "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" + "diff" ], - "time": "2018-06-10T07:54:39+00:00" + "time": "2017-05-22T07:24:03+00:00" }, { "name": "sebastian/environment", - "version": "4.0.1", + "version": "1.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "febd209a219cea7b56ad799b30ebbea34b71eb8f" + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/febd209a219cea7b56ad799b30ebbea34b71eb8f", - "reference": "febd209a219cea7b56ad799b30ebbea34b71eb8f", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^7.4" + "phpunit/phpunit": "^4.8 || ^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -3108,34 +2903,34 @@ "environment", "hhvm" ], - "time": "2018-11-25T09:31:21+00:00" + "time": "2016-08-18T05:49:44+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.0", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/recursion-context": "^3.0" + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -3175,27 +2970,27 @@ "export", "exporter" ], - "time": "2017-04-03T13:19:02+00:00" + "time": "2016-06-17T09:04:28+00:00" }, { "name": "sebastian/global-state", - "version": "2.0.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "~4.2" }, "suggest": { "ext-uopz": "*" @@ -3203,7 +2998,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -3226,124 +3021,32 @@ "keywords": [ "global state" ], - "time": "2017-04-27T15:39:26+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "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" + "time": "2015-10-12T03:26:01+00:00" }, { "name": "sebastian/recursion-context", - "version": "3.0.0", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -3371,73 +3074,23 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "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" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2018-10-04T04:07:39+00:00" + "time": "2016-10-03T07:41:43+00:00" }, { "name": "sebastian/version", - "version": "2.0.1", + "version": "1.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", "shasum": "" }, - "require": { - "php": ">=5.6" - }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, "autoload": { "classmap": [ "src/" @@ -3456,24 +3109,24 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03T07:35:21+00:00" + "time": "2015-06-21T13:59:46+00:00" }, { "name": "symfony/yaml", - "version": "v4.2.1", + "version": "v3.4.22", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "c41175c801e3edfda90f32e292619d10c27103d7" + "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/c41175c801e3edfda90f32e292619d10c27103d7", - "reference": "c41175c801e3edfda90f32e292619d10c27103d7", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ba11776e9e6c15ad5759a07bffb15899bac75c2d", + "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": "^5.5.9|>=7.0.8", "symfony/polyfill-ctype": "~1.8" }, "conflict": { @@ -3488,7 +3141,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3515,47 +3168,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-11-11T19:52:12+00:00" - }, - { - "name": "theseer/tokenizer", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/theseer/tokenizer.git", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": "^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" - } - ], - "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2017-04-07T12:08:54+00:00" + "time": "2019-01-16T10:59:17+00:00" }, { "name": "webmozart/assert", @@ -3614,6 +3227,8 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "ext-json": "*" + }, "platform-dev": [] } diff --git a/src/Activities/ActivityEvent.php b/src/Activities/ActivityEvent.php index 952dffa..603d240 100644 --- a/src/Activities/ActivityEvent.php +++ b/src/Activities/ActivityEvent.php @@ -86,4 +86,4 @@ class ActivityEvent extends Event $this->response = $response; } } -?> + diff --git a/src/Activities/CreateHandler.php b/src/Activities/CreateHandler.php index 1349cb1..3fbf72c 100644 --- a/src/Activities/CreateHandler.php +++ b/src/Activities/CreateHandler.php @@ -1,8 +1,6 @@ + diff --git a/src/Activities/DeleteHandler.php b/src/Activities/DeleteHandler.php index 00f3202..45c7efc 100644 --- a/src/Activities/DeleteHandler.php +++ b/src/Activities/DeleteHandler.php @@ -77,7 +77,7 @@ class DeleteHandler implements EventSubscriberInterface ->format( DateTime::ISO8601 ); } - public function authorized( Request $request, string $objectId ) + public function authorized( Request $request, $objectId ) { if ( ! $request->attributes->has( 'actor' ) ) { return false; @@ -94,4 +94,4 @@ class DeleteHandler implements EventSubscriberInterface return $requestActor['id'] === $attributedActorId; } } -?> + diff --git a/src/Activities/FollowHandler.php b/src/Activities/FollowHandler.php index f5e9cff..760a84c 100644 --- a/src/Activities/FollowHandler.php +++ b/src/Activities/FollowHandler.php @@ -28,7 +28,7 @@ class FollowHandler implements EventSubscriberInterface ); } - public function __construct( bool $autoAccepts, + public function __construct( $autoAccepts, ContextProvider $contextProvider ) { $this->autoAccepts = $autoAccepts; @@ -36,7 +36,7 @@ class FollowHandler implements EventSubscriberInterface } public function handleInbox( InboxActivityEvent $event, - string $eventName, + $eventName, EventDispatcher $eventDispatcher ) { $activity = $event->getActivity(); @@ -68,10 +68,13 @@ class FollowHandler implements EventSubscriberInterface ), json_encode( $accept ) ); - $request->attributes->set( 'actor', $localActor ); + $request->attributes->add( array( + 'actor' => $localActor, + 'follow' => $activity, + ) ); $outboxEvent = new OutboxActivityEvent( $accept, $localActor, $request ); $eventDispatcher->dispatch( OutboxActivityEvent::NAME, $outboxEvent ); } } } -?> + diff --git a/src/Activities/InboxActivityEvent.php b/src/Activities/InboxActivityEvent.php index ea0eeb5..998c8f3 100644 --- a/src/Activities/InboxActivityEvent.php +++ b/src/Activities/InboxActivityEvent.php @@ -7,4 +7,4 @@ class InboxActivityEvent extends ActivityEvent { const NAME = 'inbox.activity'; } -?> + diff --git a/src/Activities/NonActivityHandler.php b/src/Activities/NonActivityHandler.php index fe9ecb3..fc389b7 100644 --- a/src/Activities/NonActivityHandler.php +++ b/src/Activities/NonActivityHandler.php @@ -18,15 +18,18 @@ class NonActivityHandler implements EventSubscriberInterface */ private $contextProvider; - const ACTIVITY_TYPES = array( - 'Accept', 'Add', 'Announce', 'Arrive', - 'Block', 'Create', 'Delete', 'Dislike', - 'Flag', 'Follow', 'Ignore', 'Invite', - 'Join', 'Leave', 'Like', 'Listen', - 'Move', 'Offer', 'Question', 'Reject', - 'Read', 'Remove', 'TentativeReject', 'TentativeAccept', - 'Travel', 'Undo', 'Update', 'View', - ); + public static function activityTypes() + { + return array( + 'Accept', 'Add', 'Announce', 'Arrive', + 'Block', 'Create', 'Delete', 'Dislike', + 'Flag', 'Follow', 'Ignore', 'Invite', + 'Join', 'Leave', 'Like', 'Listen', + 'Move', 'Offer', 'Question', 'Reject', + 'Read', 'Remove', 'TentativeReject', 'TentativeAccept', + 'Travel', 'Undo', 'Update', 'View', + ); + } public static function getSubscribedEvents() { @@ -43,7 +46,7 @@ class NonActivityHandler implements EventSubscriberInterface public function handle( OutboxActivityEvent $event ) { $object = $event->getActivity(); - if ( in_array( $object['type'], self::ACTIVITY_TYPES ) ) { + if ( in_array( $object['type'], self::activityTypes() ) ) { return; } $request = $event->getRequest(); @@ -78,4 +81,4 @@ class NonActivityHandler implements EventSubscriberInterface return $create; } } -?> + diff --git a/src/Activities/OutboxActivityEvent.php b/src/Activities/OutboxActivityEvent.php index 16be405..b975d3a 100644 --- a/src/Activities/OutboxActivityEvent.php +++ b/src/Activities/OutboxActivityEvent.php @@ -7,4 +7,4 @@ class OutboxActivityEvent extends ActivityEvent { const NAME = 'outbox.activity'; } -?> + diff --git a/src/Activities/ValidationHandler.php b/src/Activities/ValidationHandler.php index f5d57fa..ba4c5a8 100644 --- a/src/Activities/ValidationHandler.php +++ b/src/Activities/ValidationHandler.php @@ -8,14 +8,20 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; class ValidationHandler implements EventSubscriberInterface { - const OBJECT_REQUIRED_TYPES = array( - 'Create', 'Update', 'Delete', 'Follow', - 'Add', 'Remove', 'Like', 'Block', 'Undo', - ); + public static function getObjectRequiredTypes() + { + return array( + 'Create', 'Update', 'Delete', 'Follow', + 'Add', 'Remove', 'Like', 'Block', 'Undo', + ); + } - const TARGET_REQUIRED_TYPES = array( - 'Add', 'Remove', - ); + public static function getTargetRequiredTypes() + { + return array( + 'Add', 'Remove', + ); + } public static function getSubscribedEvents() { @@ -30,11 +36,11 @@ class ValidationHandler implements EventSubscriberInterface $activity = $event->getActivity(); $requiredFields = array( 'type', 'id', 'actor' ); if ( array_key_exists( 'type', $activity ) && - in_array( $activity['type'], self::OBJECT_REQUIRED_TYPES ) ) { + in_array( $activity['type'], self::getObjectRequiredTypes() ) ) { $requiredFields[] = 'object'; } if ( array_key_exists( 'type', $activity ) && - in_array( $activity['type'], self::TARGET_REQUIRED_TYPES ) ) { + in_array( $activity['type'], self::getTargetRequiredTypes() ) ) { $requiredFields[] = 'target'; } $this->requireFields( $activity, $requiredFields ); @@ -45,11 +51,11 @@ class ValidationHandler implements EventSubscriberInterface $activity = $event->getActivity(); $requiredFields = array( 'type', 'actor' ); if ( array_key_exists( 'type', $activity ) && - in_array( $activity['type'], self::OBJECT_REQUIRED_TYPES ) ) { + in_array( $activity['type'], self::getObjectRequiredTypes() ) ) { $requiredFields[] = 'object'; } if ( array_key_exists( 'type', $activity ) && - in_array( $activity['type'], self::TARGET_REQUIRED_TYPES ) ) { + in_array( $activity['type'], self::getTargetRequiredTypes() ) ) { $requiredFields[] = 'target'; } $this->requireFields( $activity, $requiredFields ); @@ -70,4 +76,4 @@ class ValidationHandler implements EventSubscriberInterface } } } -?> + diff --git a/src/ActivityPub.php b/src/ActivityPub.php index ee1dfbb..09c9b26 100644 --- a/src/ActivityPub.php +++ b/src/ActivityPub.php @@ -1,7 +1,9 @@ addSubscriber( $this->module->get( DeleteHandler::class ) ); } } -?> + diff --git a/src/Auth/AuthListener.php b/src/Auth/AuthListener.php index 2a1801a..f47d1d4 100644 --- a/src/Auth/AuthListener.php +++ b/src/Auth/AuthListener.php @@ -64,4 +64,4 @@ class AuthListener implements EventSubscriberInterface } } } -?> + diff --git a/src/Auth/AuthService.php b/src/Auth/AuthService.php index 717ffba..dff0023 100644 --- a/src/Auth/AuthService.php +++ b/src/Auth/AuthService.php @@ -63,4 +63,4 @@ class AuthService } } } -?> + diff --git a/src/Auth/SignatureListener.php b/src/Auth/SignatureListener.php index 3dd23e1..eef95dc 100644 --- a/src/Auth/SignatureListener.php +++ b/src/Auth/SignatureListener.php @@ -82,4 +82,4 @@ class SignatureListener implements EventSubscriberInterface } } } -?> + diff --git a/src/Collections/CollectionsService.php b/src/Collections/CollectionsService.php deleted file mode 100644 index 37f5f27..0000000 --- a/src/Collections/CollectionsService.php +++ /dev/null @@ -1,56 +0,0 @@ - diff --git a/src/Config/ActivityPubConfig.php b/src/Config/ActivityPubConfig.php index 25f7cd1..faed967 100644 --- a/src/Config/ActivityPubConfig.php +++ b/src/Config/ActivityPubConfig.php @@ -55,7 +55,7 @@ class ActivityPubConfig $this->idPathPrefix = $builder->getIdPathPrefix(); } - public function createBuilder() + public static function createBuilder() { return new ActivityPubConfigBuilder(); } @@ -109,4 +109,4 @@ class ActivityPubConfig return $this->idPathPrefix; } } -?> + diff --git a/src/Config/ActivityPubConfigBuilder.php b/src/Config/ActivityPubConfigBuilder.php index 57fb37f..253329f 100644 --- a/src/Config/ActivityPubConfigBuilder.php +++ b/src/Config/ActivityPubConfigBuilder.php @@ -4,6 +4,7 @@ namespace ActivityPub\Config; use ActivityPub\Config\ActivityPubConfig; use ActivityPub\Objects\ContextProvider; use ActivityPub\Objects\IdProvider; +use Exception; /** * The ActivityPubConfigBuilder is a builder class to create ActivityPub config data @@ -64,7 +65,7 @@ class ActivityPubConfigBuilder $this->authFunction = function() { return false; }; - $this->jsonLDContext = ContextProvider::DEFAULT_CONTEXT; + $this->jsonLdContext = ContextProvider::getDefaultContext(); $this->idPathPrefix = IdProvider::DEFAULT_ID_PATH_PREFIX; } @@ -72,6 +73,7 @@ class ActivityPubConfigBuilder * Validates and builds the config instance * * @return ActivityPubConfig + * @throws Exception If the configuration is invalid */ public function build() { @@ -79,6 +81,9 @@ class ActivityPubConfigBuilder return new ActivityPubConfig( $this ); } + /** + * @throws Exception + */ private function validate() { if ( ! $this->dbConnectionParams ) { @@ -119,7 +124,7 @@ class ActivityPubConfigBuilder * @param bool $isDevMode * @return ActivityPubConfigBuilder The builder instance */ - public function setIsDevMode( bool $isDevMode ) + public function setIsDevMode( $isDevMode ) { $this->isDevMode = $isDevMode; return $this; @@ -145,7 +150,7 @@ class ActivityPubConfigBuilder * @param string $dbPrefix * @return ActivityPubConfigBuilder The builder instance */ - public function setDbPrefix( string $dbPrefix ) + public function setDbPrefix( $dbPrefix ) { $this->dbPrefix = $dbPrefix; return $this; @@ -217,7 +222,7 @@ class ActivityPubConfigBuilder * @param string $idPathPrefix The id path prefix * @return ActivityPubConfigBuilder The builder instance */ - public function setIdPathPrefix( string $idPathPrefix ) + public function setIdPathPrefix( $idPathPrefix ) { $this->idPathPrefix = $idPathPrefix; return $this; @@ -231,4 +236,4 @@ class ActivityPubConfigBuilder return $this->idPathPrefix; } } -?> + diff --git a/src/Config/ActivityPubModule.php b/src/Config/ActivityPubModule.php index 93db217..1e1fef8 100644 --- a/src/Config/ActivityPubModule.php +++ b/src/Config/ActivityPubModule.php @@ -91,7 +91,8 @@ class ActivityPubModule ->addArgument( self::COLLECTION_PAGE_SIZE ) ->addArgument( new Reference( AuthService::class ) ) ->addArgument( new Reference( ContextProvider::class ) ) - ->addArgument( new Reference( Client::class ) ); + ->addArgument( new Reference( Client::class ) ) + ->addArgument( new Reference( SimpleDateTimeProvider::class )); $this->injector->register( RandomProvider::class, RandomProvider::class ); @@ -136,9 +137,9 @@ class ActivityPubModule * @param string $id The id of the service instance to get * @return object The service instance */ - public function get( string $id ) + public function get( $id ) { return $this->injector->get( $id ); } } -?> + diff --git a/src/Controllers/GetController.php b/src/Controllers/GetController.php index 626e5e9..66eb0dd 100644 --- a/src/Controllers/GetController.php +++ b/src/Controllers/GetController.php @@ -2,13 +2,13 @@ namespace ActivityPub\Controllers; use ActivityPub\Auth\AuthService; -use ActivityPub\Entities\ActivityPubObject; use ActivityPub\Objects\CollectionsService; use ActivityPub\Objects\ObjectsService; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; /** * The GetController is responsible for rendering ActivityPub objects as JSON @@ -75,4 +75,4 @@ class GetController return $response; } } -?> + diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index 81fa69f..68bf982 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -97,6 +97,7 @@ class PostController } else if ( is_string( $actor ) ) { return $this->objectsService->dereference( $actor ); } + return null; } private function authorized( Request $request, ActivityPubObject $activityActor ) @@ -111,7 +112,7 @@ class PostController return true; } - private function objectWithField( string $name, string $value ) + private function objectWithField( $name, $value ) { $results = $this->objectsService->query( array( $name => $value ) ); if ( count( $results ) === 0 ) { @@ -130,4 +131,4 @@ class PostController return $uri; } } -?> + diff --git a/src/Crypto/HttpSignatureService.php b/src/Crypto/HttpSignatureService.php index 1006677..7d8d1e3 100644 --- a/src/Crypto/HttpSignatureService.php +++ b/src/Crypto/HttpSignatureService.php @@ -15,12 +15,6 @@ use Symfony\Component\HttpFoundation\HeaderUtils; class HttpSignatureService { // TODO handle the Digest header better, both on generating and verifying - const DEFAULT_HEADERS = array( - '(request-target)', - 'host', - 'date', - ); - const REPLAY_THRESHOLD = 300; /** @@ -47,7 +41,16 @@ class HttpSignatureService $this->dateTimeProvider = $dateTimeProvider; $this->psr7Factory = new DiactorosFactory(); } - + + public static function getDefaultHeaders() + { + return array( + '(request-target)', + 'host', + 'date', + ); + } + /** * Generates a signature given the request and private key * @@ -58,9 +61,12 @@ class HttpSignatureService * (default ['(request-target)', 'host', 'date']) * @return string The Signature header value */ - public function sign( RequestInterface $request, string $privateKey, - string $keyId, $headers = self::DEFAULT_HEADERS ) + public function sign( RequestInterface $request, $privateKey, + $keyId, $headers = null ) { + if ( ! $headers ) { + $headers = self::getDefaultHeaders(); + } $headers = array_map( 'strtolower', $headers ); $signingString = $this->getSigningString( $request, $headers ); $keypair = RsaKeypair::fromPrivateKey( $privateKey ); @@ -79,7 +85,7 @@ class HttpSignatureService * @param string $publicKey The public key to use to verify the request * @return bool True if the signature is valid, false if it is missing or invalid */ - public function verify( Request $request, string $publicKey ) + public function verify( Request $request, $publicKey ) { $params = array(); $headers = $request->headers; @@ -155,7 +161,7 @@ class HttpSignatureService * e.g. 'keyId="theKey",algorithm="rsa-sha256"' * @return array The params as an associative array */ - private function parseSignatureParams( string $paramsStr ) + private function parseSignatureParams( $paramsStr ) { $params = array(); $split = HeaderUtils::split( $paramsStr, ',=' ); @@ -170,4 +176,4 @@ class HttpSignatureService return $params; } } -?> + diff --git a/src/Crypto/RsaKeypair.php b/src/Crypto/RsaKeypair.php index 0152c1d..dfcaf46 100644 --- a/src/Crypto/RsaKeypair.php +++ b/src/Crypto/RsaKeypair.php @@ -22,7 +22,7 @@ class RsaKeypair */ private $privateKey; - public function __construct( string $publicKey, string $privateKey ) + public function __construct( $publicKey, $privateKey ) { $this->publicKey = $publicKey; $this->privateKey = $privateKey; @@ -112,7 +112,7 @@ class RsaKeypair * @param string $publicKey The public key * @return RsaKeypair */ - public function fromPublicKey( string $publicKey ) + public static function fromPublicKey( $publicKey ) { return new RsaKeypair( $publicKey, '' ); } @@ -126,9 +126,9 @@ class RsaKeypair * @param string $privateKey The private key * @return RsaKeypair */ - public function fromPrivateKey( string $privateKey) + public static function fromPrivateKey( $privateKey) { return new RsaKeypair( '', $privateKey ); } } -?> + diff --git a/src/Database/PrefixNamingStrategy.php b/src/Database/PrefixNamingStrategy.php index 51c3e1e..c6e3301 100644 --- a/src/Database/PrefixNamingStrategy.php +++ b/src/Database/PrefixNamingStrategy.php @@ -49,4 +49,4 @@ class PrefixNamingStrategy implements NamingStrategy return $propertyName.'_'.$embeddedColumnName; } } -?> + diff --git a/src/Entities/ActivityPubObject.php b/src/Entities/ActivityPubObject.php index c46d44c..176a1b8 100644 --- a/src/Entities/ActivityPubObject.php +++ b/src/Entities/ActivityPubObject.php @@ -73,7 +73,7 @@ class ActivityPubObject implements ArrayAccess * * @return array|string Either the object or its id if $depth is < 0 */ - public function asArray( int $depth = 1 ) { + public function asArray( $depth = 1 ) { if ( $depth < 0 && $this->hasField( 'id' ) ) { return $this->getFieldValue( 'id' ); } @@ -139,7 +139,7 @@ class ActivityPubObject implements ArrayAccess * * @return boolean */ - public function hasField( string $name ) + public function hasField( $name ) { foreach( $this->getFields() as $field ) { if ( $field->getName() === $name ) { @@ -155,13 +155,14 @@ class ActivityPubObject implements ArrayAccess * @param string $name The name of the field to get * @return Field|null */ - public function getField( string $name ) + public function getField( $name ) { foreach( $this->getFields() as $field ) { if ( $field->getName() === $name ) { return $field; } } + return null; } /** @@ -173,7 +174,7 @@ class ActivityPubObject implements ArrayAccess * @return string|ActivityPubObject|null The field's value, or null if * the field is not found */ - public function getFieldValue( string $name ) + public function getFieldValue( $name ) { foreach( $this->getFields() as $field ) { if ( $field->getName() === $name ) { @@ -206,7 +207,7 @@ class ActivityPubObject implements ArrayAccess * * @return boolean */ - public function hasReferencingField( string $name ) + public function hasReferencingField( $name ) { foreach( $this->getReferencingFields() as $field ) { if ( $field->getName() === $name ) { @@ -222,13 +223,14 @@ class ActivityPubObject implements ArrayAccess * @param string $name The name of the referencing to get * @return Field|null */ - public function getReferencingField( string $name ) + public function getReferencingField( $name ) { foreach( $this->getReferencingFields() as $field ) { if ( $field->getName() === $name ) { return $field; } } + return null; } /** @@ -262,7 +264,7 @@ class ActivityPubObject implements ArrayAccess /** * Removes a field from the object * @param Field $field The field to remove - * + * @param DateTime|null $time */ public function removeField( Field $field, DateTime $time = null ) { @@ -299,7 +301,7 @@ class ActivityPubObject implements ArrayAccess * * @param string $key The new private key value */ - public function setPrivateKey( string $key ) + public function setPrivateKey( $key ) { if ( $this->hasPrivateKey() ) { $this->privateKey->setKey( $key ); @@ -353,4 +355,4 @@ class ActivityPubObject implements ArrayAccess return true; } } -?> + diff --git a/src/Entities/Field.php b/src/Entities/Field.php index e39bc27..6570c5b 100644 --- a/src/Entities/Field.php +++ b/src/Entities/Field.php @@ -84,7 +84,7 @@ class Field * @param string $value The value of the field * @return Field The new field */ - public static function withValue( ActivityPubObject $object, string $name, string $value, DateTime $time = null ) + public static function withValue( ActivityPubObject $object, $name, $value, DateTime $time = null ) { if ( ! $time ) { $time = new DateTime( "now" ); @@ -105,7 +105,7 @@ class Field * @return Field The new field */ public static function withObject( ActivityPubObject $object, - string $name, + $name, ActivityPubObject $targetObject, DateTime $time = null ) { @@ -143,12 +143,12 @@ class Field $this->lastUpdated = $time; } - protected function setName( string $name ) + protected function setName( $name ) { $this->name= $name; } - public function setValue( string $value, DateTime $time = null ) + public function setValue( $value, DateTime $time = null ) { if ( ! $time ) { $time = new DateTime( "now" ); @@ -284,4 +284,4 @@ class Field } } } -?> + diff --git a/src/Entities/PrivateKey.php b/src/Entities/PrivateKey.php index 35e88d4..917c3db 100644 --- a/src/Entities/PrivateKey.php +++ b/src/Entities/PrivateKey.php @@ -41,7 +41,7 @@ class PrivateKey * @param string $key The private key as a string * @param ActivityPubObject $object The object associated with this key */ - public function __construct( string $key, ActivityPubObject $object ) + public function __construct( $key, ActivityPubObject $object ) { $this->key = $key; $this->object = $object; @@ -53,9 +53,9 @@ class PrivateKey * Don't call this directly - instead, use ActivityPubObject->setPrivateKey() * @param string $key The private key as a string */ - public function setKey( string $key ) + public function setKey( $key ) { $this->key = $key; } } -?> + diff --git a/src/Http/Router.php b/src/Http/Router.php index afa2178..36c1959 100644 --- a/src/Http/Router.php +++ b/src/Http/Router.php @@ -57,4 +57,4 @@ class Router implements EventSubscriberInterface } } } -?> + diff --git a/src/Objects/CollectionsService.php b/src/Objects/CollectionsService.php index 080a1a5..2974918 100644 --- a/src/Objects/CollectionsService.php +++ b/src/Objects/CollectionsService.php @@ -3,9 +3,11 @@ namespace ActivityPub\Objects; use ActivityPub\Auth\AuthService; use ActivityPub\Entities\ActivityPubObject; -use ActivityPub\Objects\ContextProvider; +use ActivityPub\Entities\Field; +use ActivityPub\Utils\DateTimeProvider; use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request as Psr7Request; +use InvalidArgumentException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -32,15 +34,22 @@ class CollectionsService */ private $httpClient; - public function __construct( int $pageSize, + /** + * @var DateTimeProvider + */ + private $dateTimeProvider; + + public function __construct( $pageSize, AuthService $authService, ContextProvider $contextProvider, - Client $httpClient ) + Client $httpClient, + DateTimeProvider $dateTimeProvider ) { $this->pageSize = $pageSize; $this->authService = $authService; $this->contextProvider = $contextProvider; $this->httpClient = $httpClient; + $this->dateTimeProvider = $dateTimeProvider; } /** @@ -53,7 +62,7 @@ class CollectionsService { if ( $request->query->has( 'offset' ) ) { return $this->getCollectionPage( - $collection, $request, $request->query->get( 'offset' ), $this->pageSize + $collection, $request, intval( $request->query->get( 'offset' ) ), $this->pageSize ); } $colArr = array(); @@ -108,6 +117,24 @@ class CollectionsService return $collection; } + /** + * Adds $item to $collection + * + * @param ActivityPubObject $collection + * @param array $item + */ + public function addItem( ActivityPubObject $collection, array $item ) + { + if ( ! $collection->hasField( 'items' ) ) { + $items = new ActivityPubObject( + $this->dateTimeProvider->getTime( 'collections-service.create' ) + ); + $itemsField = Field::withObject( $collection, 'items', $items ); + } else { + $items = $collection['items']; + } + } + private function getPageItems( array $collectionPage ) { $items = array(); @@ -128,22 +155,22 @@ class CollectionsService return $items; } - private function fetchPage( string $pageId ) + private function fetchPage( $pageId ) { $request = new Psr7Request( 'GET', $pageId, array( 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ) ); $response = $this->httpClient->send( $request ); if ( $response->getStatusCode() !== 200 || empty( $response->getBody() ) ) { - return; + return null; } return json_decode( $response->getBody(), true ); } private function getCollectionPage( ActivityPubObject $collection, Request $request, - int $offset, - int $pageSize ) + $offset, + $pageSize ) { $itemsKey = 'items'; $pageType = 'CollectionPage'; @@ -162,7 +189,7 @@ class CollectionsService $idx = $offset; $count = 0; while ( $count < $pageSize ) { - $item = $collectionItems->getFieldValue( $idx ); + $item = $collectionItems->getFieldValue( strval( $idx ) ); if ( ! $item ) { break; } @@ -196,16 +223,16 @@ class CollectionsService return $page; } - private function hasNextItem( $request, $collectionItems, $idx ) + private function hasNextItem( Request $request, ActivityPubObject $collectionItems, $idx ) { - $next = $collectionItems->getFieldValue( $idx ); + $next = $collectionItems->getFieldValue( strval( $idx ) ); while ( $next ) { if ( is_string( $next ) || $this->authService->isAuthorized( $request, $next ) ) { return $idx; } $idx++; - $next = $collectionsItems->getFieldValue( $idx ); + $next = $collectionItems->getFieldValue( strval( $idx ) ); } return false; } @@ -223,4 +250,4 @@ class CollectionsService } } } -?> + diff --git a/src/Objects/ContextProvider.php b/src/Objects/ContextProvider.php index f8cc440..b70b7ca 100644 --- a/src/Objects/ContextProvider.php +++ b/src/Objects/ContextProvider.php @@ -3,17 +3,12 @@ namespace ActivityPub\Objects; class ContextProvider { - const DEFAULT_CONTEXT = array( - 'https://www.w3.org/ns/activitystreams', - 'https://w3id.org/security/v1', - ); - private $ctx; public function __construct( $ctx = null ) { if ( ! $ctx ) { - $ctx = self::DEFAULT_CONTEXT; + $ctx = self::getDefaultContext(); } $this->ctx = $ctx; } @@ -22,5 +17,13 @@ class ContextProvider { return $this->ctx; } + + public static function getDefaultContext() + { + return array( + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1', + ); + } } -?> + diff --git a/src/Objects/IdProvider.php b/src/Objects/IdProvider.php index 489a09f..8c30fd7 100644 --- a/src/Objects/IdProvider.php +++ b/src/Objects/IdProvider.php @@ -33,7 +33,7 @@ class IdProvider public function __construct( ObjectsService $objectsService, RandomProvider $randomProvider, - string $pathPrefix ) + $pathPrefix ) { $this->objectsService = $objectsService; $this->randomProvider = $randomProvider; @@ -49,7 +49,7 @@ class IdProvider * and after the path prefix. Default: "object" * @return string The new id */ - public function getId( Request $request, string $path = "objects" ) + public function getId( Request $request, $path = "objects" ) { $baseUri = $request->getSchemeAndHttpHost(); if ( ! empty( $path ) ) { @@ -66,4 +66,4 @@ class IdProvider return $id; } } -?> + diff --git a/src/Objects/ObjectsService.php b/src/Objects/ObjectsService.php index bc4defe..46d3ae3 100644 --- a/src/Objects/ObjectsService.php +++ b/src/Objects/ObjectsService.php @@ -7,6 +7,7 @@ use ActivityPub\Entities\Field; use ActivityPub\Utils\Util; use ActivityPub\Utils\DateTimeProvider; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\QueryBuilder; use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; @@ -47,7 +48,7 @@ class ObjectsService * * @return ActivityPubObject The created object */ - public function persist( array $fields, string $context = 'objects-service.create' ) + public function persist( array $fields, $context = 'objects-service.create' ) { // TODO should I do JSON-LD compaction here? if ( array_key_exists( 'id', $fields ) ) { @@ -62,6 +63,7 @@ class ObjectsService foreach ( $fields as $name => $value ) { $this->persistField( $object, $name, $value, $context ); } + /** @noinspection PhpUnhandledExceptionInspection */ $this->entityManager->flush(); return $object; } @@ -129,11 +131,11 @@ class ObjectsService ) ); $response = $this->httpClient->send( $request ); if ( $response->getStatusCode() !== 200 || empty( $response->getBody() ) ) { - return; + return null; } $object = json_decode( $response->getBody(), true ); if ( ! $object ) { - return; + return null; } return $this->persist( $object ); } @@ -225,6 +227,7 @@ class ObjectsService if ( ! empty( $results ) ) { return $results[0]; } + return null; } /** @@ -246,7 +249,7 @@ class ObjectsService { $object = $this->getObject( $id ); if ( ! $object ) { - return; + return null; } foreach( $updatedFields as $fieldName => $newValue ) { if ( $newValue === null && $object->hasField( $fieldName ) ) { @@ -306,7 +309,7 @@ class ObjectsService { $existing = $this->getObject( $id ); if ( ! $existing ) { - return; + return null; } foreach ( $existing->getFields() as $field ) { if ( ! array_key_exists( $field->getName(), $replacement ) ) { @@ -316,4 +319,4 @@ class ObjectsService return $this->update( $id, $replacement ); } } -?> + diff --git a/src/Utils/DateTimeProvider.php b/src/Utils/DateTimeProvider.php index 8b058d0..e73c2e5 100644 --- a/src/Utils/DateTimeProvider.php +++ b/src/Utils/DateTimeProvider.php @@ -1,6 +1,8 @@ + diff --git a/src/Utils/RandomProvider.php b/src/Utils/RandomProvider.php index 664e796..74db20d 100644 --- a/src/Utils/RandomProvider.php +++ b/src/Utils/RandomProvider.php @@ -13,7 +13,7 @@ class RandomProvider * @param int $length The length of the random string to generate * @return string */ - public function randomString( int $length ) + public function randomString( $length ) { $str = ''; for ( $i = 0; $i < $length; $i++ ) { @@ -22,4 +22,4 @@ class RandomProvider return $str; } } -?> + diff --git a/src/Utils/SimpleDateTimeProvider.php b/src/Utils/SimpleDateTimeProvider.php index 2dd788b..f0d746d 100644 --- a/src/Utils/SimpleDateTimeProvider.php +++ b/src/Utils/SimpleDateTimeProvider.php @@ -18,4 +18,4 @@ class SimpleDateTimeProvider implements DateTimeProvider return new DateTime( "now" ); } } -?> + diff --git a/src/Utils/Util.php b/src/Utils/Util.php index 7aa02a9..d8e987c 100644 --- a/src/Utils/Util.php +++ b/src/Utils/Util.php @@ -32,4 +32,4 @@ class Util return true; } } -?> + diff --git a/test/Activities/CreateHandlerTest.php b/test/Activities/CreateHandlerTest.php index 8e35bf3..f1e333d 100644 --- a/test/Activities/CreateHandlerTest.php +++ b/test/Activities/CreateHandlerTest.php @@ -10,26 +10,28 @@ use ActivityPub\Objects\ContextProvider; use ActivityPub\Objects\IdProvider; use ActivityPub\Objects\ObjectsService; use ActivityPub\Test\TestUtils\TestActivityPubObject; +use ActivityPub\Utils\SimpleDateTimeProvider; use GuzzleHttp\Client; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; -class CreateHandlerTest extends TestCase +class CreateHandlerTest extends APTestCase { private $eventDispatcher; public function setUp() { $this->eventDispatcher = new EventDispatcher(); - $objectsService = $this->createMock( ObjectsService::class ); - $idProvider = $this->createMock( IdProvider::class ); + $objectsService = $this->getMock( ObjectsService::class ); + $idProvider = $this->getMock( IdProvider::class ); // TODO provision mocks $collectionsService = new CollectionsService( 4, - $this->createMock( AuthService::class ), + $this->getMock( AuthService::class ), new ContextProvider(), - $this->createMock( Client::class ) + $this->getMock( Client::class ), + new SimpleDateTimeProvider() ); $createHandler = new CreateHandler( $objectsService, $idProvider, $collectionsService @@ -259,4 +261,4 @@ class CreateHandlerTest extends TestCase } } } -?> + diff --git a/test/Activities/DeleteHandlerTest.php b/test/Activities/DeleteHandlerTest.php index 2ae164c..5fb75d2 100644 --- a/test/Activities/DeleteHandlerTest.php +++ b/test/Activities/DeleteHandlerTest.php @@ -8,25 +8,28 @@ use ActivityPub\Objects\ObjectsService; use ActivityPub\Test\TestUtils\TestActivityPubObject; use ActivityPub\Test\TestUtils\TestDateTimeProvider; use DateTime; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; -class DeleteHandlerTest extends TestCase +class DeleteHandlerTest extends APTestCase { - const OBJECTS = array( - 'https://elsewhere.com/objects/1' => array( - 'id' => 'https://elsewhere.com/objects/1', - 'type' => 'Note', - 'attributedTo' => 'https://elsewhere.com/actors/1', - ), - 'https://example.com/objects/1' => array( - 'id' => 'https://example.com/objects/1', - 'type' => 'Note', - 'attributedTo' => 'https://example.com/actors/1', - ) - ); + private static function getObjects() + { + return array( + 'https://elsewhere.com/objects/1' => array( + 'id' => 'https://elsewhere.com/objects/1', + 'type' => 'Note', + 'attributedTo' => 'https://elsewhere.com/actors/1', + ), + 'https://example.com/objects/1' => array( + 'id' => 'https://example.com/objects/1', + 'type' => 'Note', + 'attributedTo' => 'https://example.com/actors/1', + ) + ); + } public function testDeleteHandler() { @@ -141,13 +144,15 @@ class DeleteHandlerTest extends TestCase ->getMock(); $objectsService->method( 'dereference' )->will( $this->returnCallback( function( $id ) { - if ( array_key_exists( $id, self::OBJECTS ) ) { - return TestActivityPubObject::fromArray( self::OBJECTS[$id] ); + if ( array_key_exists( $id, self::getObjects()) ) { + $objects = self::getObjects(); + return TestActivityPubObject::fromArray( $objects[$id] ); } + return null; } ) ); if ( array_key_exists( 'expectedException', $testCase ) ) { - $this->expectException( $testCase['expectedException'] ); + $this->setExpectedException( $testCase['expectedException'] ); } else { $objectsService->expects( $this->once() ) ->method( 'replace' ) @@ -169,4 +174,4 @@ class DeleteHandlerTest extends TestCase return $request; } } -?> + diff --git a/test/Activities/FollowHandlerTest.php b/test/Activities/FollowHandlerTest.php index ecfdb81..0e8a63b 100644 --- a/test/Activities/FollowHandlerTest.php +++ b/test/Activities/FollowHandlerTest.php @@ -6,11 +6,11 @@ use ActivityPub\Activities\InboxActivityEvent; use ActivityPub\Activities\OutboxActivityEvent; use ActivityPub\Objects\ContextProvider; use ActivityPub\Test\TestUtils\TestActivityPubObject; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; -class FollowHandlerTest extends TestCase +class FollowHandlerTest extends APTestCase { public function testFollowHandler() { @@ -29,12 +29,12 @@ class FollowHandlerTest extends TestCase 'object' => 'https://example.com/actor/1', ); $eventDispatcher->addListener( OutboxActivityEvent::NAME, function( $event, $name ) - use ( &$outboxDispatched, $actor ) + use ( &$outboxDispatched, $actor, $follow ) { $this->assertEquals( OutboxActivityEvent::NAME, $name ); $outboxDispatched = true; $accept = array( - '@context' => ContextProvider::DEFAULT_CONTEXT, + '@context' => ContextProvider::getDefaultContext(), 'type' => 'Accept', 'actor' => 'https://example.com/actor/1', 'object' => 'https://elsewhere.com/activities/1', @@ -49,7 +49,10 @@ class FollowHandlerTest extends TestCase ), json_encode( $accept ) ); - $expectedRequest->attributes->set( 'actor', $actor ); + $expectedRequest->attributes->add( array( + 'actor' => $actor, + 'follow' => $follow, + ) ); $this->assertEquals( new OutboxActivityEvent( $accept, $actor, $expectedRequest ), $event ); @@ -91,4 +94,4 @@ class FollowHandlerTest extends TestCase $this->assertFalse( $outboxDispatched ); } } -?> + diff --git a/test/Activities/NonActivityHandlerTest.php b/test/Activities/NonActivityHandlerTest.php index fb0d20b..7eed74f 100644 --- a/test/Activities/NonActivityHandlerTest.php +++ b/test/Activities/NonActivityHandlerTest.php @@ -5,10 +5,10 @@ use ActivityPub\Activities\OutboxActivityEvent; use ActivityPub\Activities\NonActivityHandler; use ActivityPub\Objects\ContextProvider; use ActivityPub\Test\TestUtils\TestActivityPubObject; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\HttpFoundation\Request; -class NonActivityHandlerTest extends TestCase +class NonActivityHandlerTest extends APTestCase { public function testNonActivityHandler() { @@ -24,7 +24,7 @@ class NonActivityHandlerTest extends TestCase 'id' => 'https://example.com/actor/1', ) ), 'expectedActivity' => array( - '@context' => ContextProvider::DEFAULT_CONTEXT, + '@context' => ContextProvider::getDefaultContext(), 'type' => 'Create', 'actor' => 'https://example.com/actor/1', 'object' => array( @@ -62,7 +62,7 @@ class NonActivityHandlerTest extends TestCase 'id' => 'https://example.com/actor/1', ) ), 'expectedActivity' => array( - '@context' => ContextProvider::DEFAULT_CONTEXT, + '@context' => ContextProvider::getDefaultContext(), 'type' => 'Create', 'actor' => 'https://example.com/actor/1', 'object' => array( @@ -103,4 +103,4 @@ class NonActivityHandlerTest extends TestCase } } } -?> + diff --git a/test/Activities/UpdateHandlerTest.php b/test/Activities/UpdateHandlerTest.php index 2df878e..76d4aa5 100644 --- a/test/Activities/UpdateHandlerTest.php +++ b/test/Activities/UpdateHandlerTest.php @@ -6,45 +6,55 @@ use ActivityPub\Activities\OutboxActivityEvent; use ActivityPub\Activities\UpdateHandler; use ActivityPub\Objects\ObjectsService; use ActivityPub\Test\TestUtils\TestActivityPubObject; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; -class UpdateHandlerTest extends TestCase +class UpdateHandlerTest extends APTestCase { - const OBJECTS = array( - 'https://elsewhere.com/objects/1' => array( - 'id' => 'https://elsewhere.com/objects/1', - 'attributedTo' => 'https://elsewhere.com/actors/1', - ), - 'https://example.com/objects/1' => array( - 'id' => 'https://example.com/objects/1', - 'attributedTo' => 'https://example.com/actors/1', - 'type' => 'Note', - 'content' => 'This is a note', - ), - ); + private static function getObjects() + { + return array( + 'https://elsewhere.com/objects/1' => array( + 'id' => 'https://elsewhere.com/objects/1', + 'attributedTo' => 'https://elsewhere.com/actors/1', + ), + 'https://example.com/objects/1' => array( + 'id' => 'https://example.com/objects/1', + 'attributedTo' => 'https://example.com/actors/1', + 'type' => 'Note', + 'content' => 'This is a note', + ), + ); + } /** * @var EventDispatcher */ private $eventDispatcher; + /** + * @var array + */ + private $objects; + public function setUp() { - $objectsService = $this->createMock( ObjectsService::class ); + $this->objects = self::getObjects(); + $objectsService = $this->getMock( ObjectsService::class ); $objectsService->method( 'dereference' )->will( $this->returnCallback( function( $id ) { - if ( array_key_exists( $id, self::OBJECTS ) ) { - return TestActivityPubObject::fromArray( self::OBJECTS[$id] ); + if ( array_key_exists( $id, $this->objects ) ) { + return TestActivityPubObject::fromArray( $this->objects[$id] ); } + return null; } ) ); $objectsService->method( 'update' )->will( $this->returnCallback( function( $id, $updateFields ) { - if ( array_key_exists( $id, self::OBJECTS ) ) { - $existing = self::OBJECTS[$id]; + if ( array_key_exists( $id, $this->objects ) ) { + $existing = $this->objects[$id]; foreach ( $updateFields as $field => $newValue ) { if ( $newValue === null && array_key_exists( $field, $existing ) ) { unset( $existing[$field] ); @@ -54,6 +64,7 @@ class UpdateHandlerTest extends TestCase } return TestActivityPubObject::fromArray( $existing ); } + return null; } ) ); $updateHandler = new UpdateHandler( $objectsService ); @@ -204,7 +215,7 @@ class UpdateHandlerTest extends TestCase foreach ( $testCases as $testCase ) { $event = $testCase['event']; if ( array_key_exists( 'expectedException', $testCase ) ) { - $this->expectException( $testCase['expectedException'] ); + $this->setExpectedException( $testCase['expectedException'] ); } $this->eventDispatcher->dispatch( $testCase['eventName'], $event ); if ( array_key_exists( 'expectedEvent', $testCase ) ) { @@ -222,4 +233,4 @@ class UpdateHandlerTest extends TestCase return $request; } } -?> + diff --git a/test/Activities/ValidationHandlerTest.php b/test/Activities/ValidationHandlerTest.php index a494c80..6e2e740 100644 --- a/test/Activities/ValidationHandlerTest.php +++ b/test/Activities/ValidationHandlerTest.php @@ -5,12 +5,12 @@ use ActivityPub\Activities\InboxActivityEvent; use ActivityPub\Activities\OutboxActivityEvent; use ActivityPub\Activities\ValidationHandler; use ActivityPub\Test\TestUtils\TestActivityPubObject; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -class ValidationHandlerTest extends TestCase +class ValidationHandlerTest extends APTestCase { /** * @var EventDispatcher @@ -161,19 +161,16 @@ class ValidationHandlerTest extends TestCase foreach ( $testCases as $testCase ) { $event = $testCase['event']; if ( array_key_exists( 'expectedException', $testCase ) ) { - $this->expectException( - $testCase['expectedException'], - "Error on test $testCase[id]" - ); - } - if ( array_key_exists( 'expectedExceptionMessage', $testCase ) ) { - $this->expectExceptionMessage( - $testCase['expectedExceptionMessage'], - "Error on test $testCase[id]" + $expectedExceptionMessage = ''; + if ( array_key_exists( 'expectedExceptionMessage', $testCase )) { + $expectedExceptionMessage = $testCase['expectedExceptionMessage']; + } + $this->setExpectedException( + $testCase['expectedException'], $expectedExceptionMessage ); } $this->eventDispatcher->dispatch( $testCase['eventName'], $event ); } } } -?> + diff --git a/test/ActivityPubTest.php b/test/ActivityPubTest.php index 001fb15..c1575f4 100644 --- a/test/ActivityPubTest.php +++ b/test/ActivityPubTest.php @@ -35,4 +35,4 @@ class ActivityPubTest extends SQLiteTestCase return dirname( __FILE__ ) . '/db.sqlite'; } } -?> + diff --git a/test/Auth/AuthListenerTest.php b/test/Auth/AuthListenerTest.php index 3045d72..0d06e82 100644 --- a/test/Auth/AuthListenerTest.php +++ b/test/Auth/AuthListenerTest.php @@ -8,15 +8,15 @@ use ActivityPub\Test\TestUtils\TestActivityPubObject; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; -class AuthListenerTest extends TestCase +class AuthListenerTest extends APTestCase { private $objectsService; public function setUp() { - $this->objectsService = $this->createMock( ObjectsService::class ); + $this->objectsService = $this->getMock( ObjectsService::class ); $this->objectsService->method( 'dereference' )->will( $this->returnValueMap( array( array( 'https://example.com/actor/1', TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/1', @@ -29,7 +29,7 @@ class AuthListenerTest extends TestCase public function getEvent() { - $kernel = $this->createMock( HttpKernelInterface::class ); + $kernel = $this->getMock( HttpKernelInterface::class ); $request = Request::create( 'https://example.com/foo', Request::METHOD_GET ); return new GetResponseEvent( $kernel, $request, HttpKernelInterface::MASTER_REQUEST @@ -108,4 +108,4 @@ class AuthListenerTest extends TestCase } } } -?> + diff --git a/test/Auth/AuthServiceTest.php b/test/Auth/AuthServiceTest.php index 7c1ce10..4211ef4 100644 --- a/test/Auth/AuthServiceTest.php +++ b/test/Auth/AuthServiceTest.php @@ -3,10 +3,10 @@ namespace ActivityPub\Test\Auth; use ActivityPub\Auth\AuthService; use ActivityPub\Test\TestUtils\TestActivityPubObject; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\HttpFoundation\Request; -class AuthServiceTest extends TestCase +class AuthServiceTest extends APTestCase { private $authService; @@ -72,4 +72,4 @@ class AuthServiceTest extends TestCase } } } -?> + diff --git a/test/Auth/SignatureListenerTest.php b/test/Auth/SignatureListenerTest.php index b3e48f8..2c59291 100644 --- a/test/Auth/SignatureListenerTest.php +++ b/test/Auth/SignatureListenerTest.php @@ -12,12 +12,11 @@ use ActivityPub\Test\TestUtils\TestDateTimeProvider; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; -class SignatureListenerTest extends TestCase +class SignatureListenerTest extends APTestCase { const ACTOR_ID = 'https://example.com/actor/1'; - const ACTOR = array( 'id' => self::ACTOR_ID ); const KEY_ID = 'https://example.com/actor/1/key'; const PUBLIC_KEY = "-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFENGw33yGihy92pDjZQhl0C3 @@ -25,14 +24,26 @@ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFENGw33yGihy92pDjZQhl0C3 Z4UMR7EOcpfdUE9Hf3m/hs+FUR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJw oYi+1hqp1fIekaxsyQIDAQAB -----END PUBLIC KEY-----"; - const KEY = array( - 'id' => self::KEY_ID, - 'owner' => 'https://example.com/actor/1', - 'publicKeyPem' => self::PUBLIC_KEY, - ); - + + /** + * @var SignatureListener + */ private $signatureListener; + private static function getActor() + { + return array( 'id' => self::ACTOR_ID ); + } + + private static function getKey() + { + return array( + 'id' => self::KEY_ID, + 'owner' => 'https://example.com/actor/1', + 'publicKeyPem' => self::PUBLIC_KEY, + ); + } + public function setUp() { $dateTimeProvider = new TestDateTimeProvider( array( @@ -41,11 +52,11 @@ oYi+1hqp1fIekaxsyQIDAQAB ), ) ); $httpSignatureService = new HttpSignatureService( $dateTimeProvider ); - $objectsService = $this->createMock( ObjectsService::class ); + $objectsService = $this->getMock( ObjectsService::class ); $objectsService->method( 'dereference' ) ->will( $this->returnValueMap( array( - array( self::KEY_ID, TestActivityPubObject::fromArray( self::KEY ) ), - array( self::ACTOR_ID, TestActivityPubObject::fromArray( self::ACTOR ) ), + array( self::KEY_ID, TestActivityPubObject::fromArray( self::getKey()) ), + array( self::ACTOR_ID, TestActivityPubObject::fromArray( self::getActor()) ), ) ) ); $this->signatureListener = new SignatureListener( $httpSignatureService, $objectsService @@ -54,7 +65,7 @@ oYi+1hqp1fIekaxsyQIDAQAB private function getEvent() { - $kernel = $this->createMock( HttpKernelInterface::class ); + $kernel = $this->getMock( HttpKernelInterface::class ); $request = Request::create( 'https://example.com/foo?param=value&pet=dog', Request::METHOD_POST, @@ -145,4 +156,4 @@ oYi+1hqp1fIekaxsyQIDAQAB } } } -?> + diff --git a/test/Config/ActivityPubModuleTest.php b/test/Config/ActivityPubModuleTest.php index b5a10e0..695aa11 100644 --- a/test/Config/ActivityPubModuleTest.php +++ b/test/Config/ActivityPubModuleTest.php @@ -5,9 +5,9 @@ use ActivityPub\Config\ActivityPubConfig; use ActivityPub\Config\ActivityPubModule; use ActivityPub\Http\Router; use Doctrine\ORM\EntityManager; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; -class ActivityPubModuleTest extends TestCase +class ActivityPubModuleTest extends APTestCase { private $module; @@ -33,4 +33,4 @@ class ActivityPubModuleTest extends TestCase $this->assertInstanceOf( Router::class, $router ); } } -?> + diff --git a/test/Controllers/GetControllerTest.php b/test/Controllers/GetControllerTest.php index 0d975ff..04a30a3 100644 --- a/test/Controllers/GetControllerTest.php +++ b/test/Controllers/GetControllerTest.php @@ -9,69 +9,85 @@ use ActivityPub\Objects\ContextProvider; use ActivityPub\Objects\CollectionsService; use ActivityPub\Objects\ObjectsService; use ActivityPub\Test\TestUtils\TestActivityPubObject; +use ActivityPub\Utils\SimpleDateTimeProvider; use GuzzleHttp\Client; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; -class GetControllerTest extends TestCase +class GetControllerTest extends APTestCase { - const OBJECTS = array( - 'https://example.com/objects/1' => array( - 'id' => 'https://example.com/objects/1', - 'object' => array( - 'id' => 'https://example.com/objects/2', - 'type' => 'Note', + private static function getObjects() + { + return array( + 'https://example.com/objects/1' => array( + 'id' => 'https://example.com/objects/1', + 'object' => array( + 'id' => 'https://example.com/objects/2', + 'type' => 'Note', + ), + 'audience' => array( 'https://www.w3.org/ns/activitystreams#Public' ), + 'type' => 'Create', ), - 'audience' => array( 'https://www.w3.org/ns/activitystreams#Public' ), - 'type' => 'Create', - ), - 'https://example.com/objects/2' => array( - 'id' => 'https://example.com/objects/2', - 'object' => array( + 'https://example.com/objects/2' => array( + 'id' => 'https://example.com/objects/2', + 'object' => array( + 'id' => 'https://example.com/objects/3', + 'type' => 'Note', + ), + 'to' => array( 'https://example.com/actor/1' ), + 'type' => 'Create', + 'actor' => array( + 'id' => 'https://example.com/actor/2', + ), + ), + 'https://example.com/objects/3' => array( 'id' => 'https://example.com/objects/3', - 'type' => 'Note', + 'object' => array( + 'id' => 'https://example.com/objects/2', + 'type' => 'Note', + ), + 'type' => 'Like', + 'actor' => array( + 'id' => 'https://example.com/actor/2', + ), ), - 'to' => array( 'https://example.com/actor/1' ), - 'type' => 'Create', - 'actor' => array( - 'id' => 'https://example.com/actor/2', + 'https://example.com/objects/4' => array( + 'id' => 'https://example.com/objects/4', + 'type' => 'Tombstone', ), - ), - 'https://example.com/objects/3' => array( - 'id' => 'https://example.com/objects/3', - 'object' => array( - 'id' => 'https://example.com/objects/2', - 'type' => 'Note', - ), - 'type' => 'Like', - 'actor' => array( - 'id' => 'https://example.com/actor/2', - ), - ), - 'https://example.com/objects/4' => array( - 'id' => 'https://example.com/objects/4', - 'type' => 'Tombstone', - ), - ); + ); + } + /** + * @var GetController + */ private $getController; + /** + * @var array + */ + private $objects; + public function setUp() { - $objectsService = $this->createMock( ObjectsService::class ); + $this->objects = self::getObjects(); + $objectsService = $this->getMock( ObjectsService::class ); $objectsService->method( 'dereference' )->will( $this->returnCallback( function( $uri ) { - if ( array_key_exists( $uri, self::OBJECTS ) ) { - return TestActivityPubObject::fromArray( self::OBJECTS[$uri] ); + if ( array_key_exists( $uri, $this->objects) ) { + return TestActivityPubObject::fromArray( $this->objects[$uri] ); } + return null; }) ); $authService = new AuthService(); $contextProvider = new ContextProvider(); - $httpClient = $this->createMock( Client::class ); - $collectionsService = new CollectionsService( 4, $authService, $contextProvider, $httpClient ); + $httpClient = $this->getMock( Client::class ); + $collectionsService = new CollectionsService( + 4, $authService, $contextProvider, $httpClient, new SimpleDateTimeProvider() + ); $this->getController = new GetController( $objectsService, $collectionsService, $authService ); @@ -83,7 +99,7 @@ class GetControllerTest extends TestCase $response = $this->getController->handle( $request ); $this->assertNotNull( $response ); $this->assertEquals( - json_encode( self::OBJECTS['https://example.com/objects/1'] ), + json_encode( $this->objects['https://example.com/objects/1'] ), $response->getContent() ); $this->assertEquals( 'application/json', $response->headers->get( 'Content-Type' ) ); @@ -92,14 +108,14 @@ class GetControllerTest extends TestCase public function testItThrowsNotFound() { $request = Request::create( 'https://example.com/objects/notreal' ); - $this->expectException( NotFoundHttpException::class ); + $this->setExpectedException( NotFoundHttpException::class ); $this->getController->handle( $request ); } public function testItDeniesAccess() { $request = Request::create( 'https://example.com/objects/2' ); - $this->expectException( UnauthorizedHttpException::class ); + $this->setExpectedException( UnauthorizedHttpException::class ); $this->getController->handle( $request ); } @@ -110,7 +126,7 @@ class GetControllerTest extends TestCase $response = $this->getController->handle( $request ); $this->assertNotNull( $response ); $this->assertEquals( - json_encode( self::OBJECTS['https://example.com/objects/2'] ), + json_encode( $this->objects['https://example.com/objects/2'] ), $response->getContent() ); $this->assertEquals( 'application/json', $response->headers->get( 'Content-Type' ) ); @@ -123,7 +139,7 @@ class GetControllerTest extends TestCase $response = $this->getController->handle( $request ); $this->assertNotNull( $response ); $this->assertEquals( - json_encode( self::OBJECTS['https://example.com/objects/2'] ), + json_encode( $this->objects['https://example.com/objects/2'] ), $response->getContent() ); $this->assertEquals( 'application/json', $response->headers->get( 'Content-Type' ) ); @@ -135,7 +151,7 @@ class GetControllerTest extends TestCase $response = $this->getController->handle( $request ); $this->assertNotNull( $response ); $this->assertEquals( - json_encode( self::OBJECTS['https://example.com/objects/3'] ), + json_encode( $this->objects['https://example.com/objects/3'] ), $response->getContent() ); $this->assertEquals( 'application/json', $response->headers->get( 'Content-Type' ) ); @@ -147,7 +163,7 @@ class GetControllerTest extends TestCase $response = $this->getController->handle( $request ); $this->assertNotNull( $response ); $this->assertEquals( - json_encode( self::OBJECTS['https://example.com/objects/1'] ), + json_encode( $this->objects['https://example.com/objects/1'] ), $response->getContent() ); $this->assertEquals( 'application/json', $response->headers->get( 'Content-Type' ) ); @@ -159,11 +175,11 @@ class GetControllerTest extends TestCase $response = $this->getController->handle( $request ); $this->assertNotNull( $response ); $this->assertEquals( - json_encode( self::OBJECTS['https://example.com/objects/4'] ), + json_encode( $this->objects['https://example.com/objects/4'] ), $response->getContent() ); $this->assertEquals( 'application/json', $response->headers->get( 'Content-Type' ) ); $this->assertEquals( 410, $response->getStatusCode() ); } } -?> + diff --git a/test/Controllers/PostControllerTest.php b/test/Controllers/PostControllerTest.php index e90c124..7d2d6da 100644 --- a/test/Controllers/PostControllerTest.php +++ b/test/Controllers/PostControllerTest.php @@ -6,60 +6,78 @@ use ActivityPub\Activities\OutboxActivityEvent; use ActivityPub\Controllers\PostController; use ActivityPub\Objects\ObjectsService; use ActivityPub\Test\TestUtils\TestActivityPubObject; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; -class PostControllerTest extends TestCase +class PostControllerTest extends APTestCase { - const OBJECTS = array( - 'https://example.com/actor/1/inbox' => array( - 'id' => 'https://example.com/actor/1/inbox', - ), - 'https://example.com/actor/1/outbox' => array( - 'id' => 'https://example.com/actor/1/outbox', - ), - 'https://example.com/actor/1' => array( - 'id' => 'https://example.com/actor/1', - 'inbox' => array( + private static function getObjects() + { + return array( + 'https://example.com/actor/1/inbox' => array( 'id' => 'https://example.com/actor/1/inbox', ), - 'outbox' => array( + 'https://example.com/actor/1/outbox' => array( 'id' => 'https://example.com/actor/1/outbox', ), - ), - 'https://elsewhere.com/actor/1' => array( - 'id' => 'https://elsewhere.com/actor/1', - ), - ); - const REFS = array( - 'https://example.com/actor/1/inbox' => array( - 'field' => 'inbox', - 'referencingObject' => 'https://example.com/actor/1', - ), - 'https://example.com/actor/1/outbox' => array( - 'field' => 'outbox', - 'referencingObject' => 'https://example.com/actor/1', - ), - ); + 'https://example.com/actor/1' => array( + 'id' => 'https://example.com/actor/1', + 'inbox' => array( + 'id' => 'https://example.com/actor/1/inbox', + ), + 'outbox' => array( + 'id' => 'https://example.com/actor/1/outbox', + ), + ), + 'https://elsewhere.com/actor/1' => array( + 'id' => 'https://elsewhere.com/actor/1', + ), + ); + } + private static function getRefs() + { + return array( + 'https://example.com/actor/1/inbox' => array( + 'field' => 'inbox', + 'referencingObject' => 'https://example.com/actor/1', + ), + 'https://example.com/actor/1/outbox' => array( + 'field' => 'outbox', + 'referencingObject' => 'https://example.com/actor/1', + ), + ); + } + + /** + * @var array + */ + private $objects; + + /** + * @var array + */ + private $refs; public function testPostController() { - $objectsService = $this->createMock( ObjectsService::class ); + $this->objects = self::getObjects(); + $this->refs = self::getRefs(); + $objectsService = $this->getMock( ObjectsService::class ); $objectsService->method( 'query' )->will( $this->returnCallback( function( $query ) { if ( array_key_exists( 'id', $query ) && - array_key_exists( $query['id'], self::OBJECTS ) ) { + array_key_exists( $query['id'], $this->objects ) ) { $object = TestActivityPubObject::fromArray( - self::OBJECTS[$query['id']] + $this->objects[$query['id']] ); - if ( array_key_exists( $query['id'], self::REFS ) ) { - $ref = self::REFS[$query['id']]; + if ( array_key_exists( $query['id'], $this->refs ) ) { + $ref = $this->refs[$query['id']]; $referencingObject = TestActivityPubObject::fromArray( - self::OBJECTS[$ref['referencingObject']] + $this->objects[$ref['referencingObject']] ); $referencingField = $referencingObject->getField( $ref['field'] ); $object->addReferencingField( $referencingField ); @@ -72,8 +90,8 @@ class PostControllerTest extends TestCase ); $objectsService->method( 'dereference' )->will( $this->returnCallback( function( $id ) { - if ( array_key_exists( $id, self::OBJECTS ) ) { - return TestActivityPubObject::fromArray( self::OBJECTS[$id] ); + if ( array_key_exists( $id, $this->objects ) ) { + return TestActivityPubObject::fromArray( $this->objects[$id] ); } else { return null; } @@ -89,7 +107,7 @@ class PostControllerTest extends TestCase array( 'signed' => true, 'actor' => TestActivityPubObject::fromArray( - self::OBJECTS['https://elsewhere.com/actor/1'] + $this->objects['https://elsewhere.com/actor/1'] ), ) ), @@ -100,7 +118,7 @@ class PostControllerTest extends TestCase 'actor' => 'https://elsewhere.com/actor/1' ), TestActivityPubObject::fromArray( - self::OBJECTS['https://example.com/actor/1'] + $this->objects['https://example.com/actor/1'] ), $this->makeRequest( 'https://example.com/actor/1/inbox', @@ -109,7 +127,7 @@ class PostControllerTest extends TestCase array( 'signed' => true, 'actor' => TestActivityPubObject::fromArray( - self::OBJECTS['https://elsewhere.com/actor/1'] + $this->objects['https://elsewhere.com/actor/1'] ), ) ) @@ -123,7 +141,7 @@ class PostControllerTest extends TestCase '{"type": "Create"}', array( 'actor' => TestActivityPubObject::fromArray( - self::OBJECTS['https://example.com/actor/1'] + $this->objects['https://example.com/actor/1'] ), ) ), @@ -131,7 +149,7 @@ class PostControllerTest extends TestCase 'expectedEvent' => new OutboxActivityEvent( array( 'type' => 'Create' ), TestActivityPubObject::fromArray( - self::OBJECTS['https://example.com/actor/1'] + $this->objects['https://example.com/actor/1'] ), $this->makeRequest( 'https://example.com/actor/1/outbox', @@ -139,7 +157,7 @@ class PostControllerTest extends TestCase '{"type": "Create"}', array( 'actor' => TestActivityPubObject::fromArray( - self::OBJECTS['https://example.com/actor/1'] + $this->objects['https://example.com/actor/1'] ), ) ) @@ -153,7 +171,7 @@ class PostControllerTest extends TestCase '{"type": "Create", "actor": "https://elsewhere.com/actor/1"}', array( 'actor' => TestActivityPubObject::fromArray( - self::OBJECTS['https://elsewhere.com/actor/1'] + $this->objects['https://elsewhere.com/actor/1'] ), ) ), @@ -178,7 +196,7 @@ class PostControllerTest extends TestCase array( 'signed' => true, 'actor' => TestActivityPubObject::fromArray( - self::OBJECTS['https://elsewhere.com/actor/1'] + $this->objects['https://elsewhere.com/actor/1'] ), ) ), @@ -193,7 +211,7 @@ class PostControllerTest extends TestCase array( 'signed' => true, 'actor' => TestActivityPubObject::fromArray( - self::OBJECTS['https://elsewhere.com/actor/1'] + $this->objects['https://elsewhere.com/actor/1'] ), ) ), @@ -208,7 +226,7 @@ class PostControllerTest extends TestCase array( 'signed' => 'true', 'actor' => TestActivityPubObject::fromArray( - self::OBJECTS['https://elsewhere.com/actor/1'] + $this->objects['https://elsewhere.com/actor/1'] ), ) ), @@ -230,7 +248,7 @@ class PostControllerTest extends TestCase $postController = new PostController( $eventDispatcher, $objectsService ); $request = $testCase['request']; if ( array_key_exists( 'expectedException', $testCase ) ) { - $this->expectException( $testCase['expectedException'] ); + $this->setExpectedException( $testCase['expectedException'] ); } $postController->handle( $request ); } @@ -247,4 +265,4 @@ class PostControllerTest extends TestCase return $request; } } -?> + diff --git a/test/Crypto/HttpSignatureServiceTest.php b/test/Crypto/HttpSignatureServiceTest.php index d6c54cb..51e5176 100644 --- a/test/Crypto/HttpSignatureServiceTest.php +++ b/test/Crypto/HttpSignatureServiceTest.php @@ -5,10 +5,10 @@ use DateTime; use ActivityPub\Crypto\HttpSignatureService; use ActivityPub\Test\TestUtils\TestDateTimeProvider; use GuzzleHttp\Psr7\Request as PsrRequest; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\HttpFoundation\Request; -class HttpSignatureServiceTest extends TestCase +class HttpSignatureServiceTest extends APTestCase { const PUBLIC_KEY = "-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFENGw33yGihy92pDjZQhl0C3 @@ -230,4 +230,4 @@ G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI } } } -?> + diff --git a/test/Crypto/RsaKeypairTest.php b/test/Crypto/RsaKeypairTest.php index a4a72a6..83b5822 100644 --- a/test/Crypto/RsaKeypairTest.php +++ b/test/Crypto/RsaKeypairTest.php @@ -1,12 +1,11 @@ expectException( Error::class ); + $this->setExpectedException( \PHPUnit_Framework_Error::class ); $verified = $keypair->verify( $data, $signature ); } @@ -66,9 +65,8 @@ class RsaKeypairTest extends TestCase $fullKeypair = RsaKeypair::generate(); $publicKeyOnly = RsaKeypair::fromPublicKey( $fullKeypair->getPublicKey() ); $data = 'This is some data'; - $this->expectException( BadMethodCallException::class ); - $this->expectExceptionMessage( 'Unable to sign data without a private key' ); - $signature = $publicKeyOnly->sign( $data ); + $this->setExpectedException( BadMethodCallException::class, 'Unable to sign data without a private key' ); + $publicKeyOnly->sign( $data ); } public function testItSignsAndVerifiesEmptyData() @@ -90,4 +88,4 @@ class RsaKeypairTest extends TestCase $this->assertFalse( $verified ); } } -?> + diff --git a/test/Entities/EntityTest.php b/test/Entities/EntityTest.php index 6bb5a2e..441c629 100644 --- a/test/Entities/EntityTest.php +++ b/test/Entities/EntityTest.php @@ -110,4 +110,4 @@ class EntityTest extends SQLiteTestCase $this->assertTablesEqual( $expectedKeysTable, $keysQueryTable ); } } -?> + diff --git a/test/Http/RouterTest.php b/test/Http/RouterTest.php index 3d3b106..a82b861 100644 --- a/test/Http/RouterTest.php +++ b/test/Http/RouterTest.php @@ -4,14 +4,14 @@ namespace ActivityPub\Test\Http; use ActivityPub\Controllers\GetController; use ActivityPub\Controllers\PostController; use ActivityPub\Http\Router; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; +use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Kernel; -class RouterTest extends TestCase +class RouterTest extends APTestCase { /** * @var Router @@ -24,10 +24,10 @@ class RouterTest extends TestCase public function setUp() { - $this->getController = $this->createMock( GetController::class ); - $this->postController = $this->createMock( PostController::class ); + $this->getController = $this->getMock( GetController::class ); + $this->postController = $this->getMock( PostController::class ); $this->router = new Router( $this->getController, $this->postController ); - $this->kernel = $this->createMock( Kernel::class ); + $this->kernel = $this->getMock( HttpKernel::class ); } public function testRouter() @@ -55,7 +55,7 @@ class RouterTest extends TestCase $this->kernel, $request, HttpKernelInterface::MASTER_REQUEST ); if ( array_key_exists( 'expectedException', $testCase ) ) { - $this->expectException( $testCase['expectedException'] ); + $this->setExpectedException( $testCase['expectedException'] ); } $this->router->route( $event ); $this->assertEquals( @@ -66,4 +66,4 @@ class RouterTest extends TestCase } } } -?> + diff --git a/test/Objects/CollectionsServiceTest.php b/test/Objects/CollectionsServiceTest.php index 6de722e..1fa2ddb 100644 --- a/test/Objects/CollectionsServiceTest.php +++ b/test/Objects/CollectionsServiceTest.php @@ -1,6 +1,7 @@ createMock( Client::class ); + $httpClient = $this->getMock( Client::class ); $httpClient->method( 'send' )->willReturn( new Psr7Response( 200, array(), json_encode( array( 'type' => 'OrderedCollectionPage', @@ -31,7 +35,7 @@ class CollectionsServiceTest extends TestCase ) ) ) ); $this->collectionsService = new CollectionsService( - 4, $authService, $contextProvider, $httpClient + 4, $authService, $contextProvider, $httpClient, new SimpleDateTimeProvider() ); } @@ -375,7 +379,7 @@ class CollectionsServiceTest extends TestCase ); foreach ( $testCases as $testCase ) { if ( array_key_exists( 'expectedException', $testCase ) ) { - $this->expectException( $testCase['expectedException'] ); + $this->setExpectedException( $testCase['expectedException'] ); } $request = $testCase['request']; if ( array_key_exists( 'requestAttributes', $testCase ) ) { @@ -490,7 +494,7 @@ class CollectionsServiceTest extends TestCase foreach ( $testCases as $testCase ) { $collection = $testCase['collection']; if ( array_key_exists( 'expectedException', $testCase ) ) { - $this->expectException( $testCase['expectedException'] ); + $this->setExpectedException( $testCase['expectedException'] ); } $actual = $this->collectionsService->normalizeCollection( $collection ); $this->assertEquals( @@ -499,4 +503,4 @@ class CollectionsServiceTest extends TestCase } } } -?> + diff --git a/test/Objects/IdProviderTest.php b/test/Objects/IdProviderTest.php index 8bfedad..f756fa0 100644 --- a/test/Objects/IdProviderTest.php +++ b/test/Objects/IdProviderTest.php @@ -4,10 +4,10 @@ namespace ActivityPub\Test\Objects; use ActivityPub\Objects\IdProvider; use ActivityPub\Objects\ObjectsService; use ActivityPub\Utils\RandomProvider; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; use Symfony\Component\HttpFoundation\Request; -class IdProviderTest extends TestCase +class IdProviderTest extends APTestCase { const EXISTING_ID_STR = 'exists'; @@ -15,7 +15,7 @@ class IdProviderTest extends TestCase public function setUp() { - $this->objectsService = $this->createMock( ObjectsService::class ); + $this->objectsService = $this->getMock( ObjectsService::class ); $this->objectsService->method( 'query' ) ->will( $this->returnCallback( function( $query) { $existsId = sprintf( @@ -50,7 +50,7 @@ class IdProviderTest extends TestCase ), ); foreach ( $testCases as $testCase ) { - $randomProvider = $this->createMock( RandomProvider::class ); + $randomProvider = $this->getMock( RandomProvider::class ); call_user_func_array( array( $randomProvider->method( 'randomString' ), 'willReturnOnConsecutiveCalls' ), $testCase['providedRnd'] @@ -67,4 +67,4 @@ class IdProviderTest extends TestCase } } } -?> + diff --git a/test/Objects/ObjectsServiceTest.php b/test/Objects/ObjectsServiceTest.php index f086bb0..f238bb5 100644 --- a/test/Objects/ObjectsServiceTest.php +++ b/test/Objects/ObjectsServiceTest.php @@ -15,7 +15,6 @@ use ActivityPub\Test\TestUtils\TestDateTimeProvider; use Doctrine\ORM\Tools\Setup; use GuzzleHttp\Client; use GuzzleHttp\Psr7\Response; -use PHPUnit\DbUnit\TestCaseTrait; class ObjectsServiceTest extends SQLiteTestCase { @@ -46,7 +45,7 @@ class ObjectsServiceTest extends SQLiteTestCase 'objects-service.create' => new DateTime( "12:00" ), 'objects-service.update' => new DateTime( "12:01" ), ) ); - $this->httpClient = $this->createMock( Client::class ); + $this->httpClient = $this->getMock( Client::class ); $this->httpClient->method( 'send' ) ->willReturn( new Response( 404 ) ); $this->objectsService = new ObjectsService( @@ -1130,7 +1129,7 @@ class ObjectsServiceTest extends SQLiteTestCase ); $now = $this->getTime( 'objects-service.create' ); $object = $this->objectsService->persist( $fields ); - $this->expectException( BadMethodCallException::class ); + $this->setExpectedException( BadMethodCallException::class ); $object['content'] = 'This should break'; } @@ -1143,7 +1142,7 @@ class ObjectsServiceTest extends SQLiteTestCase ); $now = $this->getTime( 'objects-service.create' ); $object = $this->objectsService->persist( $fields ); - $this->expectException( BadMethodCallException::class ); + $this->setExpectedException( BadMethodCallException::class ); unset( $object['content'] ); } @@ -1280,7 +1279,7 @@ class ObjectsServiceTest extends SQLiteTestCase } } } -?> + diff --git a/test/TestConfig/APTestCase.php b/test/TestConfig/APTestCase.php new file mode 100644 index 0000000..e0df3f5 --- /dev/null +++ b/test/TestConfig/APTestCase.php @@ -0,0 +1,12 @@ +addRow($row); @@ -37,7 +33,7 @@ class ArrayDataSet extends AbstractDataSet protected function createIterator($reverse = false) { - return new DefaultTableIterator($this->tables, $reverse); + return new \PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse); } public function getTable($tableName) diff --git a/test/TestConfig/SQLiteTestCase.php b/test/TestConfig/SQLiteTestCase.php index 3859548..eb0651b 100644 --- a/test/TestConfig/SQLiteTestCase.php +++ b/test/TestConfig/SQLiteTestCase.php @@ -3,14 +3,11 @@ namespace ActivityPub\Test\TestConfig; use ActivityPub\ActivityPub; use ActivityPub\Config\ActivityPubConfig; -use PHPUnit\Framework\TestCase; -use PHPUnit\DbUnit\TestCaseTrait; -use PHPUnit\DbUnit\Operation\Composite; -use PHPUnit\DbUnit\Operation\Factory; +use ActivityPub\Test\TestConfig\APTestCase; -abstract class SQLiteTestCase extends TestCase +abstract class SQLiteTestCase extends APTestCase { - use TestCaseTrait; + use \PHPUnit_Extensions_Database_TestCase_Trait; private $pdo = null; private $conn = null; @@ -58,4 +55,4 @@ abstract class SQLiteTestCase extends TestCase return $this->conn; } } -?> + diff --git a/test/TestUtils/TestActivityPubObject.php b/test/TestUtils/TestActivityPubObject.php index f8f9a73..2bc3e6e 100644 --- a/test/TestUtils/TestActivityPubObject.php +++ b/test/TestUtils/TestActivityPubObject.php @@ -62,4 +62,4 @@ class TestActivityPubObject extends ActivityPubObject return $object; } } -?> + diff --git a/test/TestUtils/TestDateTimeProvider.php b/test/TestUtils/TestDateTimeProvider.php index 96138a2..b65b968 100644 --- a/test/TestUtils/TestDateTimeProvider.php +++ b/test/TestUtils/TestDateTimeProvider.php @@ -28,4 +28,4 @@ class TestDateTimeProvider implements DateTimeProvider } } } -?> + diff --git a/test/TestUtils/TestField.php b/test/TestUtils/TestField.php index 2ee1968..aa88a8f 100644 --- a/test/TestUtils/TestField.php +++ b/test/TestUtils/TestField.php @@ -1,6 +1,7 @@ fixedTime = $time; } - public function setTargetObject( $targetObject, $time = null ) + public function setTargetObject( ActivityPubObject $targetObject, $time = null ) { parent::setTargetObject( $targetObject, $time ); $this->lastUpdated = $this->fixedTime; @@ -43,4 +44,4 @@ class TestField extends Field } } -?> + diff --git a/test/Utils/UtilTest.php b/test/Utils/UtilTest.php index 4db33ae..c5f821a 100644 --- a/test/Utils/UtilTest.php +++ b/test/Utils/UtilTest.php @@ -2,9 +2,9 @@ namespace ActivityPub\Test\Utils; use ActivityPub\Utils\Util; -use PHPUnit\Framework\TestCase; +use ActivityPub\Test\TestConfig\APTestCase; -class UtilTest extends TestCase +class UtilTest extends APTestCase { public function testItFindsAssocArray() { @@ -82,4 +82,4 @@ class UtilTest extends TestCase $this->assertTrue( $keysExist ); } } -?> + diff --git a/test/bootstrap.php b/test/bootstrap.php index 380772c..24680c6 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -16,4 +16,4 @@ $config = ActivityPubConfig::createBuilder() ->build(); $activityPub = new ActivityPub( $config ); $activityPub->updateSchema(); -?> + diff --git a/test/config.xml b/test/config.xml index a070a56..830f359 100644 --- a/test/config.xml +++ b/test/config.xml @@ -1,2 +1,2 @@ - +