オレオレmvc に PHPUnit を適用する

そんな訳で、オレオレmvc に PHPUnit を使ってみます。
ま、オレオレ mvc はちょっとパワーアップして CakePHP 風なレイアウトとデバッグ表示に。

oreoraMVC ってことで、基本カラーはオレンジ…と言いますか、実は chocolate 色。
実行クエリなんかも表示されます。

テストケースは、こんな感じで書いていこうかなと。

[code lang=”php”]
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . ‘..’);
require_once(‘lib/config.php’);
require_once ‘controllers/categories_controller.php’;

class TestCategoriesController extends PHPUnit_Framework_TestCase
{
public function testNewIndex()
{
$controller = new CategoriesController();
$controller->index();
global $Categories;
$this->assertEquals(19,sizeof($Categories));

$this->assertEquals(1,$Categories[0][‘Category’][‘term_id’]);
$this->assertEquals("blog",$Categories[0][‘Category’][‘slug’]);
$this->assertEquals("ブログ",$Categories[0][‘Category’][‘name’]);
}
}
?>
[/code]

ほら、なんかそれっぽくなっているのが不思議。oreoreMVC はもうちょっとしたら、再度公開します。

カテゴリー: CakePHP, xUnit パーマリンク