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

MockEnvironment extends Mock to be usable with MockDisabler. #6

Closed
wants to merge 1 commit into from

Conversation

geoffroy-aubry
Copy link
Contributor

Hi Markus,

Thank you for accepting my previous PR!

I would find useful if MockEnvironment extends Mock. This would write the following:

class MyTest extends \PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $builder = new SleepEnvironmentBuilder();
        $builder->setNamespace('My\\Namespace')
            ->setTimestamp(strtotime('2030-01-01 00:00:00'));
        $mock = $builder->build();
        $mock->enable();
        $this->getTestResultObject()->addListener(new MockDisabler($mock));
        // ...

Indeed, MockDisabler's constructor requires a Mock instance.

Regards,
Geoffroy

@malkusch
Copy link
Member

Thank you for your idea. Having PHPUnit disable the complete environment is a valid use case. I agree that there should be something which makes this possible. But I don't feel that MockEnvironment should become a Mock. I'd like to keep the composition.
Furthermore MockDisabler is not part of the public API and just some implementation detail. So let's rephrase this PR to the feature request "Integrate MockEnvironment into PHPUnit - notably call disable() automatically": #7

I feel to extend the trait PHPMock with some functionality for this. I'll think about this and let you know.

@malkusch
Copy link
Member

I moved this discussion to #7. What do you think about a PHPMock::registerForTearDown() which would accept a MockEnvironment?

@geoffroy-aubry
Copy link
Contributor Author

I think it is a good solution (with Deactivatable interface). :-)

@malkusch malkusch added this to the 0.6 milestone Mar 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants