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

[RFC] Make Hamcrest A Required Dependency #435

Closed
padraic opened this issue Feb 13, 2015 · 16 comments
Closed

[RFC] Make Hamcrest A Required Dependency #435

padraic opened this issue Feb 13, 2015 · 16 comments

Comments

@padraic
Copy link
Member

padraic commented Feb 13, 2015

Should end the debate over adding more matchers directly to Mockery, and also promote using the Hamcrest ones more consistently since everyone should now have it installed.

This assumes there are no other options we should be considering. Are there?

@aik099
Copy link

aik099 commented Feb 14, 2015

Yeah, too many guys I think I have a matcher idea for Mockery tickets lately. Maybe we even can:

  • remove Mockery's own matchers (that would be a BC break for sure)
  • use Hamcrest matchers inside Mockery matcher classes (or extend from them)

@padraic
Copy link
Member Author

padraic commented Feb 14, 2015

I'd be up for using them internal to our own API. I think the BC break might be too far for 1.0.0 though clearly I should not have run afoul of NIH syndrome to start with!

@padraic
Copy link
Member Author

padraic commented Feb 21, 2015

We're unlikely to change anything prior to 1.0.0, if even then so suddenly, so unless there are any objections, I'll commit it as a require tomorrow.

@padraic
Copy link
Member Author

padraic commented Mar 12, 2015

Assuming no objections, I'll commit this change later.

@JanTvrdik
Copy link

👎 This makes Mockery installation a lot heavier.

@gmazzap
Copy link
Contributor

gmazzap commented May 13, 2015

👎 Since this has been introducued all my test fails because of #464

Mockery is perfectly functional without Hamcrest, so Hamcrest is not a dependency. Why force it to be?

@GrahamCampbell
Copy link
Contributor

@Giuseppe-Mazzapica #464 has already been fixed.

@gmazzap
Copy link
Contributor

gmazzap commented May 13, 2015

@GrahamCampbell where? If I require via Composer Mockery 0.9.4 (last one) and last PHPunit and I manually load all the PHP functions file during PHPUnit bootstrap (I need that because my tests uses PHPUnit functions) I still get the "function already defined" error.

@GrahamCampbell
Copy link
Contributor

The very latest releases of phpunit and hamcrest should work.

@GrahamCampbell
Copy link
Contributor

The hamcrest release only came out yesterday mind you. ;)

@gmazzap
Copy link
Contributor

gmazzap commented May 13, 2015

@GrahamCampbell I don't require hamcrest, because I don't use it. Mockery 0.9.4 requires it for me.

If I composer-require

  • PHPUnit 4.6.6 (last stable)
  • Mockery 0.9.4 (last)

and I do (in the PHPUnit bootstrap file):

require_once 'path/to/vendor/autoload.php';
require_once  'path/to/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php';

When I run tests I get:

Fatal error: Cannot redeclare any() (previously declared in ...) in ...

On the countrary, if I composer-require

  • PHPUnit 4.6.6 (last stable)
  • Mockery 0.9.3 (previous)

Everything works well.

@davedevelopment
Copy link
Collaborator

@Giuseppe-Mazzapica

try

composer update hamcrest/hamcrest-php

then reverse the order of those includes

require_once  'path/to/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php';
require_once 'path/to/vendor/autoload.php';

@gmazzap
Copy link
Contributor

gmazzap commented May 13, 2015

Thanks @davedevelopment

try composer update hamcrest/hamcrest-php

If this is the solution, it is not the case to release a 0.9.5 of Mockery that requires last version of hamcrest? As already said, I dont require hamcrest, Mockery does it for me.

@davedevelopment
Copy link
Collaborator

@Giuseppe-Mazzapica yes and no. You'd still have the problem if you didn't reverse the order of those includes (I think), which we can't do anything about. PHPUnit dumps those functions in the global namespace without consideration for anything that might already exist.

@gmazzap
Copy link
Contributor

gmazzap commented May 13, 2015

@davedevelopment

Ok, actually 0.9.4 version of Mockery already requires the last version of hamcrest.

The solution was just to reverse the order of includes.

My opition:

  • this is a pretty fragile solution that depends on the order that consumers requires 3rd party things
  • there was no need to make hamcrest a required dependency for Mockery, because it is not a required dependency: Mockery works perfectly without it

The latter point was the reason I decided to comment here instead on #464 ...

@padraic
Copy link
Member Author

padraic commented May 14, 2015

Closing this as it's done and I don't want to confuse issues with old ones.

While recognising there is fragility, we've mitigated it as best we can short of reversing the RFC, and I'm not leaning towards a reversal. Mockery only has basic matchers, and we rely on Hamcrest to extend those. Most of the fragility isn't ours, and could be solved by PHPUnit putting some basic checks in place before loading functions into the global namespace.

If it remains a concern, please feel free to bring up in a separate issue.

@padraic padraic closed this as completed May 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants