Created
November 17, 2016 15:05
-
-
Save philipobenito/14a207fd00cc76ac5fed614d436169c3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
class FakeBar | |
{ | |
public $users = [ | |
1 => [ | |
'name' => 'Adam', | |
'email' => '[email protected]' | |
] | |
]; | |
public function editAndReturnUser($id, $name, $email) | |
{ | |
$this->users[$id]['name'] = $name; | |
$this->users[$id]['email'] = $email; | |
return $this->users[$id]; | |
} | |
} | |
class TestFoo extends PHPUnit_Framework_Testcase | |
{ | |
public function testDoSomethingEditsDataAndReturnsArray() | |
{ | |
$foo = new Foo; | |
$fakeBar = new FakeBar; | |
$user = $foo->doSomething($fakeBar, 1, 'Phil', '[email protected]'); | |
$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'], '[email protected]', 'The returned user email was not as expected'); | |
// verify that the state of FakeBar has changed | |
$this->assertSame($fakeBar->users['name'], 'Phil', 'The user name in FakeBar was not changed'); | |
$this->assertSame($fakeBar->users['email'], '[email protected]'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment