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

Can not set methods with setMethodsExcept when only one method exist #3886

Closed
ViniTou opened this issue Oct 7, 2019 · 1 comment
Closed
Labels
type/bug Something is broken

Comments

@ViniTou
Copy link

ViniTou commented Oct 7, 2019

Q A
PHPUnit version 8.3.5
PHP version 7.3.2
Installation Method Composer

Summary

I want to use not mocked method with setMethodsExcept, when only one public method is provided in class.

Current behavior

When setting methods which should not be mocked, when class in question have only one public method, that method is still mocked. Adding additional method to class solves problem.

How to reproduce

Create class with only one public method, then use MockBuilder

        return $this
            ->getMockBuilder(ClassWithOnePublicMethod::class)
            ->setMethodsExcept(['methodName'])
            ->getMock();

Expected behavior

Method in question is not mocked.

I think that problem, (if it truly exist, and it is not some misuse of api on my side) comes from array_diff returning and passing empty array to setMethods in setMethodsExcept instead of null. But not sure, if just doing in wouldn't break other things.

@sebastianbergmann
Copy link
Owner

Superseded by #3911.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants