Yaffs site version 1.1
[yaffs-website] / vendor / phpunit / phpunit / tests / _files / BankAccountTest.php
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  * @since      Class available since Release 2.3.0
15  */
16 class BankAccountTest extends PHPUnit_Framework_TestCase
17 {
18     protected $ba;
19
20     protected function setUp()
21     {
22         $this->ba = new BankAccount;
23     }
24
25     /**
26      * @covers BankAccount::getBalance
27      * @group balanceIsInitiallyZero
28      * @group specification
29      */
30     public function testBalanceIsInitiallyZero()
31     {
32         $this->assertEquals(0, $this->ba->getBalance());
33     }
34
35     /**
36      * @covers BankAccount::withdrawMoney
37      * @group balanceCannotBecomeNegative
38      * @group specification
39      */
40     public function testBalanceCannotBecomeNegative()
41     {
42         try {
43             $this->ba->withdrawMoney(1);
44         } catch (BankAccountException $e) {
45             $this->assertEquals(0, $this->ba->getBalance());
46
47             return;
48         }
49
50         $this->fail();
51     }
52
53     /**
54      * @covers BankAccount::depositMoney
55      * @group balanceCannotBecomeNegative
56      * @group specification
57      */
58     public function testBalanceCannotBecomeNegative2()
59     {
60         try {
61             $this->ba->depositMoney(-1);
62         } catch (BankAccountException $e) {
63             $this->assertEquals(0, $this->ba->getBalance());
64
65             return;
66         }
67
68         $this->fail();
69     }
70
71     /*
72      * @covers BankAccount::getBalance
73      * @covers BankAccount::depositMoney
74      * @covers BankAccount::withdrawMoney
75      * @group balanceCannotBecomeNegative
76      */
77     /*
78     public function testDepositingAndWithdrawingMoneyWorks()
79     {
80         $this->assertEquals(0, $this->ba->getBalance());
81         $this->ba->depositMoney(1);
82         $this->assertEquals(1, $this->ba->getBalance());
83         $this->ba->withdrawMoney(1);
84         $this->assertEquals(0, $this->ba->getBalance());
85     }
86     */
87 }