~tcuthbert/wordpress/openstack-objectstorage

« back to all changes in this revision

Viewing changes to vendor/phpunit/phpunit/tests/_files/BankAccountTest.test.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * @package    PHPUnit
 
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
 
20
 */
 
21
class BankAccountWithCustomExtensionTest extends PHPUnit_Framework_TestCase
 
22
{
 
23
    protected $ba;
 
24
 
 
25
    protected function setUp()
 
26
    {
 
27
        $this->ba = new BankAccount;
 
28
    }
 
29
 
 
30
    /**
 
31
     * @covers BankAccount::getBalance
 
32
     * @group balanceIsInitiallyZero
 
33
     * @group specification
 
34
     */
 
35
    public function testBalanceIsInitiallyZero()
 
36
    {
 
37
        $this->assertEquals(0, $this->ba->getBalance());
 
38
    }
 
39
 
 
40
    /**
 
41
     * @covers BankAccount::withdrawMoney
 
42
     * @group balanceCannotBecomeNegative
 
43
     * @group specification
 
44
     */
 
45
    public function testBalanceCannotBecomeNegative()
 
46
    {
 
47
        try {
 
48
            $this->ba->withdrawMoney(1);
 
49
        } catch (BankAccountException $e) {
 
50
            $this->assertEquals(0, $this->ba->getBalance());
 
51
 
 
52
            return;
 
53
        }
 
54
 
 
55
        $this->fail();
 
56
    }
 
57
 
 
58
    /**
 
59
     * @covers BankAccount::depositMoney
 
60
     * @group balanceCannotBecomeNegative
 
61
     * @group specification
 
62
     */
 
63
    public function testBalanceCannotBecomeNegative2()
 
64
    {
 
65
        try {
 
66
            $this->ba->depositMoney(-1);
 
67
        } catch (BankAccountException $e) {
 
68
            $this->assertEquals(0, $this->ba->getBalance());
 
69
 
 
70
            return;
 
71
        }
 
72
 
 
73
        $this->fail();
 
74
    }
 
75
 
 
76
    /**
 
77
     * @covers BankAccount::getBalance
 
78
     * @covers BankAccount::depositMoney
 
79
     * @covers BankAccount::withdrawMoney
 
80
     * @group balanceCannotBecomeNegative
 
81
     */
 
82
    /*
 
83
    public function testDepositingAndWithdrawingMoneyWorks()
 
84
    {
 
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());
 
90
    }
 
91
    */
 
92
}