pest icon indicating copy to clipboard operation
pest copied to clipboard

[Bug]: `toHaveMethod` Arch Expectation is Overwriting `toHaveMethod` of Common Expectations

Open devajmeireles opened this issue 1 year ago • 1 comments

What Happened

The toHaveMethod in the Arch plugin, which was added on this PR: https://github.com/pestphp/pest/pull/947, is overwriting the toHaveMethod from common expectations. The same doesn't happen to the toHaveMethods because the Arch plugin doesn't contain this expectation.

How to Reproduce

The test:

test('pass', function () {
    $object = new class
    {
        public function foo(): void
        {
            //
        }
    };

    expect($object)->toHaveMethod('foo');
});

... Will fail:

CleanShot 2023-09-06 at 12 44 25

Sample Repository

No response

Pest Version

Latest

PHP Version

8.2.9

Operation System

macOS

Notes

It was not noticed on the PR that adds the toHaveMethod in the Arch plugin, because the toHaveMethod from common expectations is not tested, only the toHaveMethods from common expectations are tested here

devajmeireles avatar Sep 06 '23 03:09 devajmeireles

+1, note that toHaveMethods works in the meantime with a singular item array, ie expect($object)->toHaveMethods(['foo']);.

Not ideal 🤦🏻‍♂️ , but will prevent the suite from failing until this is fixed.

vegabsm avatar Sep 13 '23 21:09 vegabsm