Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2012 14:28
Show Gist options
  • Save anonymous/4353149 to your computer and use it in GitHub Desktop.
Save anonymous/4353149 to your computer and use it in GitHub Desktop.
<?php
namespace foo {
interface client
{
public function execute($query, array $params);
}
class api
{
protected $client;
public function __construct(client $client)
{
$this->client = $client;
}
public function doSomething($query)
{
$datas = $this->client->execute($query, array('foo' => 'bar'));
return true;
}
}
}
namespace tests\units\foo {
use mageekguy\atoum as atoum;
use foo\api as testedClass;
class api extends atoum\test
{
public function testdoSomething()
{
$this
->if($client = new \mock\foo\client())
->and($client->getMockController()->execute = array(42))
->and($api = new testedClass($client))
->then
->boolean($api->doSomething('str'))->isTrue()
->mock($client)
->call('execute')->withArguments('some query')->once()
->boolean($api->doSomething('some query'))->isTrue()
;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment