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 support for deep-cloning of results passed between tests using @depends #1780

Closed
sebastianbergmann opened this Issue Jul 4, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Jul 4, 2015

Since PHPUnit 3.4 the following is supported

<?php
class Test extends PHPUnit_Framework_TestCase
{
    public function testOne()
    {
        $o = new StdClass;

        // ...

        return $o;
    }

    /**
     * @depends testOne
     */
    public function testTwo($o)
    {
    }
}

to indicate that 1) the execution of testTwo should be skipped in case the execution of testOne fails and 2) that the variable returned from testOne should be passed on to testTwo as an argument.

Until now the variable is passed "as-is" meaning that for objects, for instance, a reference to the original object returned from testOne is passed on. This is not desired in all situations, for instance when multiple tests depend on the same test thus all working with the same object that was returned by the test they depend on.

It should be possible to clone an object that is passed to a depending test like this:

<?php
class Test extends PHPUnit_Framework_TestCase
{
    public function testOne()
    {
        $o = new StdClass;

        // ...

        return $o;
    }

    /**
     * @depends clone testOne
     */
    public function testTwo($o)
    {
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.