1<?php
2/*
3 * This file is part of PHPUnit.
4 *
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11/**
12 * Tests for the BankAccount class.
13 *
14 */
15class BankAccountWithCustomExtensionTest extends PHPUnit_Framework_TestCase
16{
17    protected $ba;
18
19    protected function setUp()
20    {
21        $this->ba = new BankAccount;
22    }
23
24    /**
25     * @covers BankAccount::getBalance
26     * @group balanceIsInitiallyZero
27     * @group specification
28     */
29    public function testBalanceIsInitiallyZero()
30    {
31        $this->assertEquals(0, $this->ba->getBalance());
32    }
33
34    /**
35     * @covers BankAccount::withdrawMoney
36     * @group balanceCannotBecomeNegative
37     * @group specification
38     */
39    public function testBalanceCannotBecomeNegative()
40    {
41        try {
42            $this->ba->withdrawMoney(1);
43        } catch (BankAccountException $e) {
44            $this->assertEquals(0, $this->ba->getBalance());
45
46            return;
47        }
48
49        $this->fail();
50    }
51
52    /**
53     * @covers BankAccount::depositMoney
54     * @group balanceCannotBecomeNegative
55     * @group specification
56     */
57    public function testBalanceCannotBecomeNegative2()
58    {
59        try {
60            $this->ba->depositMoney(-1);
61        } catch (BankAccountException $e) {
62            $this->assertEquals(0, $this->ba->getBalance());
63
64            return;
65        }
66
67        $this->fail();
68    }
69
70    /*
71     * @covers BankAccount::getBalance
72     * @covers BankAccount::depositMoney
73     * @covers BankAccount::withdrawMoney
74     * @group balanceCannotBecomeNegative
75     */
76    /*
77    public function testDepositingAndWithdrawingMoneyWorks()
78    {
79        $this->assertEquals(0, $this->ba->getBalance());
80        $this->ba->depositMoney(1);
81        $this->assertEquals(1, $this->ba->getBalance());
82        $this->ba->withdrawMoney(1);
83        $this->assertEquals(0, $this->ba->getBalance());
84    }
85    */
86}
87