LoginSignup
7
7

More than 5 years have passed since last update.

EC-CUBE3 でテスト用のデータを生成する

Last updated at Posted at 2016-09-07

EC-CUBE3 で沢山のテスト用ダミーデータを生成するスクリプトを書きました。

EC-CUBE3.0.11 以降向けです。

下準備

EC-CUBE3 をインストールし、 composer install を実行してください.
(Composer がインストールされてない方はインストールしておいてください)

cd path/to/ec-cube
composer install

パッケージ版の場合は、 PHPUnit など必要なライブラリが含まれてないためで、 github から clone してきた場合は不要です。

使用方法

ファイルをダウンロードします

curl -Ss https://raw.githubusercontent.com/nanasess/ec-cube/fixture-generator/tests/Eccube/Tests/Fixture/GeneratorTest.php -o tests/Eccube/Tests/Fixture/GeneratorTest.php

PHPUnit を実行します

./vendor/bin/phpunit tests/Eccube/Tests/Fixture/GeneratorTest.php

GeneratorTest.php の以下のパラメータを変更することで、生成される数を変更することが可能です。

    protected $numberOfProducts = 100;
    protected $numberOfCustomer = 100;
    protected $numberOfOrder = 10;
    protected $numberOfDeliveries = 5;

大量のデータを生成したい場合

上記 PHPUnit を何回か繰り返し実行することをおすすめします。

以下のように cron で 10分おきに実行してもよいでしょう。

crontab <<EOF
*/10 * * * * cd /path/to/ec-cube && /usr/bin/php ./vendor/bin/phpunit tests/Eccube/Tests/Fixture/GeneratorTest.php
EOF

この場合、 会員数が $customerCountLimit に逹すると自動的に停止します。デフォルトは 1000 です。

その他

  • 要望が多ければ、 app/console で実行できるやつを作ろうかなと思います
7
7
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
7
7