-
-
Save everzet/5722238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//PHPUnit | |
public function testApply() { | |
$mock = $this->getMock('My\Foo\Class', array('apply')); | |
$mock->expects($this->any()) | |
->method('apply') | |
->with('foo') | |
->will($this->returnValue('bar')); | |
$target = new My\Bar\Class($mock); | |
$this->assertEquals('bar', $target->apply('foo')); | |
} | |
//PhpSpec2/Prophecy | |
function let(\My\Foo\Class $foo) { | |
$this->beConstructedWith($foo); | |
} | |
function it_applies_foo_modificator($foo) { | |
$foo->apply('foo')->willReturn('bar'); | |
$this->apply('foo')->shouldReturn('bar'); | |
} |
<?php
// PHPUnit 4.0
public function testApply() {
$mock = $this->getMock('My\Foo\Class', array('apply'));
$mock->method('apply')->with('foo')->willReturn('bar');
$target = new My\Bar\Class($mock);
$this->assertEquals('bar', $target->apply('foo'));
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@whatthejeff you're right! Fixed.