LoginSignup
8
6

More than 3 years have passed since last update.

EC-CUBEのCodeceptionをローカルで動かしてみる

Last updated at Posted at 2019-10-10

前提

結果

ほとんどのテストは動くようになったが、、プラグインのテストがうまく動かない。
うまくいかない場所にwaitを入れたり、タイムアウトをnoneに変更などすると動くか、試してみましたがうまくいきませんでした。
フォースが足りなかったか、ダークサイドに落ちてしまったのかもしれない。

参照にした記事

環境情報

開発環境

  • Homebrew 2.1.12
  • ChromeDriver 77.0.3865.40
  • Docker 2.0.1.3
  • PHP 7.2.20
  • Postgres 9.3
  • schickling/mailcatcher latest
  • composer 1.8.4

ポート構成

サーバー ポート
PHP Builtin Server 8000
Postgres 5432
schickling/mailcatcher 1025,1080
eccube/mock-package-api 8080

手順

コピペされる方は以下の環境変数を環境に合わせて流しておいてください

export ECCUBE_PATH=$(pwd)/ec-cube

ChromeDriverのインストール

1. caskを入れていない場合は入れておく
brew tap homebrew/cask
2. chromedriverのインストール
brew cask install chromedriver

PackageAPIのモックを設定

1. Pluginのテストに必要なPackageAPIのモックをDockerで立てておく
cd $ECCUBE_PATH
docker run -d --rm -v ${PWD}/repos:/repos -e MOCK_REPO_DIR=/repos -p 8080:8080 eccube/mock-package-api
2. .env にモックとCodeceptionの設定を追加

vi .env で以下を変更

#APP_ENV=dev
APP_ENV=codeception

vi .env で最終行に以下を追加

ECCUBE_PACKAGE_API_URL=http://127.0.0.1:8080

Codeceptionをローカルで動かすための設定

1. codeception/_envs/travis.ymlを元に設定ファイルを作成し設定する
cp codeception/_envs/travis.yml codeception/_envs/local.yml
vi codeception/_envs/local.yml
2. local.ymlを以下のように設定
modules:
    config:
        Db:
            user: 'postgres'
            password: ''
            dsn: 'pgsql:host=127.0.0.1;dbname=eccube_db'
        WebDriver:
            host: '127.0.0.1'
            port: 9515
            url: 'http://127.0.0.1:8000'
            connection_timeout: 300
            request_timeout: 300
#            capabilities:
#                chromeOptions:
#                    args: ["--headless"]
        MailCatcher:
            url: '127.0.0.1'
            port: 1080

実行してみる

1. 別のコンソールでビルトインサーバーを立ち上げておく
php -S 127.0.0.1:8000 -t EC-CUBEまでのパス
2. 別のコンソールでChromeDriverを起動しておく
chromedriver --url-base=/wd/hub
3. テストを実行
vendor/bin/codecept run -d acceptance --env chrome,local -g admin01

プラグインのテストを実施

1. 認証キーを登録する
docker exec -it ポスグレのCONTAINER_ID psql -U postgres eccube_db -c "update dtb_base_info set authentication_key='test';"
2. プラグイン関連のテストを実行
vendor/bin/codecept run -d acceptance --env chrome,local -g EA10PluginCest

データのリセット方法

  1. codeception用のシェルがそのまま使えそうなので使う
sh codeception.sh --reset
  1. 手動でやる場合は以下
rm -rf app/Plugin/* html
git checkout app/Plugin html
find app/proxy/entity -name '*.php' -delete
rm .maintenance
rm -rf var/cache
git checkout composer.json composer.lock
composer install --dev --no-interaction -o --apcu-autoloader
bin/console doctrine:schema:drop --force --full-database --env=dev
bin/console doctrine:schema:create --env=dev
bin/console eccube:fixtures:load --env=dev
8
6
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
8
6