Files
w4rpservices/vendor/phpunit/phpunit/tests/_files/BankAccountTest2.php
2018-10-15 00:37:28 -05:00

57 lines
1.1 KiB
PHP

<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use PHPUnit\Framework\TestCase;
class BankAccountTest extends TestCase
{
private $ba;
protected function setUp(): void
{
$this->ba = new BankAccount;
}
public function testBalanceIsInitiallyZero(): void
{
$ba = new BankAccount;
$balance = $ba->getBalance();
$this->assertEquals(0, $balance);
}
public function testBalanceCannotBecomeNegative(): void
{
try {
$this->ba->withdrawMoney(1);
} catch (BankAccountException $e) {
$this->assertEquals(0, $this->ba->getBalance());
return;
}
$this->fail();
}
public function testBalanceCannotBecomeNegative2(): void
{
try {
$this->ba->depositMoney(-1);
} catch (BankAccountException $e) {
$this->assertEquals(0, $this->ba->getBalance());
return;
}
$this->fail();
}
}