-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BankAccount example to TheCure. Also add unit tests for the code.
- Loading branch information
1 parent
f5ccf9d
commit 4543151
Showing
4 changed files
with
137 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
class ModelBankAccountTest extends PHPUnit_Framework_TestCase { | ||
|
||
public function provideBankAccounts() | ||
{ | ||
return array( | ||
array(new Models\BankAccount, new Models\BankAccount), | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider provideBankAccounts | ||
*/ | ||
public function testItShouldTransferMoneyFromOneAccountToAnother( | ||
$lukesAccount, | ||
$bobsAccount) | ||
{ | ||
$lukesAccount->__object()->balance = 100; | ||
$bobsAccount->__object()->balance = 0; | ||
|
||
$lukesAccount->transfer_money($bobsAccount, 100); | ||
|
||
$this->assertSame(0, $lukesAccount->__object()->balance); | ||
$this->assertSame(100, $bobsAccount->__object()->balance); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Models; | ||
|
||
class BankAccount extends \Gignite\TheCure\Models\Model { | ||
|
||
public function transfer_money(BankAccount $account, $amount) | ||
{ | ||
$this->__object()->balance -= $amount; | ||
$account->__object()->balance += $amount; | ||
} | ||
|
||
} |