I love iPhone, Android, Cocos2d-x
Posts tagged assert
CakePHP1.2 SimpleTest でコントローラのテストケースを作成
1CakePHP1.2 SimpleTest でテストケースを作成する ではモデルのテストケースを作成したので今度はコントローラのテストケースを作成してみました。
コントローラのテストケースは app/tests/case/conrollers 以下に作成します。
app/tests/case/conrollers/user_controller.test.php
<?php
class UsersControllerTestCase extends CakeTestCase {
function testIndexTitle() {
$result = $this->testAction('/users/index', array('return'=>'render'));
$this->assertPattern("/<title>TITLE<\/title>/", $result);
}
function testIndexSet() {
$result = $this->testAction('/users/index', array('return'=>'vars'));
$this->assertTrue(isset($result["users"]));
}
}
?>
CakePHP1.2 SimpleTest 値を検証する assert?メソッド
2SimpleTest で使用する値を検証する assert?メソッド
assertTure
boolean assertTrue(boolean $result, [string $message])
$result が true か
(続きを読む…)
CakePHP1.2 SimpleTest でテストケースを作成する
6CakePHP1.2 に SimpleTest をインストール で SimpleTest をインストールするところまでやったので、今度は実際にテストケースを作成してみます。
空のテストケースを作成する
app/test/cases/models に user.test.php を作成して以下のコードで保存する。
<?php
class UserTest extends User {
}
?>