3
* This file is part of PHPUnit.
5
* (c) Sebastian Bergmann <sebastian@phpunit.de>
7
* For the full copyright and license information, please view the LICENSE
8
* file that was distributed with this source code.
12
* Tests for the BankAccount class.
15
* @author Sebastian Bergmann <sebastian@phpunit.de>
16
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
17
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
18
* @link http://www.phpunit.de/
19
* @since Class available since Release 2.3.0
21
class BankAccountWithCustomExtensionTest extends PHPUnit_Framework_TestCase
25
protected function setUp()
27
$this->ba = new BankAccount;
31
* @covers BankAccount::getBalance
32
* @group balanceIsInitiallyZero
33
* @group specification
35
public function testBalanceIsInitiallyZero()
37
$this->assertEquals(0, $this->ba->getBalance());
41
* @covers BankAccount::withdrawMoney
42
* @group balanceCannotBecomeNegative
43
* @group specification
45
public function testBalanceCannotBecomeNegative()
48
$this->ba->withdrawMoney(1);
49
} catch (BankAccountException $e) {
50
$this->assertEquals(0, $this->ba->getBalance());
59
* @covers BankAccount::depositMoney
60
* @group balanceCannotBecomeNegative
61
* @group specification
63
public function testBalanceCannotBecomeNegative2()
66
$this->ba->depositMoney(-1);
67
} catch (BankAccountException $e) {
68
$this->assertEquals(0, $this->ba->getBalance());
77
* @covers BankAccount::getBalance
78
* @covers BankAccount::depositMoney
79
* @covers BankAccount::withdrawMoney
80
* @group balanceCannotBecomeNegative
83
public function testDepositingAndWithdrawingMoneyWorks()
85
$this->assertEquals(0, $this->ba->getBalance());
86
$this->ba->depositMoney(1);
87
$this->assertEquals(1, $this->ba->getBalance());
88
$this->ba->withdrawMoney(1);
89
$this->assertEquals(0, $this->ba->getBalance());