今回は、PHPUnit3の便利な機能とPHP版プロジェクトビルドシステムであるPhingとの連携について見ていきます。 既存クラスからテストを作成する さて、別の開発チームで作成していた決済用クラス(Checkoutクラス)が届きました。 <?php require_once 'Cart.php'; class Checkout { private $cart; public function __construct(Cart $cart) { $this->cart = $cart; } public function getSubTotal() { return $this->cart->getTotal(); } public function getShippingCharge() { if ($this->cart->getTotal() > 1500) { return 0;
![第5回 PHPUnitの便利な機能とPhingとの連携 | gihyo.jp](https://cdn-ak-scissors.b.st-hatena.com/image/square/166fab904765a9d5a9e93a0b7310be3ad39166d6/height=288;version=1;width=512/https%3A%2F%2Fgihyo.jp%2Fassets%2Fimages%2FICON%2F2007%2F077_phpunit.png)