-
Notifications
You must be signed in to change notification settings - Fork 154
No longer possible to configure methods for the mock a class that does not exist #322
Comments
Classes that do not exist cannot be doubled using the new <?php
class Test extends PHPUnit\Framework\TestCase
{
public function testClassThatDoesNotExistCanBeDoubledUsingMockBuilder()
{
$o = $this->createMock('DoesNotExist');
$this->assertInstanceOf('DoesNotExist', $o);
}
}
Classes that do not exist can still be doubled using the Mock Builder API: <?php
class Test extends PHPUnit\Framework\TestCase
{
public function testClassThatDoesNotExistCanBeDoubledUsingMockBuilder()
{
$o = $this->getMockBuilder('DoesNotExist')->getMock();
$this->assertInstanceOf('DoesNotExist', $o);
}
}
What is currently broken, and what I think this ticket is about, is configuring methods for test doubles of classes that do not exist: <?php
class Test extends PHPUnit\Framework\TestCase
{
public function testClassThatDoesNotExistCanBeDoubledUsingMockBuilder()
{
$o = $this->getMockBuilder('DoesNotExist')
->setMethods(['someMethod'])
->getMock();
}
}
This is a bug that I will fix ASAP. |
Seems to be related to this change a8c81f2#diff-64dbbc1c21f9be2d92e2b715617ffe34R839 by @sawmurai for #319. |
Sorry, I failed to express it clearly but this is indeed the issue I wanted to report |
No worries, glad we figured it out now :-) |
@sawmurai Can you have a look at this, please? Thanks! |
It has a bug that makes it incompatible with the doctrine dbal test suite, see sebastianbergmann/phpunit-mock-objects#322
It has a bug that makes it incompatible with the doctrine dbal test suite, see sebastianbergmann/phpunit-mock-objects#322 Fixes doctrine#2475
It has a bug that makes it incompatible with the doctrine dbal test suite, see sebastianbergmann/phpunit-mock-objects#322 Fixes doctrine#2475
Sorry guys I was busy the entire day. Is there anything left to do? What was/is the outcome of this one? |
I think the todo list is the following:
|
As of db55f4b that test is already in |
Here you go guys. Tests now work for me. |
Apparently this test was not enough, see #324 |
They are buggy. This implies using phpunit from the vendors. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/324/files and sebastianbergmann/phpunit-mock-objects#322
@sawmurai Can you have another look, please? Thanks! |
This should help: #325 I hope that now we covered everything :) |
Thanks! |
Since 3.2.4, using
getMock
on a class that does not exist no longer allows specifying methods that should be recognized. Calling a method on such a mock results in an undefined index warning.This can be reproduced thanks to @nubs by following the steps described here : https://gist.github.com/nubs/ddb081e1d1b09541d7f7a1d93d009533
The text was updated successfully, but these errors were encountered: