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

Strange behavior after update to 0.7.0 #21

Closed
dmitrybelyakov opened this issue Apr 5, 2011 · 5 comments
Closed

Strange behavior after update to 0.7.0 #21

dmitrybelyakov opened this issue Apr 5, 2011 · 5 comments

Comments

@dmitrybelyakov
Copy link

Hi, Pádraic.

Today I've updated mockery to the latest from githib that is 0.7.0 and discivered some strange bahevior - all my tests are suddenly failing with some strange message when tearDown() is done.

Here's the message:

  1. MessageService_Cache_SaveTest::testCanClearThreadMessagesCacheByTag
    BadMethodCallException: Method RequestScope::__isset() does not exist on this mock object

And the call stack:

/library/Mockery/Container.php:197
/library/Mockery/Container.php:182
/library/Mockery.php:71
/library/Shift/Test/Case.php:172

The problem appears to be related to the mocked class having an __isset() method. But that was fine in previous Mockery versions...

I'm going to revert back to previous version for now.
Please tell me if I can give you any firther informstion on this issue.

Dmitry.

@padraic
Copy link
Member

padraic commented Apr 5, 2011

You're right that mocked classes now feature an __isset() method. 0.7 uses it for public property mocking.

Do you have an actual test case and the relevant class I can use to replicate the issue? If I follow what you are mocking, and how, I'll be able to diagnose the problem.

@dmitrybelyakov
Copy link
Author

Hi and thanks for quick response.
I've composed two files to reproduce issue, that are quite straightforward. Let's assume we do all the application bootstrapping and Mockery setup in test case superclass.

The class itself

class Test_Magic
{
protected $_properties = array();

public function __construct()
{
}

public function __isset($property=null)
{
    return isset($this->_properties[$property]);
}

}

And a test:

class Test_MagicTest extends Shift_Test_Case
{
public function setUp()
{
parent::setUp();
$this->appBootstrap();
}

public function testIsset()
{
    $form = Mockery::mock('Zend_Form');
    $mock = Mockery::mock('Test_Magic');
}

}

This throws the BadMethodCallException: Method Test_Magic::__isset() does not exist on this mock object
When test reaches tearDown().

Please let me now if I can provide any further info or assis in any way.

@dmitrybelyakov
Copy link
Author

Please excuse github markdown

@padraic
Copy link
Member

padraic commented Apr 5, 2011

Thanks for that. I've committed a small patch to exclude __isset() from being replaced. That seems to resolve the exception. Let me know if the git master is now running clean for you.

@dmitrybelyakov
Copy link
Author

Yes, that did it. Now everything is back to normal. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants