Skip to content

1.10.0 regression #457

@yannickl88

Description

@yannickl88

With the release of 1.10.0 we noticed some of our tests breaking. After some digging this is because the behavior has slightly changed. Maybe it's best explained with an example:

require __DIR__ . '/vendor/autoload.php';

class A {
    public function someMethod() {
        return 42;
    }
    public function otherMethod() {
    }
}

class Regression {
    public function test(A $a) {
        try {
            $a->someMethod();
        } catch (\Throwable $e) {
            return false;
        }
        return true;
    }
}

$prophet = new Prophecy\Prophet();
$prophecy = $prophet->prophesize(A::class);
$prophecy->otherMethod()->shouldNotBeCalled();

var_dump((new Regression())->test($prophecy->reveal()));

With 1.9.0 this outputs: bool(false)
With 1.10.0 this outputs: bool(true)

This is because the prophecy no longer throws an error when dealing with methods which have not been prophesied. And while I admit this is a poor test, it means that some of our tests are breaking and need fixing with a feature release.

Is this an intended side effect?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions