cvs: pear /PHPUnit2/Samples/BankAccount BankAccount.php BankAccountTest.php /PHPUnit2/Samples/Money IMoney.php Money.php MoneyBag.php MoneyTest.php

From: Date: Mon, 11 Apr 2005 07:21:56 +0000
Subject: cvs: pear /PHPUnit2/Samples/BankAccount BankAccount.php BankAccountTest.php /PHPUnit2/Samples/Money IMoney.php Money.php MoneyBag.php MoneyTest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-31096@lists.php.net to get a copy of this message
sebastian Mon Apr 11 03:21:56 2005 EDT Modified files: /pear/PHPUnit2/Samples/BankAccount BankAccount.php BankAccountTest.php /pear/PHPUnit2/Samples/Money IMoney.php Money.php MoneyBag.php MoneyTest.php Log: Adopt new code formatting standard.

http://cvs.php.net/diff.php/pear/PHPUnit2/Samples/BankAccount/BankAccount.php?r1=1.2&r2=1.3&ty=u Index: pear/PHPUnit2/Samples/BankAccount/BankAccount.php diff -u pear/PHPUnit2/Samples/BankAccount/BankAccount.php:1.2 pear/PHPUnit2/Samples/BankAccount/BankAccount.php:1.3 --- pear/PHPUnit2/Samples/BankAccount/BankAccount.php:1.2 Sun Mar 20 03:08:03 2005 +++ pear/PHPUnit2/Samples/BankAccount/BankAccount.php Mon Apr 11 03:21:56 2005 @@ -1,33 +1,75 @@ <?php -// -// +------------------------------------------------------------------------+ -// | PEAR :: PHPUnit2 | -// +------------------------------------------------------------------------+ -// | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +------------------------------------------------------------------------+ -// -// $Id: BankAccount.php,v 1.2 2005/03/20 08:08:03 sebastian Exp $ -// +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * PHP Version 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: BankAccount.php,v 1.3 2005/04/11 07:21:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +/** + * A Bank Account. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.3.0 + */ class BankAccount { + /** + * The bank account's balance. + * + * @var float + * @access private + */ private $balance = 0; + /** + * Returns the bank account's balance. + * + * @return float + * @access public + */ public function getBalance() { return $this->balance; } + /** + * Sets the bank account's balance. + * + * @param float $balance + * @access public + */ public function setBalance($balance) { - if ($balance >= 0) { + if (is_numeric($amount) && + $amount >= 0) { $this->balance = $balance; } } + /** + * Deposits an amount of money to the bank account. + * + * @param float $balance + * @access public + */ public function depositMoney($amount) { if (is_numeric($amount) && $amount >= 0) { @@ -35,6 +77,12 @@ } } + /** + * Withdraws an amount of money from the bank account. + * + * @param float $balance + * @access public + */ public function withdrawMoney($amount) { if (is_numeric($amount) && $amount >= 0 && @@ -45,7 +93,10 @@ } /* - * vim600: et sw=2 ts=2 fdm=marker - * vim<600: et sw=2 ts=2 + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: */ ?> http://cvs.php.net/diff.php/pear/PHPUnit2/Samples/BankAccount/BankAccountTest.php?r1=1.1&r2=1.2&ty=u Index: pear/PHPUnit2/Samples/BankAccount/BankAccountTest.php diff -u pear/PHPUnit2/Samples/BankAccount/BankAccountTest.php:1.1 pear/PHPUnit2/Samples/BankAccount/BankAccountTest.php:1.2 --- pear/PHPUnit2/Samples/BankAccount/BankAccountTest.php:1.1 Sun Mar 20 03:06:28 2005 +++ pear/PHPUnit2/Samples/BankAccount/BankAccountTest.php Mon Apr 11 03:21:56 2005 @@ -1,45 +1,89 @@ <?php -// -// +------------------------------------------------------------------------+ -// | PEAR :: PHPUnit2 | -// +------------------------------------------------------------------------+ -// | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +------------------------------------------------------------------------+ -// -// $Id: BankAccountTest.php,v 1.1 2005/03/20 08:06:28 sebastian Exp $ -// +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: BankAccountTest.php,v 1.2 2005/04/11 07:21:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ require_once 'PHPUnit2/Framework/TestCase.php'; require_once 'BankAccount.php'; +/** + * Tests for the BankAccount class. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.3.0 + */ class BankAccountTest extends PHPUnit2_Framework_TestCase { + /** + * BankAccount object used as the tests' fixture. + * + * @var BankAccount + * @access private + */ private $ba; + /** + * Sets up the test fixture. + * + * @access protected + */ protected function setUp() { $this->ba = new BankAccount; } + /** + * Asserts that the balance is initially zero. + * + * @access public + */ public function testBalanceIsInitiallyZero() { $this->assertEquals(0, $this->ba->getBalance()); } + /** + * Asserts that the balance cannot become negative. + * + * @access public + */ public function testBalanceCannotBecomeNegative() { $this->ba->withdrawMoney(1); $this->assertEquals(0, $this->ba->getBalance()); + $this->ba->depositMoney(-1); + $this->assertEquals(0, $this->ba->getBalance()); + $this->ba->setBalance(-1); $this->assertEquals(0, $this->ba->getBalance()); } } /* - * vim600: et sw=2 ts=2 fdm=marker - * vim<600: et sw=2 ts=2 + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: */ ?> http://cvs.php.net/diff.php/pear/PHPUnit2/Samples/Money/IMoney.php?r1=1.1&r2=1.2&ty=u Index: pear/PHPUnit2/Samples/Money/IMoney.php diff -u pear/PHPUnit2/Samples/Money/IMoney.php:1.1 pear/PHPUnit2/Samples/Money/IMoney.php:1.2 --- pear/PHPUnit2/Samples/Money/IMoney.php:1.1 Fri Mar 18 04:12:56 2005 +++ pear/PHPUnit2/Samples/Money/IMoney.php Mon Apr 11 03:21:56 2005 @@ -1,23 +1,40 @@ <?php -// -// +------------------------------------------------------------------------+ -// | PEAR :: PHPUnit2 | -// +------------------------------------------------------------------------+ -// | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +------------------------------------------------------------------------+ -// -// $Id: IMoney.php,v 1.1 2005/03/18 09:12:56 sebastian Exp $ -// +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: IMoney.php,v 1.2 2005/04/11 07:21:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ require_once 'Money.php'; require_once 'MoneyBag.php'; +/** + * Money Interface. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.3.0 + */ interface IMoney { public function add(IMoney $m); public function addMoney(Money $m); @@ -30,7 +47,10 @@ } /* - * vim600: et sw=2 ts=2 fdm=marker - * vim<600: et sw=2 ts=2 + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: */ ?> http://cvs.php.net/diff.php/pear/PHPUnit2/Samples/Money/Money.php?r1=1.1&r2=1.2&ty=u Index: pear/PHPUnit2/Samples/Money/Money.php diff -u pear/PHPUnit2/Samples/Money/Money.php:1.1 pear/PHPUnit2/Samples/Money/Money.php:1.2 --- pear/PHPUnit2/Samples/Money/Money.php:1.1 Fri Mar 18 04:12:56 2005 +++ pear/PHPUnit2/Samples/Money/Money.php Mon Apr 11 03:21:56 2005 @@ -1,22 +1,39 @@ <?php -// -// +------------------------------------------------------------------------+ -// | PEAR :: PHPUnit2 | -// +------------------------------------------------------------------------+ -// | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +------------------------------------------------------------------------+ -// -// $Id: Money.php,v 1.1 2005/03/18 09:12:56 sebastian Exp $ -// +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: Money.php,v 1.2 2005/04/11 07:21:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ require_once 'IMoney.php'; +/** + * A Money. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.3.0 + */ class Money implements IMoney { private $fAmount; private $fCurrency; @@ -94,7 +111,10 @@ } /* - * vim600: et sw=2 ts=2 fdm=marker - * vim<600: et sw=2 ts=2 + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: */ ?> http://cvs.php.net/diff.php/pear/PHPUnit2/Samples/Money/MoneyBag.php?r1=1.1&r2=1.2&ty=u Index: pear/PHPUnit2/Samples/Money/MoneyBag.php diff -u pear/PHPUnit2/Samples/Money/MoneyBag.php:1.1 pear/PHPUnit2/Samples/Money/MoneyBag.php:1.2 --- pear/PHPUnit2/Samples/Money/MoneyBag.php:1.1 Fri Mar 18 04:12:56 2005 +++ pear/PHPUnit2/Samples/Money/MoneyBag.php Mon Apr 11 03:21:56 2005 @@ -1,23 +1,40 @@ <?php -// -// +------------------------------------------------------------------------+ -// | PEAR :: PHPUnit2 | -// +------------------------------------------------------------------------+ -// | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +------------------------------------------------------------------------+ -// -// $Id: MoneyBag.php,v 1.1 2005/03/18 09:12:56 sebastian Exp $ -// +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: MoneyBag.php,v 1.2 2005/04/11 07:21:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ require_once 'IMoney.php'; require_once 'Money.php'; +/** + * A MoneyBag. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.3.0 + */ class MoneyBag implements IMoney { private $fMonies = array(); @@ -188,7 +205,10 @@ } /* - * vim600: et sw=2 ts=2 fdm=marker - * vim<600: et sw=2 ts=2 + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: */ ?> http://cvs.php.net/diff.php/pear/PHPUnit2/Samples/Money/MoneyTest.php?r1=1.1&r2=1.2&ty=u Index: pear/PHPUnit2/Samples/Money/MoneyTest.php diff -u pear/PHPUnit2/Samples/Money/MoneyTest.php:1.1 pear/PHPUnit2/Samples/Money/MoneyTest.php:1.2 --- pear/PHPUnit2/Samples/Money/MoneyTest.php:1.1 Fri Mar 18 04:12:56 2005 +++ pear/PHPUnit2/Samples/Money/MoneyTest.php Mon Apr 11 03:21:56 2005 @@ -1,25 +1,42 @@ <?php -// -// +------------------------------------------------------------------------+ -// | PEAR :: PHPUnit2 | -// +------------------------------------------------------------------------+ -// | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +------------------------------------------------------------------------+ -// -// $Id: MoneyTest.php,v 1.1 2005/03/18 09:12:56 sebastian Exp $ -// +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: MoneyTest.php,v 1.2 2005/04/11 07:21:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ require_once 'PHPUnit2/Framework/TestCase.php'; require_once 'Money.php'; require_once 'MoneyBag.php'; +/** + * Tests for the Money and MoneyBag classes. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.3.0 + */ class MoneyTest extends PHPUnit2_Framework_TestCase { private $f12EUR; private $f14EUR; @@ -182,7 +199,10 @@ } /* - * vim600: et sw=2 ts=2 fdm=marker - * vim<600: et sw=2 ts=2 + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: */ ?>
« previous php.pear.cvs (#31096) next »