Skip to content

Instantly share code, notes, and snippets.

@gquemener
Last active December 18, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gquemener/5722064 to your computer and use it in GitHub Desktop.
Save gquemener/5722064 to your computer and use it in GitHub Desktop.
Which one is the clearest?
<?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
/**
* @param My\Foo\Class $foo
*/
function it_should_apply_foo_modificator($foo) {
$this->beConstructedWith($foo);
$foo->apply(Argument::exact('foo'))->willReturn('bar');
$this->apply('foo')->shouldReturn('bar');
}
@docteurklein
Copy link

you can even shorten your example by merging the let method with the example one.

@docteurklein
Copy link

I think phpunit is more clear.

@docteurklein
Copy link

you forget the <?php. It's dirty.

@pjedrzejewski
Copy link

@everzet
Copy link

everzet commented Jun 6, 2013

@hurty
Copy link

hurty commented Jun 6, 2013

the clearEST

@docteurklein
Copy link

:D i love trolling.

@gquemener
Copy link
Author

oh you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment