Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing dev requirement against "phpspec/prophecy" #5617

Closed
wants to merge 1 commit into from

Conversation

phansys
Copy link
Member

@phansys phansys commented Jul 3, 2019

Subject

Add missing dev requirement against "phpspec/prophecy".

I am targeting this branch, because these changes respect BC.

Changelog

### Added
- Development dependency against "phpspec/prophecy".

@phansys phansys added the patch label Jul 3, 2019
@phansys phansys requested a review from a team July 3, 2019 16:38
@greg0ire
Copy link
Contributor

greg0ire commented Jul 3, 2019

Prophecy ships with phpunit. Adding this dependency exposes us to autoloading conflicts. What exactly pushed you to create this PR?

@phansys
Copy link
Member Author

phansys commented Jul 3, 2019

I didn't noticed that, you're right: https://github.com/sebastianbergmann/phpunit/blob/61d34e8dd6eb3555900f0f2a2fa9e7e570730102/composer.json#L34
In my case, the tests was failing because the lack of the dependency. I'll try to remove my vendor/ dir and try a fresh install in order to know what's happening.

@phansys
Copy link
Member Author

phansys commented Jul 4, 2019

We aren't requiring "phpunit/phpunit" explicitly, but "symfony/phpunit-bridge" (which has their own logic for version resolving):

"symfony/phpunit-bridge": "^4.3",

This line seems to remove the dependency, so, as result, "phpspec/prophecy" is not being installed:

$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml': ''));
Results
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 78 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-ctype (v1.11.0): Loading from cache
  - Installing symfony/yaml (v3.4.29): Loading from cache
  - Installing symfony/filesystem (v4.3.2): Loading from cache
  - Installing symfony/config (v4.3.2): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/service-contracts (v1.1.5): Loading from cache
  - Installing psr/cache (1.0.1): Loading from cache
  - Installing symfony/contracts (v1.1.0): Loading from cache
  - Installing symfony/dependency-injection (v3.4.29): Loading from cache
  - Installing matthiasnoback/symfony-config-test (4.0.1): Loading from cache
  - Installing matthiasnoback/symfony-dependency-injection-test (v3.1.0): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.11.0): Loading from cache
  - Installing twig/twig (v2.11.3): Loading from cache
  - Installing psr/log (1.1.0): Loading from cache
  - Installing symfony/debug (v4.3.2): Loading from cache
  - Installing symfony/polyfill-php72 (v1.11.0): Loading from cache
  - Installing symfony/polyfill-intl-idn (v1.11.0): Loading from cache
  - Installing symfony/mime (v4.3.2): Loading from cache
  - Installing symfony/http-foundation (v4.3.2): Loading from cache
  - Installing symfony/event-dispatcher-contracts (v1.1.5): Loading from cache
  - Installing symfony/event-dispatcher (v4.3.2): Loading from cache
  - Installing symfony/translation-contracts (v1.1.5): Loading from cache
  - Installing symfony/twig-bridge (v4.2.10): Loading from cache
  - Installing symfony/http-kernel (v3.4.29): Loading from cache
  - Installing symfony/twig-bundle (v4.1.0): Loading from cache
  - Installing symfony/templating (v4.3.2): Loading from cache
  - Installing symfony/options-resolver (v4.3.2): Loading from cache
  - Installing symfony/finder (v3.4.29): Loading from cache
  - Installing symfony/var-exporter (v4.3.2): Loading from cache
  - Installing symfony/cache-contracts (v1.1.5): Loading from cache
  - Installing symfony/cache (v4.3.2): Loading from cache
  - Installing symfony/routing (v3.4.29): Loading from cache
  - Installing symfony/class-loader (v3.4.29): Loading from cache
  - Installing symfony/framework-bundle (v3.4.29): Loading from cache
  - Installing doctrine/cache (v1.8.0): Loading from cache
  - Installing symfony/inflector (v4.3.2): Loading from cache
  - Installing symfony/property-access (v4.3.2): Loading from cache
  - Installing symfony/security (v4.2.10): Loading from cache
  - Installing symfony/security-acl (v3.0.2): Loading from cache
  - Installing doctrine/lexer (1.0.2): Loading from cache
  - Installing doctrine/annotations (v1.6.1): Loading from cache
  - Installing symfony/intl (v4.3.2): Loading from cache
  - Installing symfony/polyfill-intl-icu (v1.11.0): Loading from cache
  - Installing symfony/form (v4.2.10): Loading from cache
  - Installing symfony/console (v3.4.29): Loading from cache
  - Installing symfony/asset (v4.3.2): Loading from cache
  - Installing doctrine/event-manager (v1.0.0): Loading from cache
  - Installing doctrine/dbal (v2.9.2): Loading from cache
  - Installing doctrine/reflection (v1.0.0): Loading from cache
  - Installing doctrine/collections (v1.6.2): Loading from cache
  - Installing doctrine/persistence (1.1.1): Loading from cache
  - Installing doctrine/inflector (v1.3.0): Loading from cache
  - Installing doctrine/common (v2.10.0): Loading from cache
  - Installing sonata-project/doctrine-extensions (1.3.0): Loading from cache
  - Installing twig/extensions (v1.5.4): Loading from cache
  - Installing symfony/validator (v4.3.2): Loading from cache
  - Installing symfony/translation (v4.3.2): Loading from cache
  - Installing sonata-project/datagrid-bundle (2.5.0): Loading from cache
  - Installing cocur/slugify (v3.2): Loading from cache
  - Installing sonata-project/core-bundle (3.17.0): Loading from cache
  - Installing sonata-project/cache (2.0.1): Loading from cache
  - Installing sonata-project/block-bundle (3.15.0): Loading from cache
  - Installing sonata-project/exporter (2.0.1): Loading from cache
  - Installing symfony/process (v3.4.29): Loading from cache
  - Installing sensio/generator-bundle (v3.1.7): Loading from cache
  - Installing knplabs/knp-menu (2.3.0): Loading from cache
  - Installing knplabs/knp-menu-bundle (2.2.2): Loading from cache
  - Installing symfony/doctrine-bridge (v4.2.10): Loading from cache
  - Installing symfony/expression-language (v4.3.2): Loading from cache
  - Installing symfony/security-bundle (v4.0.15): Loading from cache
  - Installing jms/metadata (1.7.0): Loading from cache
  - Installing jms/cg (1.2.0): Loading from cache
  - Installing jms/aop-bundle (1.3.0): Loading from cache
  - Installing jms/di-extra-bundle (1.9.2): Loading from cache
  - Installing nikic/php-parser (v4.2.2): Loading from cache
  - Installing jms/translation-bundle (1.4.4): Loading from cache
  - Installing sonata-project/intl-bundle (2.6.0): Loading from cache
  - Installing symfony/phpunit-bridge (v4.3.2): Loading from cache
symfony/service-contracts suggests installing symfony/service-implementation
symfony/contracts suggests installing symfony/cache-contracts-implementation
symfony/contracts suggests installing symfony/http-client-contracts-implementation
symfony/contracts suggests installing symfony/service-contracts-implementation
symfony/contracts suggests installing symfony/translation-contracts-implementation
symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them)
symfony/event-dispatcher-contracts suggests installing psr/event-dispatcher
symfony/twig-bridge suggests installing symfony/stopwatch (For using the StopwatchExtension)
symfony/twig-bridge suggests installing symfony/var-dumper (For using the DumpExtension)
symfony/twig-bridge suggests installing symfony/web-link (For using the WebLinkExtension)
symfony/http-kernel suggests installing symfony/browser-kit
symfony/http-kernel suggests installing symfony/var-dumper
symfony/class-loader suggests installing symfony/polyfill-apcu (For using ApcClassLoader on HHVM)
symfony/framework-bundle suggests installing ext-apcu (For best performance of the system caches)
symfony/framework-bundle suggests installing symfony/serializer (For using the serializer service)
symfony/framework-bundle suggests installing symfony/property-info (For using the property_info service)
symfony/framework-bundle suggests installing symfony/web-link (For using web links, features such as preloading, prefetching or prerendering)
doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
symfony/security suggests installing symfony/ldap (For using the LDAP user and authentication providers)
symfony/console suggests installing symfony/lock
sonata-project/doctrine-extensions suggests installing doctrine/orm (If you use doctrine orm)
sonata-project/doctrine-extensions suggests installing doctrine/phpcr-odm (If you use doctrine phpcr)
symfony/validator suggests installing egulias/email-validator (Strict (RFC compliant) email validation)
symfony/validator suggests installing symfony/property-info (To automatically add NotNull and Type constraints)
sonata-project/cache suggests installing doctrine/orm (ORM support)
sonata-project/cache suggests installing doctrine/phpcr-odm (PHPCR ODM support)
sonata-project/cache suggests installing ext-apc (Caching with ext/apc)
sonata-project/cache suggests installing ext-memcached (Caching with ext/memcached)
sonata-project/cache suggests installing predis/predis (Install redis php)
sonata-project/block-bundle suggests installing sonata-project/cache-bundle (^3.0)
sonata-project/exporter suggests installing propel/propel1 (^1.6)
symfony/doctrine-bridge suggests installing symfony/property-info
symfony/doctrine-bridge suggests installing doctrine/data-fixtures
symfony/doctrine-bridge suggests installing doctrine/orm
sonata-project/intl-bundle suggests installing sonata-project/user-bundle (For user timezone detection)
Writing lock file
Generating autoload files

$ php ./vendor/bin/simple-phpunit
Installing phpunit/phpunit (7.4.5)
Plugins have been disabled.
  - Installing phpunit/phpunit (7.4.5): Loading from cache
Created project in phpunit-7.4
composer.json has been updated
Loading composer repositories with package information
Updating dependencies
Package operations: 22 installs, 0 updates, 0 removals
  - Installing sebastian/global-state (2.0.0): Loading from cache
  - Installing sebastian/recursion-context (3.0.0): Loading from cache
  - Installing sebastian/object-reflector (1.1.1): Loading from cache
  - Installing sebastian/object-enumerator (3.0.3): Loading from cache
  - Installing doctrine/instantiator (1.2.0): Loading from cache
  - Installing myclabs/deep-copy (1.9.1): Loading from cache
  - Installing phar-io/version (2.0.1): Loading from cache
  - Installing phar-io/manifest (1.0.3): Loading from cache
  - Installing theseer/tokenizer (1.1.3): Loading from cache
  - Installing sebastian/version (2.0.1): Loading from cache
  - Installing sebastian/environment (4.2.2): Loading from cache
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing phpunit/php-token-stream (3.0.1): Loading from cache
  - Installing phpunit/php-file-iterator (2.0.2): Loading from cache
  - Installing phpunit/php-code-coverage (6.1.4): Loading from cache
  - Installing phpunit/php-timer (2.1.2): Loading from cache
  - Installing sebastian/exporter (3.1.0): Loading from cache
  - Installing sebastian/diff (3.0.2): Loading from cache
  - Installing sebastian/comparator (3.0.2): Loading from cache
  - Installing sebastian/resource-operations (2.0.1): Loading from cache
  - Installing symfony/phpunit-bridge (7.4.99): Symlinking from SonataAdminBundle/vendor/symfony/phpunit-bridge
Writing lock file
Generating optimized autoload files

@core23
Copy link
Member

core23 commented Jul 5, 2019

Maybe we should work an this to solve the tooling problem?

@greg0ire
Copy link
Contributor

greg0ire commented Jul 5, 2019

@phansys we're installing the bridge to get deprecation-related goodies, but we're not using simple-phpunit, are we? We're using the phpunit phar, which should contain prophecy.

@phansys
Copy link
Member Author

phansys commented Jul 5, 2019

@phansys we're installing the bridge to get deprecation-related goodies, but we're not using simple-phpunit, are we? We're using the phpunit phar, which should contain prophecy.

I think you're referring to the CI process, but this change was made focusing on the end user, which checks out the project and wants to test it; like the case I've shared before (see Results).

IMO, if there is no strong conflict with the usage of the self declared dependencies on the CI suite, I think we could make both cases compatible.
Personally, I generally feel more confident on projects that have based their CI routine on dependencies that are explicitly declared.

@greg0ire
Copy link
Contributor

greg0ire commented Jul 5, 2019

I think we should document what ways of testing we support. Our contributing guide is huge but does not contain this information. Right now, the way I test is downloading the phar in my $PATH, and then run make test:

test: build/xdebug-filter.php
ifeq ($(HAS_XDEBUG), 0)
phpunit --prepend build/xdebug-filter.php -c phpunit.xml.dist --coverage-clover build/logs/clover.xml
else
phpunit -c phpunit.xml.dist
endif
.PHONY: test

I hear what you say @phansys , but I think it would be better to solve this by using the tool @core23 is suggesting.

If you want to read, here is a long thread about this subject: sonata-project/dev-kit#197

@phansys
Copy link
Member Author

phansys commented Jul 6, 2019

I agree that the proposed solution at sonata-project/dev-kit#372 could solve the issue, but AFAIK, "symfony/phpunit-bridge" accomplish exactly that task:

Provides a modified version of PHPUnit that allows 1. separating the dependencies of your app from those of phpunit to prevent any unwanted constraints to apply; 2. running tests in parallel when a test suite is split in several phpunit.xml files; 3. recording and replaying skipped tests.

@greg0ire
Copy link
Contributor

greg0ire commented Jul 7, 2019

I reread the conversation on dev-kit and yes, that would be a good solution too. IMO you can carry sonata-project/dev-kit#265 if you think we should go that way. I closed it because I no longer observed that kind of autoloading issues, probably because there was some work in upstream libraries to make them easier to avoid.

@SonataCI
Copy link
Collaborator

Could you please rebase your PR and fix merge conflicts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants