Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipobenito/1dd8b64e542567c28ffec216534fca37 to your computer and use it in GitHub Desktop.
Save philipobenito/1dd8b64e542567c28ffec216534fca37 to your computer and use it in GitHub Desktop.
<?php
class FooTest extends PHPUnit_Framework_Testcase
{
public function testDoSomethingEditsDataAndReturnsArray()
{
$foo = new Foo;
$user = [
'name' => 'Phil',
'email' => 'hello@example.com'
];
$stubBar = $this->getMock('Bar');
$stubBar->expects($this->any())
->method('editAndReturnUser')
->will($this->returnValue($user));
$foo->doSomething($stubBar, 1, 'Phil', 'hello@example.com');
$this->assertInternalType('array', $user, 'The return of (doSomething) was not an array');
$this->assertSame($user['name'], 'Phil', 'The returned user name was not as expected');
$this->assertSame($user['email'], 'hello@example.com', 'The returned user email was not as expected');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment