gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

BankAccountTest.php (1506B)


      1 <?php
      2 require_once 'BankAccount.php';
      3 
      4 class BankAccountTest extends PHPUnit_Framework_TestCase
      5 {
      6     protected $ba;
      7 
      8     protected function setUp()
      9     {
     10         $this->ba = new BankAccount;
     11     }
     12 
     13     /**
     14      * @covers BankAccount::getBalance
     15      */
     16     public function testBalanceIsInitiallyZero()
     17     {
     18         $this->assertEquals(0, $this->ba->getBalance());
     19     }
     20 
     21     /**
     22      * @covers BankAccount::withdrawMoney
     23      */
     24     public function testBalanceCannotBecomeNegative()
     25     {
     26         try {
     27             $this->ba->withdrawMoney(1);
     28         }
     29 
     30         catch (RuntimeException $e) {
     31             $this->assertEquals(0, $this->ba->getBalance());
     32 
     33             return;
     34         }
     35 
     36         $this->fail();
     37     }
     38 
     39     /**
     40      * @covers BankAccount::depositMoney
     41      */
     42     public function testBalanceCannotBecomeNegative2()
     43     {
     44         try {
     45             $this->ba->depositMoney(-1);
     46         }
     47 
     48         catch (RuntimeException $e) {
     49             $this->assertEquals(0, $this->ba->getBalance());
     50 
     51             return;
     52         }
     53 
     54         $this->fail();
     55     }
     56 
     57     /**
     58      * @covers BankAccount::getBalance
     59      * @covers BankAccount::depositMoney
     60      * @covers BankAccount::withdrawMoney
     61      */
     62     public function testDepositWithdrawMoney()
     63     {
     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());
     69     }
     70 }