xampp+CakePHP2.x+PHPUnit

CakePHPの導入を決めたのもユニットテスト環境の構築を
考えてのこと。
テストは重要ですよ、皆さん。
xreaサーバにpearやPHPUnitをインストールするのはなんだか
タイヘンそうなので、とりあえずローカルPCで環境を構築します。

CakePHP 2.x テスト Cookbook 2.x
http://book.cakephp.org/2.0/ja/development/testing.html

第三章 PHPUnitのインストール PHPUnitマニュアル
http://phpunit.de/manual/3.7/ja/installation.html

あれでも何か変ですよ?

Warning: include(Cake/bootstrap.php) [function.include]: failed to open stream: No such file or directory in /(MyAppURL)/app/webroot/test.php on line 80

Warning: include() [function.include]: Failed opening 'Cake/bootstrap.php' for inclusion (include_path='/(MyAppURL)/lib:.:/usr/local/lib/php') in /(MyAppURL)/app/webroot/test.php on line 80

Fatal error: CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your /cake core directory and your /vendors root directory. in /(MyAppURL)/app/webroot/test.php on line 89

どうやらライブラリの参照に失敗しているようです。
定数の設定が適当じゃないのは、例によって「複数のアプリケーションから一つのCakePHPを使用する」のせいみたい。

/(MyAppURL)/app/webroot/test.phpで定義している
定数 CAKE_CORE_INCLUDE_PATHを以下設定に変更したら
ユニットテストのサンプルを動かすことに成功!!

// modified by zummy 20140414
//define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
define('CAKE_CORE_INCLUDE_PATH', dirname(ROOT) . DS . 'lib');

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です