Skip to content
This repository was archived by the owner on Feb 20, 2023. It is now read-only.
This repository was archived by the owner on Feb 20, 2023. It is now read-only.

Mocking undeclared methods impossible since 1.0.4 #35

@sebastianbergmann

Description

@sebastianbergmann

Example

<?php
class Foo
{
}

class Test extends PHPUnit_Framework_TestCase
{
    public function testStubbingUndeclaredMethodsWorks()
    {
        $stub = $this->getMock('Foo', array('bar'));

        $stub->expects($this->any())
             ->method('bar')
             ->with($this->equalTo('baz'))
             ->will($this->returnValue('foobarbaz'));

        $this->assertEquals('foobarbaz', $stub->bar('baz'));
    }
}

Actual Output

sb@vmware ~ % phpunit Test
PHPUnit @package_version@ by Sebastian Bergmann.

F

Time: 0 seconds, Memory: 4.25Mb

There was 1 failure:

1) Test::testStubbingUndeclaredMethodsWorks
Expectation failed for method name is equal to <string:bar> when invoked zero or more times
Parameter count for invocation Foo::bar() is too low.

/usr/local/src/phpunit-mock-objects/PHPUnit/Framework/MockObject/Matcher.php:180
/usr/local/src/phpunit-mock-objects/PHPUnit/Framework/MockObject/InvocationMocker.php:138
/home/sb/Test.php:17

FAILURES!
Tests: 1, Assertions: 0, Failures: 1.

Expected Output

sb@vmware ~ % phpunit Test
PHPUnit @package_version@ by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 4.25Mb

OK (1 test, 2 assertions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions