CentOS 7.4 上で、PHP 5.6 + FuelPHP 1.8.6 のプロジェクトで、aspect-mock を使って開発をする時は、codeception/aspect-mock のバージョンを1.*にすること。
composer.json
(snip)
"require-dev": {
"codeception/aspect-mock": "1.*"
"phpunit/phpunit": "^5.7",
},
(snip)
バージョンを指定せずに
$ php composer.phar require --dev codeception/aspect-mock phpunit/phpunit
をすると、以下のようなバージョンがインストールされる
"require-dev": {
"codeception/aspect-mock": "^2.2",
"phpunit/phpunit": "^5.7"
},
結果、以下のようなエラーが発生する。
[vagrant@localhost cleanfuel]$ php oil test;
Tests Running...This may take a few moments.
PHP Notice: Constant DS already defined in /home/vagrant/cleanfuel/fuel/core/bootstrap.php on line 13
PHP Notice: Constant CRLF already defined in /home/vagrant/cleanfuel/fuel/core/bootstrap.php on line 14
Notice: Constant DS already defined in /home/vagrant/cleanfuel/fuel/core/bootstrap.php on line 13
Notice: Constant CRLF already defined in /home/vagrant/cleanfuel/fuel/core/bootstrap.php on line 14
PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Class FuelException was not found by locator' in /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionEngine.php:125
Stack trace:
# 0 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionEngine.php(140): Go\ParserReflection\ReflectionEngine::locateClassFile('FuelException')
# 1 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionClass.php(44): Go\ParserReflection\ReflectionEngine::parseClass('FuelException')
# 2 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionClass.php(150): Go\ParserReflection\ReflectionClass->__construct('FuelException')
# 3 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php(446): Go\ParserReflection\ReflectionClass->createReflectionForClass('FuelException')
# 4 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php(924): Go\ParserReflection\ReflectionClas in /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionEngine.php on line 125
PHP Fatal error: Class 'Config' not found in /home/vagrant/cleanfuel/fuel/core/classes/fuel.php on line 423
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Class FuelException was not found by locator' in /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionEngine.php:125
Stack trace:
# 0 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionEngine.php(140): Go\ParserReflection\ReflectionEngine::locateClassFile('FuelException')
# 1 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionClass.php(44): Go\ParserReflection\ReflectionEngine::parseClass('FuelException')
# 2 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionClass.php(150): Go\ParserReflection\ReflectionClass->__construct('FuelException')
# 3 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php(446): Go\ParserReflection\ReflectionClass->createReflectionForClass('FuelException')
# 4 /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php(924): Go\ParserReflection\ReflectionClas in /home/vagrant/cleanfuel/fuel/vendor/goaop/parser-reflection/src/ReflectionEngine.php on line 125
Fatal error: Class 'Config' not found in /home/vagrant/cleanfuel/fuel/core/classes/fuel.php on line 423
Aspect-mock使えるかどうかの確認方法
- FuelPHPのプロジェクトを作成
- composerのパッケージをインストール
- config.php の TimeZoneを設定
-
php oil config g config
でoilのconfigファイルを作成 - config/oil.php の中で、phpunitのbinary_pathを
vendor/bin/phpunit
に変更 - fuel/core/phpunit.xml を fuel/app/phpunit.xml にコピーして、
backupGlobals="false"
を設定 -
php oil test
を実行して、テストが実行されるかどうか