diff --git a/composer.json b/composer.json index 432509098..92bbfdc8c 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,6 @@ }, "require-dev": { "symfony/phpunit-bridge": "^6.0", - "phpspec/prophecy": "^1.10", "phpstan/phpstan": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-deprecation-rules": "^1", diff --git a/composer.lock b/composer.lock index 90a10ba80..e9f67c58f 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": "9c8e9d945b0cbc11f0600b7f0224ac91", + "content-hash": "982b74a5ea81168a1ef177278da9cb88", "packages": [ { "name": "composer/ca-bundle", @@ -1790,302 +1790,6 @@ } ], "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^8.0", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "https://ocramius.github.io/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.0" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2020-11-10T18:47:58+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" - }, - "time": "2021-10-19T17:43:47+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.5.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae", - "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1" - }, - "time": "2021-10-02T14:08:47+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0 || ^7.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" - }, - "time": "2021-12-08T12:19:24+00:00" - }, { "name": "phpstan/phpstan", "version": "1.2.0", @@ -2306,286 +2010,6 @@ }, "time": "2021-11-18T09:30:29+00:00" }, - { - "name": "sebastian/comparator", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", - "shasum": "" - }, - "require": { - "php": ">=7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" - }, - "require-dev": { - "phpunit/phpunit": "^8.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-30T08:04:30+00:00" - }, - { - "name": "sebastian/diff", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/14f72dd46eaf2f2293cbe79c93cc0bc43161a211", - "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.0", - "symfony/process": "^2 || ^3.3 || ^4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/3.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-30T07:59:04+00:00" - }, - { - "name": "sebastian/exporter", - "version": "3.1.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/0c32ea2e40dbf59de29f3b49bf375176ce7dd8db", - "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db", - "shasum": "" - }, - "require": { - "php": ">=7.0", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^8.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2021-11-11T13:51:24+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "3.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", - "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", - "shasum": "" - }, - "require": { - "php": ">=7.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" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "support": { - "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-30T07:34:24+00:00" - }, { "name": "symfony/phpunit-bridge", "version": "v6.0.0", @@ -2668,64 +2092,6 @@ } ], "time": "2021-11-29T15:32:57+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.10.0" - }, - "time": "2021-03-09T10:59:23+00:00" } ], "aliases": [], diff --git a/phpstan/config.neon b/phpstan/config.neon index 5b8431607..ecc222e0b 100644 --- a/phpstan/config.neon +++ b/phpstan/config.neon @@ -36,13 +36,6 @@ parameters: # we don't have different constructors for parent/child - '~^Unsafe usage of new static\(\)\.$~' - # BC with older PHPUnit - - '~^Call to an undefined static method Composer\\Test\\PolyfillTestCase::setExpectedException\(\)\.$~' - - '~^Call to an undefined method Composer\\Test\\[a-zA-Z0-9\\]+::(assertFileDoesNotExist|assertMatchesRegularExpression)\(\)\.$~' - - # Mock errors - - '~^Call to an undefined method (PHPUnit\\Framework\\MockObject\\MockObject|Prophecy\\Prophecy\\ObjectProphecy)::.*$~' - # Ignore some irrelevant errors in test files - '~Method Composer\\Test\\[^:]+::(setUp(BeforeClass)?|tearDown(AfterClass)?|test[^(]+)\(\) has no return type specified.~' - '~Method Composer\\Test\\[^:]+::(data\w+|provide\w+|\w+?Provider)\(\) has no return type specified.~' diff --git a/tests/Composer/Test/Downloader/DownloadManagerTest.php b/tests/Composer/Test/Downloader/DownloadManagerTest.php index d689c4f58..7c84a1c9b 100644 --- a/tests/Composer/Test/Downloader/DownloadManagerTest.php +++ b/tests/Composer/Test/Downloader/DownloadManagerTest.php @@ -13,6 +13,7 @@ namespace Composer\Test\Downloader; use Composer\Downloader\DownloadManager; +use Composer\Package\PackageInterface; use Composer\Test\TestCase; class DownloadManagerTest extends TestCase @@ -639,20 +640,30 @@ class DownloadManagerTest extends TestCase { $initial = null; if ($prevPkgSource) { - $initial = $this->prophesize('Composer\Package\PackageInterface'); - $initial->getInstallationSource()->willReturn($prevPkgSource); - $initial->isDev()->willReturn($prevPkgIsDev); + $initial = $this->getMockBuilder(PackageInterface::class)->getMock(); + $initial->expects($this->atLeastOnce()) + ->method('getInstallationSource') + ->willReturn($prevPkgSource); + $initial->expects($this->any()) + ->method('isDev') + ->willReturn($prevPkgIsDev); } - $target = $this->prophesize('Composer\Package\PackageInterface'); - $target->getSourceType()->willReturn(in_array('source', $targetAvailable, true) ? 'git' : null); - $target->getDistType()->willReturn(in_array('dist', $targetAvailable, true) ? 'zip' : null); - $target->isDev()->willReturn($targetIsDev); + $target = $this->getMockBuilder(PackageInterface::class)->getMock(); + $target->expects($this->atLeastOnce()) + ->method('getSourceType') + ->willReturn(in_array('source', $targetAvailable, true) ? 'git' : null); + $target->expects($this->atLeastOnce()) + ->method('getDistType') + ->willReturn(in_array('dist', $targetAvailable, true) ? 'zip' : null); + $target->expects($this->any()) + ->method('isDev') + ->willReturn($targetIsDev); $manager = new DownloadManager($this->io, false, $this->filesystem); $method = new \ReflectionMethod($manager, 'getAvailableSources'); $method->setAccessible(true); - $this->assertEquals($expected, $method->invoke($manager, $target->reveal(), $initial ? $initial->reveal() : null)); + $this->assertEquals($expected, $method->invoke($manager, $target, $initial ?? null)); } public static function updatesProvider() diff --git a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php index d99fcd110..462000325 100644 --- a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php @@ -20,8 +20,6 @@ use Composer\Package\RootPackage; use Composer\Package\Version\VersionGuesser; use Composer\Semver\VersionParser; use Composer\Test\TestCase; -use Composer\Test\Mock\ProcessExecutorMock; -use Prophecy\Argument; class RootPackageLoaderTest extends TestCase { @@ -93,9 +91,10 @@ class RootPackageLoaderTest extends TestCase public function testPrettyVersionForRootPackageInVersionBranch() { // see #6845 - $manager = $this->prophesize('Composer\\Repository\\RepositoryManager'); - $versionGuesser = $this->prophesize('Composer\\Package\\Version\\VersionGuesser'); - $versionGuesser->guessVersion(Argument::cetera()) + $manager = $this->getMockBuilder('Composer\\Repository\\RepositoryManager')->disableOriginalConstructor()->getMock(); + $versionGuesser = $this->getMockBuilder('Composer\\Package\\Version\\VersionGuesser')->disableOriginalConstructor()->getMock(); + $versionGuesser->expects($this->atLeastOnce()) + ->method('guessVersion') ->willReturn(array( 'name' => 'A', 'version' => '3.0.9999999.9999999-dev', @@ -104,7 +103,7 @@ class RootPackageLoaderTest extends TestCase )); $config = new Config; $config->merge(array('repositories' => array('packagist' => false))); - $loader = new RootPackageLoader($manager->reveal(), $config, null, $versionGuesser->reveal()); + $loader = new RootPackageLoader($manager, $config, null, $versionGuesser); $package = $loader->load(array()); $this->assertEquals('3.0-dev', $package->getPrettyVersion()); diff --git a/tests/Composer/Test/Package/RootAliasPackageTest.php b/tests/Composer/Test/Package/RootAliasPackageTest.php index 10f9a179c..72ffbebcb 100644 --- a/tests/Composer/Test/Package/RootAliasPackageTest.php +++ b/tests/Composer/Test/Package/RootAliasPackageTest.php @@ -14,84 +14,112 @@ namespace Composer\Test\Package; use Composer\Package\Link; use Composer\Package\RootAliasPackage; +use Composer\Package\RootPackage; use Composer\Semver\Constraint\MatchAllConstraint; use Composer\Test\TestCase; -use Prophecy\Argument; +use PHPUnit\Framework\MockObject\MockObject; class RootAliasPackageTest extends TestCase { public function testUpdateRequires() { - $root = $this->getMockRootPackageInterface(); - $root->setRequires(Argument::type('array'))->shouldBeCalled(); - - $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getRequires()); $links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_REQUIRE, 'self.version')); + + $root = $this->getMockRootPackage(); + $root->expects($this->once()) + ->method('setRequires') + ->with($this->equalTo($links)); + + $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getRequires()); $alias->setRequires($links); $this->assertNotEmpty($alias->getRequires()); } public function testUpdateDevRequires() { - $root = $this->getMockRootPackageInterface(); - $root->setDevRequires(Argument::type('array'))->shouldBeCalled(); - - $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getDevRequires()); $links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_DEV_REQUIRE, 'self.version')); + + $root = $this->getMockRootPackage(); + $root->expects($this->once()) + ->method('setDevRequires') + ->with($this->equalTo($links)); + + $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getDevRequires()); $alias->setDevRequires($links); $this->assertNotEmpty($alias->getDevRequires()); } public function testUpdateConflicts() { - $root = $this->getMockRootPackageInterface(); - $root->setConflicts(Argument::type('array'))->shouldBeCalled(); - - $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getConflicts()); $links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_CONFLICT, 'self.version')); + + $root = $this->getMockRootPackage(); + $root->expects($this->once()) + ->method('setConflicts') + ->with($this->equalTo($links)); + + $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getConflicts()); $alias->setConflicts($links); $this->assertNotEmpty($alias->getConflicts()); } public function testUpdateProvides() { - $root = $this->getMockRootPackageInterface(); - $root->setProvides(Argument::type('array'))->shouldBeCalled(); - - $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getProvides()); $links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_PROVIDE, 'self.version')); + + $root = $this->getMockRootPackage(); + $root->expects($this->once()) + ->method('setProvides') + ->with($this->equalTo($links)); + + $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getProvides()); $alias->setProvides($links); $this->assertNotEmpty($alias->getProvides()); } public function testUpdateReplaces() { - $root = $this->getMockRootPackageInterface(); - $root->setReplaces(Argument::type('array'))->shouldBeCalled(); - - $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getReplaces()); $links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_REPLACE, 'self.version')); + + $root = $this->getMockRootPackage(); + $root->expects($this->once()) + ->method('setReplaces') + ->with($this->equalTo($links)); + + $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getReplaces()); $alias->setReplaces($links); $this->assertNotEmpty($alias->getReplaces()); } /** - * @return \Prophecy\Prophecy\ObjectProphecy + * @return RootPackage&MockObject */ - protected function getMockRootPackageInterface() + protected function getMockRootPackage() { - $root = $this->prophesize('Composer\\Package\\RootPackage'); - $root->getName()->willReturn('something/something')->shouldBeCalled(); - $root->getRequires()->willReturn(array())->shouldBeCalled(); - $root->getDevRequires()->willReturn(array())->shouldBeCalled(); - $root->getConflicts()->willReturn(array())->shouldBeCalled(); - $root->getProvides()->willReturn(array())->shouldBeCalled(); - $root->getReplaces()->willReturn(array())->shouldBeCalled(); + $root = $this->getMockBuilder(RootPackage::class)->disableOriginalConstructor()->getMock(); + $root->expects($this->atLeastOnce()) + ->method('getName') + ->willReturn('something/something'); + $root->expects($this->atLeastOnce()) + ->method('getRequires') + ->willReturn(array()); + $root->expects($this->atLeastOnce()) + ->method('getDevRequires') + ->willReturn(array()); + $root->expects($this->atLeastOnce()) + ->method('getConflicts') + ->willReturn(array()); + $root->expects($this->atLeastOnce()) + ->method('getProvides') + ->willReturn(array()); + $root->expects($this->atLeastOnce()) + ->method('getReplaces') + ->willReturn(array()); return $root; }