sebastianbergmann / phpunit-mock-objects

Mock Object library for PHPUnit
https://phpunit.de/
Other
4.98k stars 154 forks source link

Allow mocking methods that returns generators #387

Closed lcobucci closed 6 years ago

lcobucci commented 6 years ago

Because of #386 we can no longer mock methods that uses \Generator or \Closure as return type. This fixes it.

codecov-io commented 6 years ago

Codecov Report

Merging #387 into master will increase coverage by 0.04%. The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #387      +/-   ##
============================================
+ Coverage     73.37%   73.41%   +0.04%     
- Complexity      441      443       +2     
============================================
  Files            27       27              
  Lines          1277     1279       +2     
============================================
+ Hits            937      939       +2     
  Misses          340      340
Impacted Files Coverage Δ Complexity Δ
src/Generator.php 85.09% <100%> (+0.05%) 181 <0> (+2) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9388a2d...9caab78. Read the comment docs.

lcobucci commented 6 years ago

By the way, this is essentially a regression since the stable version works fine 👍

kubawerlos commented 6 years ago

By the way, this is essentially a regression since the stable version works fine

Well, it is not "fine"- if you look carefully at https://github.com/sebastianbergmann/phpunit-mock-objects/pull/386 you will see a test there, and see that mocking method which returns final class resulted with PHP error which is far away from "fine".

lcobucci commented 6 years ago

Well, it is not "fine"- if you look carefully at #386 you will see a test there, and see that mocking method which returns final class resulted with PHP error which is far away from "fine".

@kubawerlos the thing is that phpunit doesn't try to mock \Generator and \Closure because there's a check for that on StaticInvocation.

kubawerlos commented 6 years ago

@lcobucci yeah, I've found that as well - seems all cases are covered now.