2 require_once 'BankAccount.php';
4 class BankAccountTest
extends PHPUnit_Framework_TestCase
8 protected function setUp()
10 $this->ba
= new BankAccount
;
14 * @covers BankAccount::getBalance
16 public function testBalanceIsInitiallyZero()
18 $this->assertEquals(0, $this->ba
->getBalance());
22 * @covers BankAccount::withdrawMoney
24 public function testBalanceCannotBecomeNegative()
27 $this->ba
->withdrawMoney(1);
30 catch (RuntimeException
$e) {
31 $this->assertEquals(0, $this->ba
->getBalance());
40 * @covers BankAccount::depositMoney
42 public function testBalanceCannotBecomeNegative2()
45 $this->ba
->depositMoney(-1);
48 catch (RuntimeException
$e) {
49 $this->assertEquals(0, $this->ba
->getBalance());
58 * @covers BankAccount::getBalance
59 * @covers BankAccount::depositMoney
60 * @covers BankAccount::withdrawMoney
62 public function testDepositWithdrawMoney()
64 $this->assertEquals(0, $this->ba
->getBalance());
65 $this->ba
->depositMoney(1);
66 $this->assertEquals(1, $this->ba
->getBalance());
67 $this->ba
->withdrawMoney(1);
68 $this->assertEquals(0, $this->ba
->getBalance());