0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHP 5.6 と FuelPHP で aspect-mock を使う時の設定

Posted at

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使えるかどうかの確認方法

  1. FuelPHPのプロジェクトを作成
  2. composerのパッケージをインストール
  3. config.php の TimeZoneを設定
  4. php oil config g configでoilのconfigファイルを作成
  5. config/oil.php の中で、phpunitのbinary_pathをvendor/bin/phpunitに変更
  6. fuel/core/phpunit.xml を fuel/app/phpunit.xml にコピーして、backupGlobals="false"を設定
  7. php oil testを実行して、テストが実行されるかどうか
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?