Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

docteurklein commented Jun 6, 2013

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

@docteurklein

This comment has been minimized.

Copy link

docteurklein commented Jun 6, 2013

I think phpunit is more clear.

@docteurklein

This comment has been minimized.

Copy link

docteurklein commented Jun 6, 2013

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

@pjedrzejewski

This comment has been minimized.

Copy link

pjedrzejewski commented Jun 6, 2013

@everzet

This comment has been minimized.

Copy link

everzet commented Jun 6, 2013

@hurty

This comment has been minimized.

Copy link

hurty commented Jun 6, 2013

the clearEST

@docteurklein

This comment has been minimized.

Copy link

docteurklein commented Jun 7, 2013

:D i love trolling.

@gquemener

This comment has been minimized.

Copy link
Owner Author

gquemener commented Jun 7, 2013

oh you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.