diff --git a/classes/InfoController.php b/classes/InfoController.php index d86af83..f0753e9 100644 --- a/classes/InfoController.php +++ b/classes/InfoController.php @@ -25,16 +25,24 @@ class InfoController { + /** + * @return self + */ + public static function create() + { + return new self; + } + public function defaultAction() { global $pth; - (new View('pfw')) + View::create('pfw') ->template('info') ->data([ 'logo' => "{$pth['folder']['plugins']}pfw/pfw.png", 'version' => Plugin::VERSION, - 'checks' => (new SystemCheckService) + 'checks' => SystemCheckService::create() ->minPhpVersion('5.4.0') ->minXhVersion('1.6.3') ->writable("{$pth['folder']['plugins']}pfw/css/") diff --git a/classes/Plugin.php b/classes/Plugin.php index 9a2ced9..3aa37c0 100644 --- a/classes/Plugin.php +++ b/classes/Plugin.php @@ -49,7 +49,7 @@ private function handleAdministration() switch ($admin) { case '': ob_start(); - (new InfoController)->defaultAction(); + InfoController::create()->defaultAction(); $o .= ob_get_clean(); break; default: diff --git a/classes/SystemCheckService.php b/classes/SystemCheckService.php index 75c9a4b..a5f1376 100644 --- a/classes/SystemCheckService.php +++ b/classes/SystemCheckService.php @@ -34,6 +34,14 @@ */ class SystemCheckService { + /** + * @return self + */ + public static function create() + { + return new self; + } + /** * @var array */ diff --git a/classes/TestCase.php b/classes/TestCase.php new file mode 100644 index 0000000..7dea7d4 --- /dev/null +++ b/classes/TestCase.php @@ -0,0 +1,70 @@ +. + */ + +namespace Pfw; + +use PHPUnit\Framework\TestCase as PHPUnitTestCase; +use PHPUnit_Extensions_MockFunction; +use PHPUnit_Extensions_MockStaticMethod; + +abstract class TestCase extends PHPUnitTestCase +{ + /** + * Mocks a function in the scope of an object. + * + * @param string $function + * @param object $scopeObject + * @return PHPUnit_Extensions_MockFunction + */ + protected function mockFunction($function, $scopeObject = null) + { + return new PHPUnit_Extensions_MockFunction($function, $scopeObject); + } + + /** + * Mocks a static method in the scope of an object. + * + * @param string $class + * @param string $method + * @param object $scopeObject + * @return PHPUnit_Extensions_MockStaticMethod + */ + protected function mockStaticMethod($class, $method, $scopeObject = null) + { + return new PHPUnit_Extensions_MockStaticMethod("$class::$method", $scopeObject); + } + + /** + * (Re)defines a constant. + * + * @param string $name + * @param mixed $value + * @return void + */ + protected function setConstant($name, $value) + { + if (defined($name)) { + runkit_constant_redefine($name, $value); + } else { + define($name, $value); + } + } +} diff --git a/classes/View/View.php b/classes/View/View.php index 25f00bc..b29c12f 100644 --- a/classes/View/View.php +++ b/classes/View/View.php @@ -33,6 +33,15 @@ */ class View { + /** + * @param string $pluginname + * @return self + */ + public function create($pluginname) + { + return new self($pluginname); + } + /** * @var string */ diff --git a/composer.json b/composer.json index 4185b58..11b4c43 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "phpmd/phpmd": "2.6.*", "bartlett/php-compatinfo": "5.0.*", "phpunit/phpunit": "5.7.*", + "tcz/phpunit-mockfunction": "1.0.*", "mikey179/vfsStream": "1.6.*" } } diff --git a/composer.lock b/composer.lock index bab9dff..37de793 100644 --- a/composer.lock +++ b/composer.lock @@ -4,26 +4,26 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "184f89bf79e573ec05e539b35073ca4b", + "content-hash": "79a99560419ccee9ac41f86ac323717f", "packages": [], "packages-dev": [ { "name": "bartlett/php-compatinfo", - "version": "5.0.8", + "version": "5.0.9", "source": { "type": "git", "url": "https://github.com/llaville/php-compat-info.git", - "reference": "18913e8807d2ab02dea89b60e006ec395a131f0c" + "reference": "23db55a1c8f8a078e691bc66524fcb73eabbcb2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/llaville/php-compat-info/zipball/18913e8807d2ab02dea89b60e006ec395a131f0c", - "reference": "18913e8807d2ab02dea89b60e006ec395a131f0c", + "url": "https://api.github.com/repos/llaville/php-compat-info/zipball/23db55a1c8f8a078e691bc66524fcb73eabbcb2c", + "reference": "23db55a1c8f8a078e691bc66524fcb73eabbcb2c", "shasum": "" }, "require": { - "bartlett/php-compatinfo-db": "~1.23", - "bartlett/php-reflect": "~4.0", + "bartlett/php-compatinfo-db": "^1.23", + "bartlett/php-reflect": "^4.0", "ext-json": "*", "ext-libxml": "*", "ext-pcre": "*", @@ -32,13 +32,13 @@ "php": ">=5.4.0" }, "require-dev": { - "bartlett/monolog-callbackfilterhandler": "~1.0", - "bartlett/monolog-growlhandler": "~1.0", - "bartlett/phpunit-loggertestlistener": "~1.5", - "bartlett/umlwriter": "~1.0", - "doctrine/cache": "~1.3", - "monolog/monolog": "~1.10", - "psr/log": "~1.0" + "bartlett/monolog-callbackfilterhandler": "^1.0", + "bartlett/monolog-growlhandler": "^1.0", + "bartlett/phpunit-loggertestlistener": "^1.5", + "bartlett/umlwriter": "^1.0", + "doctrine/cache": "^1.3", + "monolog/monolog": "^1.10", + "psr/log": "^1.0" }, "suggest": { "bartlett/monolog-callbackfilterhandler": "Advanced filtering strategies for Monolog", @@ -81,20 +81,20 @@ "compatibility", "version" ], - "time": "2017-07-17T17:11:49+00:00" + "time": "2017-12-06T13:55:22+00:00" }, { "name": "bartlett/php-compatinfo-db", - "version": "1.25.0", + "version": "1.26.0", "source": { "type": "git", "url": "https://github.com/llaville/php-compatinfo-db.git", - "reference": "b5c31684aac0ca4f49eed632a65ce656d7626c31" + "reference": "be819ca85034b9e77b125ae3fa44a41f2fb51724" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/llaville/php-compatinfo-db/zipball/b5c31684aac0ca4f49eed632a65ce656d7626c31", - "reference": "b5c31684aac0ca4f49eed632a65ce656d7626c31", + "url": "https://api.github.com/repos/llaville/php-compatinfo-db/zipball/be819ca85034b9e77b125ae3fa44a41f2fb51724", + "reference": "be819ca85034b9e77b125ae3fa44a41f2fb51724", "shasum": "" }, "require": { @@ -151,7 +151,7 @@ "compatibility", "database" ], - "time": "2017-10-30T19:49:16+00:00" + "time": "2017-11-23T23:23:39+00:00" }, { "name": "bartlett/php-reflect", @@ -685,26 +685,26 @@ }, { "name": "pdepend/pdepend", - "version": "2.5.0", + "version": "2.5.1", "source": { "type": "git", "url": "https://github.com/pdepend/pdepend.git", - "reference": "0c50874333149c0dad5a2877801aed148f2767ff" + "reference": "9392319cbed95b12756945354c8b22be314b9c2b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdepend/pdepend/zipball/0c50874333149c0dad5a2877801aed148f2767ff", - "reference": "0c50874333149c0dad5a2877801aed148f2767ff", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/9392319cbed95b12756945354c8b22be314b9c2b", + "reference": "9392319cbed95b12756945354c8b22be314b9c2b", "shasum": "" }, "require": { "php": ">=5.3.7", - "symfony/config": "^2.3.0|^3", - "symfony/dependency-injection": "^2.3.0|^3", - "symfony/filesystem": "^2.3.0|^3" + "symfony/config": "^2.3.0|^3|^4", + "symfony/dependency-injection": "^2.3.0|^3|^4", + "symfony/filesystem": "^2.3.0|^3|^4" }, "require-dev": { - "phpunit/phpunit": "^4.4.0,<4.8", + "phpunit/phpunit": "^4.8|^5.7", "squizlabs/php_codesniffer": "^2.0.0" }, "bin": [ @@ -721,7 +721,7 @@ "BSD-3-Clause" ], "description": "Official version of pdepend to be handled with Composer", - "time": "2017-01-19T14:23:36+00:00" + "time": "2017-12-06T21:23:07+00:00" }, { "name": "phing/phing", @@ -872,35 +872,29 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.3.1", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "1119a9765990a24f4c5218a85032fb6f3a91eaff" + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/1119a9765990a24f4c5218a85032fb6f3a91eaff", - "reference": "1119a9765990a24f4c5218a85032fb6f3a91eaff", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bf329f6c1aadea3299f08ee804682b7c45b326a2", + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2", "shasum": "" }, "require": { - "php": "^7.0", + "php": "^5.6 || ^7.0", "phpdocumentor/reflection-common": "^1.0.0", "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -919,7 +913,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-15T19:01:54+00:00" + "time": "2017-11-10T14:09:06+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -1036,16 +1030,16 @@ }, { "name": "phpspec/prophecy", - "version": "v1.7.2", + "version": "1.7.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" + "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", + "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", "shasum": "" }, "require": { @@ -1057,7 +1051,7 @@ }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7" }, "type": "library", "extra": { @@ -1095,7 +1089,7 @@ "spy", "stub" ], - "time": "2017-09-04T11:05:03+00:00" + "time": "2017-11-24T13:59:53+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1162,16 +1156,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "1.4.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", "shasum": "" }, "require": { @@ -1205,7 +1199,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -1299,16 +1293,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { @@ -1344,7 +1338,7 @@ "keywords": [ "tokenizer" ], - "time": "2017-08-20T05:47:52+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", @@ -2098,16 +2092,16 @@ }, { "name": "seld/jsonlint", - "version": "1.6.1", + "version": "1.6.2", "source": { "type": "git", "url": "https://github.com/Seldaek/jsonlint.git", - "reference": "50d63f2858d87c4738d5b76a7dcbb99fa8cf7c77" + "reference": "7a30649c67ee0d19faacfd9fa2cfb6cc032d9b19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/50d63f2858d87c4738d5b76a7dcbb99fa8cf7c77", - "reference": "50d63f2858d87c4738d5b76a7dcbb99fa8cf7c77", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/7a30649c67ee0d19faacfd9fa2cfb6cc032d9b19", + "reference": "7a30649c67ee0d19faacfd9fa2cfb6cc032d9b19", "shasum": "" }, "require": { @@ -2143,7 +2137,7 @@ "parser", "validator" ], - "time": "2017-06-18T15:11:04+00:00" + "time": "2017-11-30T15:34:22+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -2225,30 +2219,30 @@ }, { "name": "symfony/config", - "version": "v3.3.13", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "8d2649077dc54dfbaf521d31f217383d82303c5f" + "reference": "1de51a6c76359897ab32c309934b93d036bccb60" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/8d2649077dc54dfbaf521d31f217383d82303c5f", - "reference": "8d2649077dc54dfbaf521d31f217383d82303c5f", + "url": "https://api.github.com/repos/symfony/config/zipball/1de51a6c76359897ab32c309934b93d036bccb60", + "reference": "1de51a6c76359897ab32c309934b93d036bccb60", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", - "symfony/filesystem": "~2.8|~3.0" + "symfony/filesystem": "~2.8|~3.0|~4.0" }, "conflict": { "symfony/dependency-injection": "<3.3", "symfony/finder": "<3.3" }, "require-dev": { - "symfony/dependency-injection": "~3.3", - "symfony/finder": "~3.3", - "symfony/yaml": "~3.0" + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/finder": "~3.3|~4.0", + "symfony/yaml": "~3.0|~4.0" }, "suggest": { "symfony/yaml": "To use the yaml reference dumper" @@ -2256,7 +2250,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2283,48 +2277,49 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2017-11-07T14:16:22+00:00" + "time": "2017-11-19T20:09:36+00:00" }, { "name": "symfony/console", - "version": "v3.3.13", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "63cd7960a0a522c3537f6326706d7f3b8de65805" + "reference": "2cdef78de8f54f68ff16a857e710e7302b47d4c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/63cd7960a0a522c3537f6326706d7f3b8de65805", - "reference": "63cd7960a0a522c3537f6326706d7f3b8de65805", + "url": "https://api.github.com/repos/symfony/console/zipball/2cdef78de8f54f68ff16a857e710e7302b47d4c7", + "reference": "2cdef78de8f54f68ff16a857e710e7302b47d4c7", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0", + "symfony/debug": "~2.8|~3.0|~4.0", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/dependency-injection": "<3.3" + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3", - "symfony/dependency-injection": "~3.3", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/filesystem": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" }, "suggest": { "psr/log": "For using the console logger", "symfony/event-dispatcher": "", - "symfony/filesystem": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2351,20 +2346,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-11-16T15:24:32+00:00" + "time": "2017-12-02T18:20:11+00:00" }, { "name": "symfony/debug", - "version": "v3.3.13", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "74557880e2846b5c84029faa96b834da37e29810" + "reference": "fb2001e5d85f95d8b6ab94ae3be5d2672df128fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/74557880e2846b5c84029faa96b834da37e29810", - "reference": "74557880e2846b5c84029faa96b834da37e29810", + "url": "https://api.github.com/repos/symfony/debug/zipball/fb2001e5d85f95d8b6ab94ae3be5d2672df128fd", + "reference": "fb2001e5d85f95d8b6ab94ae3be5d2672df128fd", "shasum": "" }, "require": { @@ -2375,12 +2370,12 @@ "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" }, "require-dev": { - "symfony/http-kernel": "~2.8|~3.0" + "symfony/http-kernel": "~2.8|~3.0|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2407,20 +2402,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-11-10T16:38:39+00:00" + "time": "2017-11-21T09:01:46+00:00" }, { "name": "symfony/dependency-injection", - "version": "v3.3.13", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "4e84f5af2c2d51ee3dee72df40b7fc08f49b4ab8" + "reference": "27810742895ad89e706ba5028e4f8fe425792b50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/4e84f5af2c2d51ee3dee72df40b7fc08f49b4ab8", - "reference": "4e84f5af2c2d51ee3dee72df40b7fc08f49b4ab8", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/27810742895ad89e706ba5028e4f8fe425792b50", + "reference": "27810742895ad89e706ba5028e4f8fe425792b50", "shasum": "" }, "require": { @@ -2430,15 +2425,16 @@ "conflict": { "symfony/config": "<3.3.1", "symfony/finder": "<3.3", - "symfony/yaml": "<3.3" + "symfony/proxy-manager-bridge": "<3.4", + "symfony/yaml": "<3.4" }, "provide": { "psr/container-implementation": "1.0" }, "require-dev": { - "symfony/config": "~3.3", - "symfony/expression-language": "~2.8|~3.0", - "symfony/yaml": "~3.3" + "symfony/config": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/yaml": "~3.4|~4.0" }, "suggest": { "symfony/config": "", @@ -2450,7 +2446,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2477,20 +2473,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2017-11-13T18:10:32+00:00" + "time": "2017-12-04T19:20:32+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.3.13", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "271d8c27c3ec5ecee6e2ac06016232e249d638d9" + "reference": "ca20b8f9ef149f40ff656d52965f240d85f7a8e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/271d8c27c3ec5ecee6e2ac06016232e249d638d9", - "reference": "271d8c27c3ec5ecee6e2ac06016232e249d638d9", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ca20b8f9ef149f40ff656d52965f240d85f7a8e4", + "reference": "ca20b8f9ef149f40ff656d52965f240d85f7a8e4", "shasum": "" }, "require": { @@ -2501,10 +2497,10 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~3.3", - "symfony/expression-language": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0" + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/stopwatch": "~2.8|~3.0|~4.0" }, "suggest": { "symfony/dependency-injection": "", @@ -2513,7 +2509,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2540,20 +2536,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-11-05T15:47:03+00:00" + "time": "2017-11-09T14:14:31+00:00" }, { "name": "symfony/filesystem", - "version": "v3.3.13", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "77db266766b54db3ee982fe51868328b887ce15c" + "reference": "de56eee71e0a128d8c54ccc1909cdefd574bad0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/77db266766b54db3ee982fe51868328b887ce15c", - "reference": "77db266766b54db3ee982fe51868328b887ce15c", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/de56eee71e0a128d8c54ccc1909cdefd574bad0f", + "reference": "de56eee71e0a128d8c54ccc1909cdefd574bad0f", "shasum": "" }, "require": { @@ -2562,7 +2558,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2589,20 +2585,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2017-11-07T14:12:55+00:00" + "time": "2017-11-19T18:59:05+00:00" }, { "name": "symfony/finder", - "version": "v3.3.13", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880" + "reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/138af5ec075d4b1d1bd19de08c38a34bb2d7d880", - "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880", + "url": "https://api.github.com/repos/symfony/finder/zipball/dac8d7db537bac7ad8143eb11360a8c2231f251a", + "reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a", "shasum": "" }, "require": { @@ -2611,7 +2607,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2638,7 +2634,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-11-05T15:47:03+00:00" + "time": "2017-11-05T16:10:10+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2701,16 +2697,16 @@ }, { "name": "symfony/stopwatch", - "version": "v3.3.13", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "1e93c3139ef6c799831fe03efd0fb1c7aecb3365" + "reference": "52510fe1aefdc1c5d2076ac6030421d387e689d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/1e93c3139ef6c799831fe03efd0fb1c7aecb3365", - "reference": "1e93c3139ef6c799831fe03efd0fb1c7aecb3365", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/52510fe1aefdc1c5d2076ac6030421d387e689d1", + "reference": "52510fe1aefdc1c5d2076ac6030421d387e689d1", "shasum": "" }, "require": { @@ -2719,7 +2715,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2746,27 +2742,30 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2017-11-10T19:02:53+00:00" + "time": "2017-11-07T14:28:09+00:00" }, { "name": "symfony/yaml", - "version": "v3.3.13", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "0938408c4faa518d95230deabb5f595bf0de31b9" + "reference": "f6a99b95b338799645fe9f7880d7d4ca1bf79cc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/0938408c4faa518d95230deabb5f595bf0de31b9", - "reference": "0938408c4faa518d95230deabb5f595bf0de31b9", + "url": "https://api.github.com/repos/symfony/yaml/zipball/f6a99b95b338799645fe9f7880d7d4ca1bf79cc1", + "reference": "f6a99b95b338799645fe9f7880d7d4ca1bf79cc1", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8" }, + "conflict": { + "symfony/console": "<3.4" + }, "require-dev": { - "symfony/console": "~2.8|~3.0" + "symfony/console": "~3.4|~4.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -2774,7 +2773,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2801,53 +2800,41 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-11-10T18:26:04+00:00" + "time": "2017-12-04T18:15:22+00:00" }, { - "name": "tedivm/jshrink", - "version": "v1.2.0", + "name": "tcz/phpunit-mockfunction", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/tedious/JShrink.git", - "reference": "667e99774d230525d4d3dc2a50da7ba6b1d56bad" + "url": "https://github.com/tcz/phpunit-mockfunction.git", + "reference": "87340f714620d7d6f8bb7fdd1f0ae50533acdcc3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tedious/JShrink/zipball/667e99774d230525d4d3dc2a50da7ba6b1d56bad", - "reference": "667e99774d230525d4d3dc2a50da7ba6b1d56bad", + "url": "https://api.github.com/repos/tcz/phpunit-mockfunction/zipball/87340f714620d7d6f8bb7fdd1f0ae50533acdcc3", + "reference": "87340f714620d7d6f8bb7fdd1f0ae50533acdcc3", "shasum": "" }, "require": { - "php": "^5.6|^7.0" - }, - "require-dev": { - "fabpot/php-cs-fixer": "0.4.0", - "phpunit/phpunit": "4.0.*", - "satooshi/php-coveralls": "^0.7.0" + "ext-runkit": "*" }, "type": "library", "autoload": { - "psr-0": { - "JShrink": "src/" - } + "classmap": [ + "PHPUnit/" + ] }, "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Robert Hafner", - "email": "tedivm@tedivm.com" - } - ], - "description": "Javascript Minifier built in PHP", - "homepage": "http://github.com/tedious/JShrink", + "description": "PHPUnit extension that uses runkit to mock PHP functions (both user-defined and system)", "keywords": [ - "javascript", - "minifier" + "mock", + "phpunit", + "runkit", + "testing", + "unit" ], - "time": "2017-05-30T02:59:46+00:00" + "time": "2014-03-20T18:50:53+00:00" }, { "name": "webmozart/assert", diff --git a/tests/unit/HtmlStringTest.php b/tests/unit/HtmlStringTest.php index f632155..c0f9ac0 100644 --- a/tests/unit/HtmlStringTest.php +++ b/tests/unit/HtmlStringTest.php @@ -21,7 +21,7 @@ namespace Pfw; -use PHPUnit\Framework\TestCase; +use Pfw\TestCase; use Pfw\View\HtmlString; class HtmlStringTest extends TestCase diff --git a/tests/unit/InfoControllerTest.php b/tests/unit/InfoControllerTest.php index 223f546..8cd55bc 100644 --- a/tests/unit/InfoControllerTest.php +++ b/tests/unit/InfoControllerTest.php @@ -21,7 +21,7 @@ namespace Pfw; -use PHPUnit\Framework\TestCase; +use Pfw\TestCase; use Pfw\View\View; class InfoControllerTest extends TestCase @@ -39,7 +39,8 @@ public function testDefaultAction() $systemCheckServiceMock->expects($this->any())->method('minXhVersion')->willReturn($systemCheckServiceMock); $systemCheckServiceMock->expects($this->any())->method('writable')->willReturn($systemCheckServiceMock); $systemCheckServiceMock->expects($this->once())->method('getChecks')->willReturn([]); - uopz_set_mock(SystemCheckService::class, $systemCheckServiceMock); + $scscreatemock = $this->mockStaticMethod(SystemCheckService::class, 'create'); + $scscreatemock->expects($this->any())->willReturn($systemCheckServiceMock); $viewMock = $this->createMock(View::class); $viewMock->expects($this->once())->method('template')->with('info')->willReturn($viewMock); $viewMock->expects($this->once())->method('data')->with([ @@ -48,9 +49,10 @@ public function testDefaultAction() 'checks' => [] ])->willReturn($viewMock); $viewMock->expects($this->once())->method('render'); - uopz_set_mock(View::class, $viewMock); + $viewcreatemock = $this->mockStaticMethod(View::class, 'create'); + $viewcreatemock->expects($this->any())->willReturn($viewMock); (new InfoController)->defaultAction(); - uopz_unset_mock(View::class); - uopz_unset_mock(SystemCheckService::class); + $viewcreatemock->restore(); + $scscreatemock->restore(); } } diff --git a/tests/unit/PluginTest.php b/tests/unit/PluginTest.php index c68fd7d..d83dca5 100644 --- a/tests/unit/PluginTest.php +++ b/tests/unit/PluginTest.php @@ -21,24 +21,38 @@ namespace Pfw; -use PHPUnit\Framework\TestCase; +use Pfw\TestCase; class PluginTest extends TestCase { + /** + * @var object + */ + private $rspmimock; + + /** + * @var object + */ + private $wpamock; + + /** + * @var object + */ + private $ppamock; + /** * @return void */ public function testAlwaysRegistersPluginMenu() { - uopz_redefine('XH_ADM', true); - uopz_set_return('XH_registerStandardPluginMenuItems', function ($showMain) use (&$registered) { - $registered = $showMain === false; - }, true); - uopz_set_return('XH_wantsPluginAdministration', false); + $this->setConstant('XH_ADM', true); + $rspmimock = $this->mockFunction('XH_registerStandardPluginMenuItems'); + $rspmimock->expects($this->once()); + $wpamock = $this->mockFunction('XH_wantsPluginAdministration'); + $wpamock->expects($this->any())->willReturn(false); (new Plugin)->run(); - $this->assertTrue($registered); - uopz_unset_return('XH_registerStandardPluginMenuItems'); - uopz_unset_return('XH_wantsPluginAdministration'); + $rspmimock->restore(); + $wpamock->restore(); } /** @@ -50,10 +64,13 @@ public function testPluginInfo() $admin = ''; $this->setUpPluginAdministrationStubs(); + $this->wpamock->expects($this->any())->willReturn(true); $infoControllerMock = $this->createMock(InfoController::class); $infoControllerMock->expects($this->once())->method('defaultAction'); - uopz_set_mock(InfoController::class, $infoControllerMock); + $iccmock = $this->mockStaticMethod(InfoController::class, 'create'); + $iccmock->expects($this->any())->willReturn($infoControllerMock); (new Plugin)->run(); + $iccmock->restore(); $this->tearDownPluginAdministrationStubs(); } @@ -67,13 +84,12 @@ public function testLanguageAdministration() $admin = 'plugin_language'; $action = 'plugin_edit'; $this->setUpPluginAdministrationStubs(); - uopz_set_return('plugin_admin_common', function () use (&$called) { - $called = true; - }, true); + $this->wpamock->expects($this->any())->willReturn(true); + $pacmock = $this->mockFunction('plugin_admin_common'); + $pacmock->expects($this->once())->willReturn(null); (new Plugin)->run(); - $this->assertTrue($called); $this->tearDownPluginAdministrationStubs(); - uopz_unset_return('plugin_admin_common'); + $pacmock->restore(); } /** @@ -81,10 +97,10 @@ public function testLanguageAdministration() */ private function setUpPluginAdministrationStubs() { - uopz_redefine('XH_ADM', true); - uopz_set_return('XH_registerStandardPluginMenuItems', null); - uopz_set_return('XH_wantsPluginAdministration', true); - uopz_set_return('print_plugin_admin', null); + $this->setConstant('XH_ADM', true); + $this->rspmimock = $this->mockFunction('XH_registerStandardPluginMenuItems'); + $this->wpamock = $this->mockFunction('XH_wantsPluginAdministration'); + $this->ppamock = $this->mockFunction('print_plugin_admin'); } /** @@ -92,8 +108,8 @@ private function setUpPluginAdministrationStubs() */ private function tearDownPluginAdministrationStubs() { - uopz_unset_return('XH_registerStandardPluginMenuItems'); - uopz_unset_return('XH_wantsPluginAdministration'); - uopz_unset_return('print_plugin_admin'); + $this->rspmimock->restore(); + $this->wpamock->restore(); + $this->ppamock->restore(); } } diff --git a/tests/unit/SystemCheckServiceTest.php b/tests/unit/SystemCheckServiceTest.php index fb6906b..bae3652 100644 --- a/tests/unit/SystemCheckServiceTest.php +++ b/tests/unit/SystemCheckServiceTest.php @@ -21,7 +21,7 @@ namespace Pfw; -use PHPUnit\Framework\TestCase; +use Pfw\TestCase; class SystemCheckServiceTest extends TestCase { @@ -73,7 +73,7 @@ public function testExtension() */ public function testMinXhVersion() { - uopz_redefine('CMSIMPLE_XH_VERSION', 'CMSimple_XH 1.7.0'); + $this->setConstant('CMSIMPLE_XH_VERSION', 'CMSimple_XH 1.7.0'); $subject = new SystemCheckService; $subject->minXhVersion('1.6.3'); @@ -90,7 +90,8 @@ public function testMinXhVersion() */ public function testPlugin() { - uopz_set_return('is_dir', true); + $isdirmock = $this->mockFunction('is_dir'); + $isdirmock->expects($this->any())->willReturn(true); $subject = new SystemCheckService; $subject->plugin('pagemanager'); @@ -100,7 +101,7 @@ public function testPlugin() $this->assertCount(1, $checks); $this->assertEquals(SystemCheck::SUCCESS, $checks[0]->getState()); - uopz_unset_return('is_dir'); + $isdirmock->restore(); } /** @@ -109,7 +110,8 @@ public function testPlugin() */ public function testWritable() { - uopz_set_return('is_writable', true); + $iswritablemock = $this->mockFunction('is_writable'); + $iswritablemock->expects($this->any())->willReturn(true); $subject = new SystemCheckService; $subject->writable('foo/bar/baz'); @@ -119,6 +121,6 @@ public function testWritable() $this->assertCount(1, $checks); $this->assertEquals(SystemCheck::SUCCESS, $checks[0]->getState()); - uopz_unset_return('is_writable'); + $iswritablemock->restore(); } } diff --git a/tests/unit/SystemCheckTest.php b/tests/unit/SystemCheckTest.php index f481a18..2575a8c 100644 --- a/tests/unit/SystemCheckTest.php +++ b/tests/unit/SystemCheckTest.php @@ -21,7 +21,7 @@ namespace Pfw; -use PHPUnit\Framework\TestCase; +use Pfw\TestCase; class SystemCheckTest extends TestCase { diff --git a/tests/unit/UrlTest.php b/tests/unit/UrlTest.php index 774ddcc..b44b51b 100644 --- a/tests/unit/UrlTest.php +++ b/tests/unit/UrlTest.php @@ -21,7 +21,7 @@ namespace Pfw; -use PHPUnit\Framework\TestCase; +use Pfw\TestCase; class UrlTest extends TestCase { @@ -116,7 +116,7 @@ public function testAbsoulte() $sn = '/'; $su = 'foo'; $_GET = ['foo' => '', 'bar' => 'baz']; - uopz_redefine('CMSIMPLE_URL', 'http://example.com/'); + $this->setConstant('CMSIMPLE_URL', 'http://example.com/'); $this->assertEquals('http://example.com/?foo&bar=baz', Url::getCurrent()->getAbsolute()); } diff --git a/tests/unit/ViewTest.php b/tests/unit/ViewTest.php index 7fd1b09..7799d22 100644 --- a/tests/unit/ViewTest.php +++ b/tests/unit/ViewTest.php @@ -21,7 +21,7 @@ namespace Pfw; -use PHPUnit\Framework\TestCase; +use Pfw\TestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; use Pfw\View\View; @@ -122,8 +122,8 @@ public function testI18n() ], 'foo' => [ 'foo_bar' => 'A %s, a %s and a .', - 'foo_plural_0' => '%s foo.', - 'foo_plural_1' => '%s foos.' + 'foo_plural#0' => '%s foo.', + 'foo_plural#1' => '%s foos.' ] ]; $this->expectOutputString( diff --git a/tests/unit/ViewValueTest.php b/tests/unit/ViewValueTest.php index f00f05b..bcfe127 100644 --- a/tests/unit/ViewValueTest.php +++ b/tests/unit/ViewValueTest.php @@ -21,7 +21,7 @@ namespace Pfw; -use PHPUnit\Framework\TestCase; +use Pfw\TestCase; use stdClass; use Pfw\View\View; use Pfw\View\ViewValue;