source: branches/version-2_12-dev/test/createEcCubeCustomerData-v25.php @ 21660

Revision 21660, 5.7 KB checked in by Seasoft, 12 years ago (diff)

#1613 (typo修正・ソース整形・ソースコメントの改善)
#1605 (PHP4向けコードの除去、PHP5向けのコード最適化)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
RevLine 
[21360]1#!/usr/local/bin/php -q
2<?php
3/*
4 * EC-CUBE 動作検証用会員データ生成スクリプト
5 *
6 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
7 *
8 * http://www.lockon.co.jp/
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 *
24 * @auther Kentaro Habu
[21362]25 * @version $Id$
[21360]26 */
27
28// {{{ requires
29/** 適宜、htmlディレクトリへのrequire.phpを読み込めるよう パスを書き換えて下さい */
30require_once(dirname(__FILE__) . "/../html/require.php");
31
32// }}}
33// {{{ constants
34
35/** 会員の生成数 */
[21480]36define('CUSTOMERS_VOLUME', 100);    // ※最大値:99999までで指定してください
[21360]37
38/**
39 * 会員メールアドレスのアカウント名
40 * アカウント名の後ろに「+99999」の形で連番をつけて、別名アドレス(エイリアス)の形でメールアドレスを登録します。
41 * 実際にメールを受信するためには、メールサーバが別名アドレスに対応している必要があります。
42 * (例えば、Gmailは別名アドレスに対応しています)
43 */
[21481]44define('EMAIL_ADDRESS_ACCOUNT', 'test');
[21360]45
46/**
47 * 会員メールアドレスのドメイン名
48 */
[21480]49define('EMAIL_ADDRESS_DOMAIN', "@localhost");
[21360]50
51// }}}
52// {{{ Logic
53set_time_limit(0);
54while (@ob_end_flush());
55
56$objData = new CreateEcCubeCustomerData();
[21660]57$start = microtime(true);
[21360]58
59/*
60 * ※このスクリプトは、会員データの作成に
61 * SC_Helper_Customer_Ex::sfEditCustomerData()を利用しており、
62 * この関数内で、begin~commitされているので、
63 * このスクリプト側でbegin~rollback/commitする事はできません。
64 */
65//$objData->objQuery->begin();
66
67// 会員生成
[21362]68print("creating Customer Data(for Test)...\n");
69$objData->createCustomers();
[21360]70
71//$objData->objQuery->rollback();
72//$objData->objQuery->commit();
[21660]73$end = microtime(true);
[21360]74/*
75 * Windowsのコマンドプロンプトで文字化けしないように、
76 * 標準出力に出すメッセージにはマルチバイト文字を使用しないようにした。
77 * (「chcp 65001」を実行してもWindows7では文字化けした)
78 */
79print("create customer data DONE!\n");
80printf("elapsed time: %f sec\n", $end - $start);
[21362]81lfPrintLog(sprintf("elapsed time: %f sec\n", $end - $start));
82exit;
[21360]83
84// }}}
85// {{{ classes
86
87/**
88 * EC-CUBE のテスト用会員データを生成する
89 */
90class CreateEcCubeCustomerData {
91
92    /** SC_Query インスタンス */
93    var $objQuery;
94
95    /**
96     * コンストラクタ.
97     */
98    function CreateEcCubeCustomerData() {
99        $this->objQuery = new SC_Query();
100    }
101
102    /**
103     * テスト用 会員データ を生成する.
104     *
105     * @return void
106     */
[21362]107    function createCustomers() {
108        lfPrintLog("createCustomers START.(" . CUSTOMERS_VOLUME . " data)");
[21360]109        for ($i = 0; $i < CUSTOMERS_VOLUME; $i++) {
[21362]110            lfPrintLog("----------");
111            lfPrintLog("creating customer data count:[" . ($i+1) . "] start.");
[21360]112           
113            $sqlval['name01'] = "検証";
114            $sqlval['name02'] = sprintf("太郎%05d", $i+1);
115            $sqlval['kana01'] = "ケンショウ";
116            $sqlval['kana02'] = "タロウ";
[21481]117            $sqlval['zip01'] = '101';
118            $sqlval['zip02'] = '0051';
119            $sqlval['pref'] = '13'; // 13:東京都
[21360]120            $sqlval['addr01'] = "千代田区神田神保町";
121            $sqlval['addr02'] = "1-3-5";
[21481]122            $sqlval['tel01'] = '012';
123            $sqlval['tel02'] = '3456';
124            $sqlval['tel03'] = '7890';
[21360]125            $sqlval['email'] = EMAIL_ADDRESS_ACCOUNT . "+" . sprintf("%05d", $i+1) . EMAIL_ADDRESS_DOMAIN;
[21481]126            $sqlval['sex'] = '1';    // 1:男性 2:女性
127            $sqlval['password'] = 'test';
128            $sqlval['reminder'] = '1';    // 1:「母親の旧姓は?」
[21360]129            $sqlval['reminder_answer'] = "てすと";
[21481]130            $sqlval['mailmaga_flg'] = (string) '1';    // 1:HTMLメール+テキストメールを受け取る 2:テキストメールを受け取る 3:受け取らない
[21360]131
132            // 生年月日の作成
133            $sqlval['birth']    = SC_Utils_Ex::sfGetTimestamp(2006, 9, 1);
134
135            // 仮会員 1 本会員 2
[21481]136            $sqlval['status']   = '2';
[21360]137
138            /*
139             * secret_keyは、テーブルで重複許可されていない場合があるので、
140             * 本会員登録では利用されないがセットしておく。
141             */
[21481]142            $sqlval['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
[21360]143
144            // 入会時ポイント
145            $CONF = SC_Helper_DB_Ex::sfGetBasisData();
[21481]146            $sqlval['point'] = $CONF['welcome_point'];
[21360]147
148            // 会員データの生成
149            SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
150
151            print("*");
[21362]152            lfPrintLog("creating customer data count:[" . ($i+1) . "] end.");
[21360]153        }
154        print("\n");
[21362]155        lfPrintLog("createCustomers DONE.(" . CUSTOMERS_VOLUME . " data created)");
[21360]156    }
157
158}
159
[21362]160/** テスト用スクリプトのログ出力関数 */
161function lfPrintLog($mess) {
[21660]162    $path = DATA_REALDIR . "logs/" .  basename(__FILE__, '.php') . ".log";
163    GC_Utils::gfPrintLog($mess, $path);
[21362]164}
Note: See TracBrowser for help on using the repository browser.