From 5c6f122154da260b00d103d1cb935bf5b62e8c6e Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Thu, 6 Jun 2019 16:05:12 +0900 Subject: [PATCH 01/14] Add FixtureGenerator --- tests/class/fixtures/FixtureGenerator.php | 681 ++++++++++++++++++++++ 1 file changed, 681 insertions(+) create mode 100644 tests/class/fixtures/FixtureGenerator.php diff --git a/tests/class/fixtures/FixtureGenerator.php b/tests/class/fixtures/FixtureGenerator.php new file mode 100644 index 0000000000..eed081a054 --- /dev/null +++ b/tests/class/fixtures/FixtureGenerator.php @@ -0,0 +1,681 @@ +objQuery = SC_Query_Ex::getSingletonInstance(); + } else { + $this->objQuery = $objQuery; + } + $this->faker = Faker\Factory::create($locale); + } + + /** + * 会員を生成して customer_id を返す. + * + * @param string $email メールアドレス. null の場合は, ランダムなメールアドレスが生成される. + * + * @return int customer_id + */ + public function createCustomer($email = null) + { + $customerValues = $this->createCustomerAsArray($email); + $customerValues['salt'] = SC_Utils_Ex::sfGetRandomString(10); + $customerValues['password'] = SC_Utils_Ex::sfGetHashString( + $customerValues['password'], + $customerValues['salt'] + ); + $customerValues['reminder_answer'] = SC_Utils_Ex::sfGetHashString( + $customerValues['reminder_answer'], + $customerValues['salt'] + ); + $customerValues['create_date'] = 'CURRENT_TIMESTAMP'; + $customerValues['update_date'] = 'CURRENT_TIMESTAMP'; + $customerValues['del_flg'] = 0; + + $this->objQuery->insert('dtb_customer', $customerValues); + return $customerValues['customer_id']; + } + + /** + * 会員のダミーデータを生成して配列で返す + * + * @param string $email メールアドレス. null の場合は, ランダムなメールアドレスが生成される. + * + * @return array 会員ダミーデータの配列 + */ + public function createCustomerAsArray($email = null) + { + list($zip01, $zip02) = explode('-', $this->faker->postcode); + list($tel01, $tel02, $tel03) = explode('-', $this->faker->phoneNumber); + $email = $email ? $email : microtime(true).'.'.$this->faker->safeEmail; + $customer_id = $this->objQuery->nextVal('dtb_customer_customer_id'); + $values = [ + 'customer_id' => $customer_id, + 'name01' => $this->faker->lastName, + 'name02' => $this->faker->firstName, + 'kana01' => $this->faker->lastKanaName, + 'kana02' => $this->faker->firstKanaName, + 'zip01' => $this->faker->postcode1, + 'zip02' => $this->faker->postcode2, + 'pref' => $this->faker->numberBetween(1, 47), + 'addr01' => $this->faker->city, + 'addr02' => $this->faker->streetAddress, + 'tel01' => $tel01, + 'tel02' => $tel02, + 'tel03' => $tel03, + 'email' => $email, + 'sex' => $this->faker->numberBetween(1, 2), + 'job' => $this->faker->numberBetween(1, 18), + 'password' => 'password', + 'reminder' => $this->faker->numberBetween(1, 7), + 'reminder_answer' => $this->faker->word, + 'mailmaga_flg' => $this->faker->numberBetween(1, 2), + 'birth' => $this->faker->dateTimeThisDecade()->format('Y-m-d H:i:s'), + 'status' => '2', // 本会員 + 'secret_key' => SC_Helper_Customer_Ex::sfGetUniqSecretKey(), + 'point' => $this->faker->randomNumber() + ]; + + return $this->objQuery->extractOnlyColsOf('dtb_customer', $values); + } + + /** + * 商品のダミーデータを生成し配列で返す. + * + * @param string $product_name 商品名 + * @return array 商品のダミーデータの配列 + */ + public function createProductAsArray($product_name = null) + { + $product_name = $product_name ? $product_name : $this->faker->company; + $product_id = $this->objQuery->nextVal('dtb_products_product_id'); + $values = [ + 'product_id' => $product_id, + 'name' => $product_name, + 'status' => 1, + 'comment3' => $this->faker->streetName, + 'main_list_comment' => $this->faker->streetAddress, + 'main_list_image' => 'nabe130.jpg', + 'main_comment' => $this->faker->address, + 'main_image' => 'nabe260.jpg', + 'main_large_image' => 'nabe500.jpg', + 'sub_comment1' => $this->faker->streetAddress, + 'del_flg' => 0, + 'creator_id' => self::DEFAULT_CREATOR_ID, + 'create_date' => 'CURRENT_TIMESTAMP', + 'update_date' => 'CURRENT_TIMESTAMP', + 'deliv_date_id' => $this->faker->numberBetween(1, 9) + ]; + + return $this->objQuery->extractOnlyColsOf('dtb_products', $values); + } + + /** + * 商品を生成し product_id を返す + * + * @param string $product_name 商品名 + * @param int $product_class_num 商品規格の生成数 + * @return int product_id + */ + public function createProduct($product_name = null, $product_class_num = 3) + { + $productValues = $this->createProductAsArray($product_name); + $this->objQuery->insert('dtb_products', $productValues); + + if ($product_class_num == 0) { + // 0 が指定した場合はデフォルトの商品規格のみを生成する + $this->createProductsClass($productValues['product_id']); + } else { + // 規格をランダムに抽出する + $class_ids = $this->objQuery->getCol('class_id', 'dtb_class', 'del_flg = 0'); + $class_id1 = $class_ids[$this->faker->numberBetween(0, count($class_ids) - 1)]; + $class_id2 = $class_ids[$this->faker->numberBetween(0, count($class_ids) - 1)]; + if ($class_id1 === $class_id2) { + $class_id2 = 0; + } + + $exist_classcategory_id1 = [0]; + $exist_classcategory_id2 = [0]; + // 指定された数だけ商品規格を生成する + for ($i = 0; $i < $product_class_num; $i++) { + $classcategory_ids1 = $this->objQuery->getCol( + 'classcategory_id', 'dtb_classcategory', + 'class_id = ? AND classcategory_id NOT IN ('.implode(', ', array_pad([], count($exist_classcategory_id1), '?')).') AND del_flg = 0', + array_merge([$class_id1], $exist_classcategory_id1) + ); + $classcategory_id1 = empty($classcategory_ids1) ? 0 : $classcategory_ids1[$this->faker->numberBetween(0, count($classcategory_ids1) - 1)]; + + if (in_array($classcategory_id1, $exist_classcategory_id1) + || !$this->objQuery->exists('dtb_classcategory', 'classcategory_id = ?', [$classcategory_id1])) { + // 見つからない規格分類IDが指定されたら規格を生成しない + $classcategory_id1 = 0; + } + + // 規格1が設定されていれば, 規格2を設定する + if ($classcategory_id1 > 0) { + $exist_classcategory_id1[] = $classcategory_id1; + $classcategory_ids2 = $this->objQuery->getCol( + 'classcategory_id', 'dtb_classcategory', + 'class_id = ? AND classcategory_id NOT IN ('.implode(', ', array_pad([], count($exist_classcategory_id2), '?')).') AND del_flg = 0', + array_merge([$class_id2], $exist_classcategory_id2) + ); + $classcategory_id2 = empty($classcategory_ids2) ? 0 : $classcategory_ids2[$this->faker->numberBetween(0, count($classcategory_ids2) - 1)]; + if (in_array($classcategory_id2, $exist_classcategory_id2) + || $classcategory_id1 === $classcategory_id2 + || !$this->objQuery->exists('dtb_classcategory', 'classcategory_id = ?', [$classcategory_id2])) { + $classcategory_id2 = 0; + } + } else { + $classcategory_id2 = 0; + } + if ($classcategory_id2 > 0) { + $exist_classcategory_id2[] = $classcategory_id2; + } + $this->createProductsClass($productValues['product_id'], $classcategory_id1, $classcategory_id2); + } + $this->createProductsClass($productValues['product_id'], 0, 0, 1); + } + + return $productValues['product_id']; + } + + /** + * 商品規格を生成して配列で返す. + * + * @param int $product_id 商品ID + * @param int $classcategory_id1 規格分類ID1 + * @param int $classcategory_id2 規格分類ID2 + * @param int $del_flg 削除フラグ + * @return array 商品規格のダミーデータの配列 + */ + public function createProductsClassAsArray($product_id, $classcategory_id1 = 0, $classcategory_id2 = 0, $del_flg = 0) + { + $product_class_id = $this->objQuery->nextVal('dtb_products_class_product_class_id'); + $stock = $this->faker->numberBetween(0, 100); + $price02 = $this->faker->randomNumber(INT_LEN); + $price01 = $this->faker->numberBetween($price02, str_repeat('9', INT_LEN)); + $values = [ + 'product_class_id' => $product_class_id, + 'product_id' => $product_id, + 'classcategory_id1' => $classcategory_id1, + 'classcategory_id2' => $classcategory_id2, + 'product_code' => 'CODE_'.$product_id.'_'.$classcategory_id1.'_'.$classcategory_id2, + 'product_type_id' => 1, + 'stock_unlimited' => $stock === 0 ? 1 : 0, + 'stock' => $stock, + 'price01' => $price01, + 'price02' => $price02, + 'point_rate' => 10, + 'creator_id' => self::DEFAULT_CREATOR_ID, + 'create_date' => 'CURRENT_TIMESTAMP', + 'update_date' => 'CURRENT_TIMESTAMP', + 'del_flg' => $del_flg, + ]; + + return $this->objQuery->extractOnlyColsOf('dtb_products_class', $values); + } + + /** + * 商品規格を生成する. + * + * @param int $product_id 商品ID + * @param int $classcategory_id1 規格分類ID1 + * @param int $classcategory_id2 規格分類ID2 + * @param int $del_flg 削除フラグ + * @return int 商品規格ID + */ + public function createProductsClass($product_id, $classcategory_id1 = 0, $classcategory_id2 = 0, $del_flg = 0) + { + + $values = $this->createProductsClassAsArray($product_id, $classcategory_id1, $classcategory_id2, $del_flg); + $this->objQuery->insert('dtb_products_class', $values); + + return $values['product_class_id']; + } + + /** + * 規格を生成して配列を返す. + * + * @param string $class_name 規格名 + * @param int $rank 並び順 + * + * @return array 規格のダミーデータの配列 + */ + public function createClassAsArray($class_name = null, $rank = 0) + { + $class_name = $class_name ? $class_name : $this->faker->lastName; + $class_id = $this->objQuery->nextVal('dtb_class_class_id'); + $values = [ + 'class_id' => $class_id, + 'name' => $class_name, + 'rank' => $rank, + 'creator_id' => self::DEFAULT_CREATOR_ID, + 'create_date' => 'CURRENT_TIMESTAMP', + 'update_date' => 'CURRENT_TIMESTAMP', + 'del_flg' => '0', + ]; + + return $this->objQuery->extractOnlyColsOf('dtb_class', $values); + } + + /** + * 規格を生成して規格IDを返す. + * + * @param string $class_name 規格名 + * @return int class_id + */ + public function createClass($class_name = null) + { + $values = $this->createClassAsArray($class_name); + $subQueries = []; + if ($values['rank'] === 0) { + $subQueries['rank'] = "(SELECT x.rank FROM (SELECT CASE + WHEN max(rank) + 1 IS NULL THEN 1 + ELSE max(rank) + 1 + END as rank + FROM dtb_class + WHERE del_flg = 0) as x)"; + unset($values['rank']); + } + $this->objQuery->insert('dtb_class', $values, $subQueries); + + return $values['class_id']; + } + + /** + * 規格分類を生成して配列を返す. + * + * @param int $class_id 規格ID + * @param string $classcategory_name 規格分類名 + * @param int $rank 並び順 + * + * @return array 規格分類の配列 + */ + public function createClassCategoryAsArray($class_id, $classcategory_name = null, $rank = 0) + { + $classcategory_id = $this->objQuery->nextVal('dtb_classcategory_classcategory_id'); + $classcategory_name = $classcategory_name ? $classcategory_name : $this->faker->firstKanaName; + $values = [ + 'classcategory_id' => $classcategory_id, + 'name' => $classcategory_name, + 'class_id' => $class_id, + 'rank' => $rank, + 'creator_id' => self::DEFAULT_CREATOR_ID, + 'create_date' => 'CURRENT_TIMESTAMP', + 'update_date' => 'CURRENT_TIMESTAMP', + 'del_flg' => 0 + ]; + + return $this->objQuery->extractOnlyColsOf('dtb_classcategory', $values); + } + + /** + * 規格分類を生成して規格分類IDを返す. + * + * @param int $class_id 規格ID + * @param string $classcategory_name 規格分類名 + * @return int 規格分類ID + */ + public function createClassCategory($class_id, $classcategory_name = null) + { + $values = $this->createClassCategoryAsArray($class_id, $classcategory_name); + $subQueries = []; + if ($values['rank'] === 0) { + $subQueries['rank'] = sprintf("(SELECT x.rank FROM (SELECT CASE + WHEN max(rank) + 1 IS NULL THEN 1 + ELSE max(rank) + 1 + END as rank + FROM dtb_classcategory + WHERE del_flg = 0 + AND class_id = %d) as x)", $class_id); + } + + $this->objQuery->insert('dtb_classcategory', $values, $subQueries); + + return $values['classcategory_id']; + } + + /** + * カテゴリを生成する. + * + * 以下のように, ツリー状のカテゴリを生成する + * + * 大カテゴリ -- 中カテゴリ -- 小カテゴリ + * | |- 小カテゴリ + * | |- 小カテゴリ + * | + * |- 中カテゴリ -- 小カテゴリ + * |- 小カテゴリ + * |- 小カテゴリ + * + * 引数 $max_depth, $max_generations に応じてランダムに生成する. + * + * @param int $max_depth 最大階層深度 + * @param int $max_generations 最大生成数 + * @return array 生成したカテゴリIDの配列 + */ + public function createCategories($max_depth = 5, $max_generations = 30) + { + $depth = $this->faker->numberBetween(1, $max_depth); + $generations = $this->faker->numberBetween($depth, $max_generations); + $hierarchy = array_pad([], $depth, ''); + $faker = $this->faker; + $objQuery = $this->objQuery; + + // 階層ごとのカテゴリIDを生成する + $category_ids = array_filter(array_map(function ($val) use (&$generations, $objQuery, $faker) { + $n = $faker->numberBetween(1, $generations); + $generations -= $n; + if ($generations < 1) { + return []; + } + $c = array_pad([], $n, ''); + return array_map(function ($id) use ($objQuery) { + $id = $objQuery->nextVal('dtb_category_category_id'); + return $id; + }, $c); + }, $hierarchy)); + + $result = []; + foreach ($category_ids as $level => $ids) { + foreach ($ids as $id) { + $level = (int) $level; + // root カテゴリ以外は, 1階層上のカテゴリをランダムに親とする + $parent_category_id = $level === 0 + ? 0 + : $category_ids[$level - 1][$this->faker->numberBetween(0, count($category_ids[$level - 1]) - 1)]; + $result[] = $this->createCategory($id, $parent_category_id, $level + 1); + } + } + + return $result; + } + + /** + * カテゴリを生成し配列を返す. + * + * @param int $category_id カテゴリID + * @param int $parent_category_id 親カテゴリID + * @param int $level 階層 + * @param string $category_name カテゴリ名 + * @return array カテゴリのダミーデータの配列 + */ + public function createCategoryAsArray($category_id = null, $parent_category_id = 0, $level = 1, $category_name = null) + { + $category_id = $category_id ? $category_id : $this->objQuery->nextVal('dtb_category_category_id'); + $max_rank = $this->objQuery->max('rank', 'dtb_category'); + $values = [ + 'category_id' => $category_id, + 'parent_category_id' => $parent_category_id, + 'category_name' => $category_name ? $category_name : $this->faker->streetAddress, + 'level' => $level, + 'rank' => $max_rank + 1, + 'creator_id' => self::DEFAULT_CREATOR_ID, + 'create_date' => 'CURRENT_TIMESTAMP', + 'update_date' => 'CURRENT_TIMESTAMP', + 'del_flg' => 0 + ]; + return $this->objQuery->extractOnlyColsOf('dtb_category', $values); + } + + /** + * カテゴリを生成し category_id を返す. + * + * @param int $category_id カテゴリID + * @param int $parent_category_id 親カテゴリID + * @param int $level 階層 + * @param string $category_name カテゴリ名 + * @return int カテゴリID + */ + public function createCategory($category_id = null, $parent_category_id = 0, $level = 1, $category_name = null) + { + $values = $this->createCategoryAsArray($category_id, $parent_category_id, $level, $category_name); + $this->objQuery->insert('dtb_category', $values); + + return $values['category_id']; + } + + /** + * 商品とカテゴリを関連づけする. + * + * @param int $product_id 商品ID + * @param array $category_ids カテゴリIDの配列 + * @return array 関連づけ済みのカテゴリIDの配列 + */ + public function relateProductCategories($product_id, $category_ids = []) + { + return array_map(function ($category_id) use ($product_id) { + $rank = $this->objQuery->max('rank', 'dtb_product_categories'); + $this->objQuery->insert('dtb_product_categories', [ + 'product_id' => $product_id, + 'category_id' => $category_id, + 'rank' => $rank + ]); + return $category_id; + }, $category_ids); + } + + /** + * 商品規格をもとに注文明細の配列を生成して返す. + * + * @param int $product_class_id 商品規格ID + * @param int $order_id order_id + * + * @return array 注文明細のダミーデータの配列 + */ + public function createOrderDetailAsArray($product_class_id, $order_id) + { + $productsClassValues = $this->objQuery->getRow('*', 'dtb_products_class', 'product_class_id = ?', [$product_class_id]); + $productsValues = $this->objQuery->getRow('*', 'dtb_products', 'product_id = ?', [$productsClassValues['product_id']]); + $classcategory_name1 = $this->objQuery->get('name', 'dtb_classcategory', 'classcategory_id = ?', [$productsClassValues['classcategory_id1']]); + + $classcategory_name2 = $this->objQuery->get('name', 'dtb_classcategory', 'classcategory_id = ?', [$productsClassValues['classcategory_id2']]); + $taxRuleValues = SC_Helper_TaxRule_Ex::getTaxRule($productsValues['product_id'], $productsClassValues['product_class_id']); + $values = [ + 'order_detail_id' => $this->objQuery->nextVal('dtb_order_detail_order_detail_id_seq'), + 'order_id' => $order_id, + 'product_id' => $productsClassValues['product_id'], + 'product_class_id' => $product_class_id, + 'product_name' => $productsValues['name'], + 'product_code' => $productsValues['product_code'], + 'classcategory_name1' => $classcategory_name1, + 'classcategory_name2' => $classcategory_name2, + 'price' => SC_Helper_TaxRule_Ex::sfCalcIncTax( + $productsClassValues['price02'], + $productsValues['product_id'], + $productsClassValues['product_class_id'] + ), + 'quantity' => $this->faker->numberBetween(1, 100), + 'point_rate' => 10, + 'tax_rate' => $taxRuleValues['tax_rate'], + 'tax_rule' => $taxRuleValues['tax_rule_id'] + ]; + + return $this->objQuery->extractOnlyColsOf('dtb_order_detail', $values); + } + + /** + * dtb_order_temp のデータを生成し配列を返す. + * + * @param int $order_id 注文ID + * @param int $subtotal 小計 + * @param int $customer_id 顧客ID. 0 の場合はゲスト購入の注文を生成する + * @param int $deliv_id 配送業者ID + * @param int $add_charge 手数料 + * @param int $add_discount 値引 + * @param int $order_status_id 指定する注文ステータス + * @return array dtb_order_temp のダミーデータの配列 + */ + public function createOrderTempAsArray($order_id = 0, $subtotal = 0, $customer_id = 0, $deliv_id = 0, $add_charge =0, $add_discount = 0, $order_status_id = ORDER_NEW) + { + $customerValues = $this->objQuery->getRow('*', 'dtb_customer', 'customer_id = ?', [$customer_id]); + if (SC_Utils_Ex::isBlank($customerValues)) { + $customerValues = $this->createCustomerAsArray(); + } + $delivValues = $this->objQuery->getRow('*', 'dtb_deliv', 'deliv_id = ?', [$deliv_id]); + $deliv_fee = $this->objQuery->get('fee', 'dtb_delivfee', 'deliv_id = ? AND pref = ?', [$deliv_id, $customerValues['pref']]); + $discount = $add_discount === 0 ? $this->faker->numberBetween(0, $subtotal) : $add_discount; + $charge = $add_charge === 0 ? $this->faker->numberBetween(0, $subtotal) : $add_charge; + $payment_ids = $this->objQuery->getCol('payment_id', 'dtb_payment_options', 'deliv_id = ?', [$deliv_id]); + $paymentValues = $this->objQuery->getRow('*', 'dtb_payment', 'payment_id = ?', [$this->faker->numberBetween(0, count($payment_ids) - 1)]); + + $values = [ + 'order_temp_id' => SC_Utils_Ex::sfGetRandomString(10), + 'customer_id' => $customer_id, + 'message' => $this->faker->address, + 'subtotal' => $subtotal, + 'discount' => $discount, + 'deliv_id' => $deliv_id, + 'deliv_fee' => $deliv_fee, + 'charge' => $charge, + 'use_point' => 0, + 'add_point' => 0, + 'birth_point' => 0, + 'tax' => SC_Helper_TaxRule_Ex::sfTax($subtotal), + 'total' => $subtotal + $deliv_fee + $charge - $discount, + 'payment_id' => $paymentValues['payment_id'], + 'payment_method' => $paymentValues['payment_method'], + 'note' => $this->faker->address, + 'mail_flag' => 0, + 'status' => $order_status_id, + 'deliv_check' => 0, + 'point_check' => 0, + 'create_date' => 'CURRENT_TIMESTAMP', + 'update_date' => 'CURRENT_TIMESTAMP', + 'device_type_id' => 1, + 'del_flg' => 1, + 'order_id' => $order_id + ]; + + $values['payment_total'] = $values['total']; + foreach ($customerValues as $key => $value) { + $orderTempValues['order_'.$key] = $value; + } + + return $this->objQuery->extractOnlyColsOf('dtb_order_temp', $values); + } + + /** + * dtb_order の配列をもとに dtb_shipping の配列を生成する. + * + * @param array $orderValues dtb_order の配列 + * @param int $shipping_id shipping_id + * @return array dtb_shipping のダミーデータの配列 + */ + public function createShippingFromOrderAsArray($orderValues, $shipping_id = 0) + { + $delivTimeValues = $this->objQuery->select('*', 'dtb_delivtime', 'deliv_id = ?', [$orderValues['deliv_id']]); + $deliv_time_key = $this->faker->numberBetween(0, count($delivTimeValues) - 1); + $shipping_id = 0; + $shippingValues = [ + 'shipping_id' => $shipping_id, + 'order_id' => $orderValues['order_id'], + 'time_id' => $delivTimeValues[$deliv_time_key]['time_id'], + 'shipping_time' => $delivTimeValues[$deliv_time_key]['deliv_time'], + 'rank' => 0, + 'create_date' => 'CURRENT_TIMESTAMP', + 'update_date' => 'CURRENT_TIMESTAMP', + 'del_flg' => 0, + ]; + + /** @var SC_Helper_Purchase_Ex $objPurchase */ + $objPurchase = new SC_Helper_Purchase_Ex(); + $objPurchase->copyFromOrder($shippingValues, $orderValues); + + return $this->objQuery->extractOnlyColsOf('dtb_shipping', $shippingValues); + } + + /** + * dtb_order_detail から dtb_shipment_item の配列を生成します. + * + * @param array $orderDetailValues dtb_order_detail の配列 + * @param int $shipping_id shipping_id + * @return array dtb_shipment_item の配列 + */ + public function creatShipmentItemFromOrderDetailAsArray($orderDetailValues, $shipping_id = 0) + { + $values = $orderDetailValues; + $values['shipping_id'] = $shipping_id; + + return $this->objQuery->extractOnlyColsOf('dtb_shipment_item', $values); + } + + /** + * 受注を生成し order_id を返します. + * + * 生成されるデータは以下の通り + * - dtb_order + * - dtb_order_detail + * - dtb_shipping + * - dtb_shipment_item + * + * @param int $customer_id 顧客ID. 0 の場合はゲスト購入の注文を生成する + * @param array $product_class_ids 注文明細に使用する商品規格IDの配列 + * @param int $deliv_id 配送業者ID + * @param int $add_charge 手数料 + * @param int $add_discount 値引 + * @param int $order_status_id 指定する注文ステータス + * @return int order_id + */ + public function createOrder($customer_id = 0, $product_class_ids = [], $deliv_id = 1, $add_charge = 0, $add_discount = 0, $order_status_id = ORDER_NEW) + { + $order_id = $this->objQuery->nextVal('dtb_order_order_id_seq'); + + if (empty($product_class_ids)) { + // 既存の商品規格から選択する + $this->objQuery->setLimit(3); + $product_class_ids = $this->objQuery->getCol( + 'product_class_id', + 'dtb_products_class', + 'product_type_id = 1 AND del_flg = 0 AND EXISTS (SELECT * FROM dtb_products WHERE del_flg = 0 AND product_id = dtb_products_class.product_id)'); + } + + $orderDetails = array_map(function ($product_class_id) use ($order_id) { + return $this->createOrderDetailAsArray($product_class_id, $order_id); + }, $product_class_ids); + + $subtotal = array_reduce( + $orderDetails, + function ($carry, $orderDetail) { + return $carry + ($orderDetail['price'] * $orderDetail['quantity']); + }); + + $orderTempValues = $this->createOrderTempAsArray($order_id, $subtotal, $customer_id, $deliv_id, $add_charge, $add_discount, $order_status_id); + $this->objQuery->insert('dtb_order_temp', $orderTempValues); + + $orderValues = $orderTempValues; + $orderValues['del_flg'] = 0; + $this->objQuery->insert('dtb_order', $this->objQuery->extractOnlyColsOf('dtb_order', $orderValues)); + + array_map(function ($detailValues) { + $this->objQuery->insert('dtb_order_detail', $detailValues); + return $detailValues; + }, $orderDetails); + + $shippingValues = $this->createShippingFromOrderAsArray($orderValues); + $this->objQuery->insert('dtb_shipping', $shippingValues); + + array_map(function ($detailValues) { + $this->objQuery->insert('dtb_shipment_item', $this->creatShipmentItemFromOrderDetailAsArray($detailValues)); + return $detailValues; + }, $orderDetails); + + return $order_id; + } +} From 0325e181f44d1e6d8a69c1b454e0523e7b2b221c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 11 Jun 2019 14:34:39 +0900 Subject: [PATCH 02/14] =?UTF-8?q?FixtureGenerator=20=E3=81=A7=E7=94=9F?= =?UTF-8?q?=E6=88=90=E3=81=97=E3=81=9F=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/class/Common_TestCase.php | 2 +- tests/class/fixtures/FixtureGenerator.php | 19 ++- .../SC_Helper_Purchase_TestBase.php | 90 +++-------- .../SC_Helper_Purchase_completeOrderTest.php | 18 ++- .../SC_Helper_Purchase_getOrderDetailTest.php | 149 ++++++++---------- .../SC_Helper_Purchase_getOrderTempTest.php | 21 ++- .../SC_Helper_Purchase_getOrderTest.php | 24 +-- ...per_Purchase_registerOrderCompleteTest.php | 1 - .../SC_Helper_Purchase_registerOrderTest.php | 18 ++- .../SC_Helper_Purchase_saveOrderTempTest.php | 21 ++- ...lper_Purchase_sfUpdateOrderNameColTest.php | 49 ++++-- ...elper_Purchase_sfUpdateOrderStatusTest.php | 52 +++--- 12 files changed, 224 insertions(+), 240 deletions(-) diff --git a/tests/class/Common_TestCase.php b/tests/class/Common_TestCase.php index 634893e532..80891d2789 100644 --- a/tests/class/Common_TestCase.php +++ b/tests/class/Common_TestCase.php @@ -33,7 +33,7 @@ class Common_TestCase extends PHPUnit_Framework_TestCase '_MDB2_dsninfo_default', ); - /** SC_Query インスタンス */ + /** @var SC_Query */ protected $objQuery; /** 期待値 */ diff --git a/tests/class/fixtures/FixtureGenerator.php b/tests/class/fixtures/FixtureGenerator.php index eed081a054..c3ebeb6990 100644 --- a/tests/class/fixtures/FixtureGenerator.php +++ b/tests/class/fixtures/FixtureGenerator.php @@ -29,12 +29,13 @@ public function __construct($objQuery = null, $locale = 'ja_JP') * 会員を生成して customer_id を返す. * * @param string $email メールアドレス. null の場合は, ランダムなメールアドレスが生成される. + * @param array $properties 任意の値を指定するプロパティの配列 * * @return int customer_id */ - public function createCustomer($email = null) + public function createCustomer($email = null, $properties = []) { - $customerValues = $this->createCustomerAsArray($email); + $customerValues = $this->createCustomerAsArray($email, $properties); $customerValues['salt'] = SC_Utils_Ex::sfGetRandomString(10); $customerValues['password'] = SC_Utils_Ex::sfGetHashString( $customerValues['password'], @@ -56,10 +57,11 @@ public function createCustomer($email = null) * 会員のダミーデータを生成して配列で返す * * @param string $email メールアドレス. null の場合は, ランダムなメールアドレスが生成される. + * @param array $properties 任意の値を指定するプロパティの配列 * * @return array 会員ダミーデータの配列 */ - public function createCustomerAsArray($email = null) + public function createCustomerAsArray($email = null, $properties = []) { list($zip01, $zip02) = explode('-', $this->faker->postcode); list($tel01, $tel02, $tel03) = explode('-', $this->faker->phoneNumber); @@ -92,7 +94,10 @@ public function createCustomerAsArray($email = null) 'point' => $this->faker->randomNumber() ]; - return $this->objQuery->extractOnlyColsOf('dtb_customer', $values); + return $this->objQuery->extractOnlyColsOf( + 'dtb_customer', + array_merge($values, $properties) + ); } /** @@ -483,6 +488,7 @@ public function createOrderDetailAsArray($product_class_id, $order_id) { $productsClassValues = $this->objQuery->getRow('*', 'dtb_products_class', 'product_class_id = ?', [$product_class_id]); $productsValues = $this->objQuery->getRow('*', 'dtb_products', 'product_id = ?', [$productsClassValues['product_id']]); + $classcategory_name1 = $this->objQuery->get('name', 'dtb_classcategory', 'classcategory_id = ?', [$productsClassValues['classcategory_id1']]); $classcategory_name2 = $this->objQuery->get('name', 'dtb_classcategory', 'classcategory_id = ?', [$productsClassValues['classcategory_id2']]); @@ -522,7 +528,7 @@ public function createOrderDetailAsArray($product_class_id, $order_id) * @param int $order_status_id 指定する注文ステータス * @return array dtb_order_temp のダミーデータの配列 */ - public function createOrderTempAsArray($order_id = 0, $subtotal = 0, $customer_id = 0, $deliv_id = 0, $add_charge =0, $add_discount = 0, $order_status_id = ORDER_NEW) + public function createOrderTempAsArray($order_id = 0, $subtotal = 0, $customer_id = 0, $deliv_id = 0, $add_charge = 0, $add_discount = 0, $order_status_id = ORDER_NEW) { $customerValues = $this->objQuery->getRow('*', 'dtb_customer', 'customer_id = ?', [$customer_id]); if (SC_Utils_Ex::isBlank($customerValues)) { @@ -562,10 +568,9 @@ public function createOrderTempAsArray($order_id = 0, $subtotal = 0, $customer_i 'del_flg' => 1, 'order_id' => $order_id ]; - $values['payment_total'] = $values['total']; foreach ($customerValues as $key => $value) { - $orderTempValues['order_'.$key] = $value; + $values['order_'.$key] = $value; } return $this->objQuery->extractOnlyColsOf('dtb_order_temp', $values); diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php index 27ef9df26f..d005fadf5d 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php @@ -32,10 +32,13 @@ */ class SC_Helper_Purchase_TestBase extends Common_TestCase { + /** @var FixtureGenerator */ + protected $objGenerator; protected function setUp() { parent::setUp(); + $this->objGenerator = new FixtureGenerator($this->objQuery); } protected function tearDown() @@ -299,7 +302,6 @@ protected function setUpPaymentOptions() ) ); - $this->objQuery->delete('dtb_payment_options'); foreach ($payment_options as $key => $item) { $this->objQuery->insert('dtb_payment_options', $item); } @@ -346,7 +348,6 @@ protected function setUpDeliv() ), ); - $this->objQuery->delete('dtb_deliv'); foreach ($deliv as $key => $item) { $this->objQuery->insert('dtb_deliv', $item); } @@ -375,7 +376,6 @@ protected function setUpDelivTime() ), ); - $this->objQuery->delete('dtb_delivtime'); foreach ($deliv_time as $key => $item) { $this->objQuery->insert('dtb_delivtime', $item); } @@ -443,7 +443,6 @@ protected function setUpPayment() ) ); - $this->objQuery->delete('dtb_payment'); foreach ($payment as $key => $item) { $this->objQuery->insert('dtb_payment', $item); } @@ -452,13 +451,12 @@ protected function setUpPayment() /** * DBに受注情報を設定します. */ - protected function setUpOrder() + protected function setUpOrder($customer_ids = []) { - $order = array( + $orders = array( array( 'update_date' => '2000-01-01 00:00:00', - 'order_id' => '1001', - 'customer_id' => '1001', + 'customer_id' => $customer_ids[0], 'order_name01' => '受注情報01', 'status' => '3', 'payment_date' => '2032-12-31 01:20:30', // 日付が変わっても良いように、遠い未来に設定 @@ -467,57 +465,35 @@ protected function setUpOrder() ), array( 'update_date' => '2000-01-01 00:00:00', - 'order_id' => '1002', - 'customer_id' => '1002', + 'customer_id' => $customer_ids[1], 'order_name01' => '受注情報02', 'status' => '5', - 'payment_id' => '1002', - 'payment_method' => '支払方法1001', - 'deliv_id' => '1002', 'use_point' => '10', 'add_point' => '20' ) ); $this->objQuery->delete('dtb_order'); - foreach ($order as $item) { - $this->objQuery->insert('dtb_order', $item); - } + return array_map(function ($properties) { + $order_id = $this->objGenerator->createOrder($properties['customer_id']); + $this->objQuery->update('dtb_order', $properties, 'order_id = ?', [$order_id]); + + return $order_id; + }, $orders); } /** - * DBに受注一時情報を設定します. + * setUpOrder() で生成した一時情報を返す. */ - protected function setUpOrderTemp() + protected function setUpOrderTemp($order_ids) { - $order = array( - array( - 'update_date' => '2000-01-01 00:00:00', - 'order_temp_id' => '1001', - 'customer_id' => '1001', - 'order_name01' => '受注情報01', - 'order_id' => '1001' - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'order_temp_id' => '1002', - 'customer_id' => '1002', - 'order_name01' => '受注情報02', - 'payment_id' => '1002', - 'payment_method' => '支払方法1001' - ) - ); - - $this->objQuery->delete('dtb_order_temp'); - foreach ($order as $item) { - $this->objQuery->insert('dtb_order_temp', $item); - } + return $this->objQuery->getCol('order_temp_id', 'dtb_order_temp', 'order_id IN ('.implode(',', array_pad([], count($order_ids), '?')).')', $order_ids); } /** * DBに受注詳細を設定します. */ - protected function setUpOrderDetail() + protected function setUpOrderDetail($order_ids) { $order_detail = array( array( @@ -570,35 +546,11 @@ protected function setUpOrderDetail() */ protected function setUpCustomer() { - $customer = array( - array( - 'customer_id' => '1001', - 'name01' => '苗字', - 'name02' => '名前', - 'kana01' => 'みょうじ', - 'kana02' => 'なまえ', - 'email' => 'test@example.com', - 'secret_key' => 'hoge', - 'point' => '100', - 'update_date' => '2000-01-01 00:00:00' - ), - array( - 'customer_id' => '1002', - 'name01' => '苗字2', - 'name02' => '名前2', - 'kana01' => 'みょうじ2', - 'kana02' => 'なまえ2', - 'email' => 'test2@example.com', - 'secret_key' => 'hoge2', - 'point' => '200', - 'update_date' => '2000-01-01 00:00:00' - ) - ); - $this->objQuery->delete('dtb_customer'); - foreach ($customer as $item) { - $this->objQuery->insert('dtb_customer', $item); - } + return [ + $this->objGenerator->createCustomer(null, ['point' => 100]), + $this->objGenerator->createCustomer(null, ['point' => 200]) + ]; } } diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php index 2ab5ce7ba5..23833cd557 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php @@ -33,16 +33,22 @@ */ class SC_Helper_Purchase_completeOrderTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; + /** @var array */ + private $order_temp_ids = []; private $helper; protected function setUp() { parent::setUp(); - $this->setUpOrder(); - $this->setUpOrderTemp(); // order_temp_id = '1001' + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); + $this->order_temp_ids = $this->setUpOrderTemp($this->order_ids); $this->setUpShipping([]); - $this->setUpCustomer(); + $_SESSION['cartKey'] = '1'; $_SESSION['site'] = array( @@ -64,7 +70,7 @@ protected function tearDown() // 適切なfunctionが呼ばれていることのみ確認 public function testCompleteOrder_顧客IDが指定されている場合_購入日が更新される() { - $_SESSION['customer']['customer_id'] = '1002'; // 顧客ID + $_SESSION['customer']['customer_id'] = $this->customer_ids[1]; // 顧客ID $this->helper->completeOrder(ORDER_DELIV); $this->expected = array( @@ -96,7 +102,7 @@ public function testCompleteOrder_顧客IDが指定されている場合_購入 ); $this->actual = $_SESSION['testResult']; $this->verify('適切なfunctionが呼ばれている'); - $last_buy_date = $this->objQuery->get('last_buy_date', 'dtb_customer', 'customer_id = ?', '1002'); + $last_buy_date = $this->objQuery->get('last_buy_date', 'dtb_customer', 'customer_id = ?', $this->customer_ids[1]); $this->assertNotNull($last_buy_date, '最終購入日'); } diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderDetailTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderDetailTest.php index c2aaa7ccc3..e947897b30 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderDetailTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderDetailTest.php @@ -33,14 +33,16 @@ */ class SC_Helper_Purchase_getOrderDetailTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; protected function setUp() { parent::setUp(); - $this->setUpOrder(); - $this->setUpOrderDetail(); - $this->setUpProductClass(); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); } protected function tearDown() @@ -61,96 +63,71 @@ public function testGetOrderDetail_存在しない受注IDを指定した場合_ public function testGetOrderDetail_存在する受注IDを指定した場合_対応する受注詳細情報が取得できる() { - $order_id = '1001'; - - $this->expected = array( - array( - 'product_id' => '1002', - 'product_class_id' => '1002', - 'product_type_id' => '2', - 'product_code' => 'pc1002', - 'product_name' => '製品名1002', - 'classcategory_name1' => 'cat10021', - 'classcategory_name2' => 'cat10022', - 'price' => '3000', - 'quantity' => '10', - 'point_rate' => '5', - 'status' => '3', - 'payment_date' => '2032-12-31 01:20:30', - 'enable' => '0', - 'effective' => '1', - 'tax_rate' => '5', - 'tax_rule' => '0' - ), - array( - 'product_id' => '1001', - 'product_class_id' => '1001', - 'product_type_id' => '1', - 'product_code' => 'pc1001', - 'product_name' => '製品名1001', - 'classcategory_name1' => 'cat10011', - 'classcategory_name2' => 'cat10012', - 'price' => '4000', - 'quantity' => '15', - 'point_rate' => '6', - 'status' => '3', - 'payment_date' => '2032-12-31 01:20:30', - 'enable' => '1', - 'effective' => '1', - 'tax_rate' => '3', - 'tax_rule' => '1' - ) - ); - $this->actual = SC_Helper_Purchase::getOrderDetail($order_id); + $properties = [ + 'product_id', 'product_class_id', 'product_type_id', 'product_code', + 'product_name', 'classcategory_name1', 'classcategory_name2', 'price', + 'quantity', 'point_rate', 'status', 'payment_date', 'enable', 'effective', + 'tax_rate', 'tax_rule']; + + $arrOrderDetails = $this->objQuery->select('*', 'dtb_order_detail T1 JOIN dtb_order T2 ON T1.order_id = T2.order_id', 'T1.order_id = ?', [$this->order_ids[0]]); + + // 不足しているダミーの情報を付与する + $arrOrderDetails = array_map(function ($orderDetail) { + $orderDetail['product_type_id'] = (string) PRODUCT_TYPE_NORMAL; + $orderDetail['enable'] = '1'; + $orderDetail['effective'] = '1'; + return $orderDetail; + }, $arrOrderDetails); + + $this->expected = array_map(function ($orderDetail) use ($properties) { + $expectedDetail = []; + foreach ($properties as $key) { + $expectedDetail[$key] = $orderDetail[$key]; + } + + return $expectedDetail; + }, $arrOrderDetails); + + $this->actual = SC_Helper_Purchase::getOrderDetail($this->order_ids[0]); $this->verify(); + + $this->assertNotEmpty($this->actual[0]['status']); + $this->assertNotEmpty($this->actual[0]['payment_date']); } public function testGetOrderDetail_ステータス取得フラグがOFFのの場合_ステータス以外の情報が取得できる() { - $order_id = '1001'; - - $this->expected = array( - array( - 'product_id' => '1002', - 'product_class_id' => '1002', - 'product_type_id' => '2', - 'product_code' => 'pc1002', - 'product_name' => '製品名1002', - 'classcategory_name1' => 'cat10021', - 'classcategory_name2' => 'cat10022', - 'price' => '3000', - 'quantity' => '10', - 'point_rate' => '5', - // 'status' => '3', - // 'payment_date' => '2032-12-31 01:20:30', - 'enable' => '0', - 'effective' => '1', - 'tax_rate' => '5', - 'tax_rule' => '0' - ), - array( - 'product_id' => '1001', - 'product_class_id' => '1001', - 'product_type_id' => '1', - 'product_code' => 'pc1001', - 'product_name' => '製品名1001', - 'classcategory_name1' => 'cat10011', - 'classcategory_name2' => 'cat10012', - 'price' => '4000', - 'quantity' => '15', - 'point_rate' => '6', - // 'status' => '3', - // 'payment_date' => '2032-12-31 01:20:30', - 'enable' => '1', - 'effective' => '1', - 'tax_rate' => '3', - 'tax_rule' => '1' - ) - ); - $this->actual = SC_Helper_Purchase::getOrderDetail($order_id, false); + $properties = [ + 'product_id', 'product_class_id', 'product_type_id', 'product_code', + 'product_name', 'classcategory_name1', 'classcategory_name2', 'price', + 'quantity', 'point_rate', 'enable', 'effective', + 'tax_rate', 'tax_rule']; + + $arrOrderDetails = $this->objQuery->select('*', 'dtb_order_detail T1 JOIN dtb_order T2 ON T1.order_id = T2.order_id', 'T1.order_id = ?', [$this->order_ids[0]]); + // 不足しているダミーの情報を付与する + $arrOrderDetails = array_map(function ($orderDetail) { + $orderDetail['product_type_id'] = (string) PRODUCT_TYPE_NORMAL; + $orderDetail['enable'] = '1'; + $orderDetail['effective'] = '1'; + return $orderDetail; + }, $arrOrderDetails); + + $this->expected = array_map(function ($orderDetail) use ($properties) { + $expectedDetail = []; + foreach ($properties as $key) { + $expectedDetail[$key] = $orderDetail[$key]; + } + + return $expectedDetail; + }, $arrOrderDetails); + + $this->actual = SC_Helper_Purchase::getOrderDetail($this->order_ids[0], false); $this->verify(); + + $this->assertEmpty($this->actual[0]['status']); + $this->assertEmpty($this->actual[0]['payment_date']); } ////////////////////////////////////////// diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderTempTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderTempTest.php index ef763a6b9c..95b3496160 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderTempTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderTempTest.php @@ -33,12 +33,19 @@ */ class SC_Helper_Purchase_getOrderTempTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; + /** @var array */ + private $order_temp_ids = []; protected function setUp() { parent::setUp(); - $this->setUpOrderTemp(); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); + $this->order_temp_ids = $this->setUpOrderTemp($this->order_ids); } protected function tearDown() @@ -59,14 +66,16 @@ public function testGetOrderTemp_存在しない受注IDを指定した場合_ public function testGetOrderTemp_存在する受注IDを指定した場合_対応する結果が取得できる() { - $order_temp_id = '1002'; + $order_temp_id = $this->order_temp_ids[0]; + $arrCustomer = $this->objQuery->getRow('*', 'dtb_customer', 'customer_id = ?', [$this->customer_ids[0]]); $this->expected = array( - 'order_temp_id' => '1002', - 'customer_id' => '1002', - 'order_name01' => '受注情報02' + 'order_temp_id' => $order_temp_id, + 'customer_id' => $this->customer_ids[0], + 'order_name01' => $arrCustomer['name01'] ); $result = SC_Helper_Purchase::getOrderTemp($order_temp_id); + $this->actual = Test_Utils::mapArray($result, array('order_temp_id', 'customer_id', 'order_name01')); $this->verify(); diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderTest.php index 44c4435ca3..c20e448723 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderTest.php @@ -33,12 +33,16 @@ */ class SC_Helper_Purchase_getOrderTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; protected function setUp() { parent::setUp(); - $this->setUpOrder(); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); } protected function tearDown() @@ -59,7 +63,7 @@ public function testGetOrder_存在しない受注IDを指定した場合_結果 public function testGetOrder_存在しない顧客IDを指定した場合_結果が空になる() { - $order_id = '1002'; + $order_id = $this->order_ids[0]; $customer_id = '9999'; $this->expected = null; @@ -70,11 +74,11 @@ public function testGetOrder_存在しない顧客IDを指定した場合_結果 public function testGetOrder_顧客IDを指定しなかった場合_受注IDに対応する結果が取得できる() { - $order_id = '1002'; + $order_id = $this->order_ids[1]; $this->expected = array( - 'order_id' => '1002', - 'customer_id' => '1002', + 'order_id' => $order_id, + 'customer_id' => $this->customer_ids[1], 'order_name01' => '受注情報02' ); $result = SC_Helper_Purchase::getOrder($order_id); @@ -85,12 +89,12 @@ public function testGetOrder_顧客IDを指定しなかった場合_受注IDに public function testGetOrder_存在する顧客IDを指定した場合_対応する結果が取得できる() { - $order_id = '1002'; - $customer_id = '1002'; + $order_id = $this->order_ids[1]; + $customer_id = $this->customer_ids[1]; $this->expected = array( - 'order_id' => '1002', - 'customer_id' => '1002', + 'order_id' => $order_id, + 'customer_id' => $customer_id, 'order_name01' => '受注情報02' ); $result = SC_Helper_Purchase::getOrder($order_id, $customer_id); diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderCompleteTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderCompleteTest.php index 7cd010cc62..83c7b797ec 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderCompleteTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderCompleteTest.php @@ -39,7 +39,6 @@ class SC_Helper_Purchase_registerOrderCompleteTest extends SC_Helper_Purchase_Te protected function setUp() { parent::setUp(); - $this->setUpOrderTemp(); $this->helper = new SC_Helper_Purchase_registerOrderCompleteMock(); } diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderTest.php index 08f904acae..f09cdc54ba 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderTest.php @@ -33,13 +33,17 @@ */ class SC_Helper_Purchase_registerOrderTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; private $helper; protected function setUp() { parent::setUp(); - $this->setUpOrder(); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); $this->helper = new SC_Helper_Purchase_registerOrderMock(); } @@ -51,7 +55,7 @@ protected function tearDown() ///////////////////////////////////////// public function testRegisterOrder_既に受注IDが存在する場合_情報が更新される() { - $order_id = '1001'; + $order_id = $this->order_ids[0]; $arrParams = array( 'status' => '1', 'add_point' => 10, @@ -63,16 +67,16 @@ public function testRegisterOrder_既に受注IDが存在する場合_情報が $this->expected = array( 'sfUpdateOrderStatus' => array( - 'order_id' => '1001', + 'order_id' => $order_id, 'status' => '1', 'add_point' => 10, 'use_point' => 20 ), - 'sfUpdateOrderNameCol' => '1001', + 'sfUpdateOrderNameCol' => $order_id, 'count' => '2', 'content' => array( - 'order_id' => '1001', - 'customer_id' => '1001', + 'order_id' => $order_id, + 'customer_id' => $this->customer_ids[0], 'status' => '1', 'add_point' => '10', 'use_point' => '20', diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_saveOrderTempTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_saveOrderTempTest.php index 8c079e4402..96eee9a9e1 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_saveOrderTempTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_saveOrderTempTest.php @@ -33,12 +33,21 @@ */ class SC_Helper_Purchase_saveOrderTempTest extends SC_Helper_Purchase_TestBase { + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; + /** @var array */ + private $order_temp_ids = []; private $helper; protected function setUp() { parent::setUp(); - $this->setUpOrderTemp(); + $this->objQuery->delete('dtb_order_temp'); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); + $this->order_temp_ids = $this->setUpOrderTemp($this->order_ids); $this->helper = new SC_Helper_Purchase_saveOrderTempMock(); } @@ -59,7 +68,7 @@ public function testSaveOrderTemp_受注一時情報IDが空の場合_何もし ); $this->expected = 2; - $this->actual = $this->objQuery->count('dtb_order_temp'); + $this->actual = $this->objQuery->count('dtb_order_temp'); $this->verify('件数が変わっていない'); } @@ -92,7 +101,7 @@ public function testSaveOrderTemp_既存の情報がない場合_情報が新規 public function testSaveOrderTemp_既存の情報がある場合_情報が更新される() { - $this->helper->saveOrderTemp('1002', + $this->helper->saveOrderTemp($this->order_temp_ids[0], array( 'customer_id' => '2002', 'order_name01' => '受注情報92', @@ -103,15 +112,15 @@ public function testSaveOrderTemp_既存の情報がある場合_情報が更新 $this->expected['count'] = '2'; $this->expected['content'] = array( array( - 'order_temp_id' => '1002', + 'order_temp_id' => $this->order_temp_ids[0], 'customer_id' => '2002', 'order_name01' => '受注情報92' ) ); - $this->actual['count'] = $this->objQuery->count('dtb_order_temp'); + $this->actual['count'] = $this->objQuery->count('dtb_order_temp'); $this->actual['content'] = $this->objQuery->select( 'order_temp_id, customer_id, order_name01', - 'dtb_order_temp', 'order_temp_id = ?', array('1002')); + 'dtb_order_temp', 'order_temp_id = ?', array($this->order_temp_ids[0])); $this->verify('件数が変わらず更新される'); } diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_sfUpdateOrderNameColTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_sfUpdateOrderNameColTest.php index ad6a341a9e..74ada006b2 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_sfUpdateOrderNameColTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_sfUpdateOrderNameColTest.php @@ -34,16 +34,20 @@ class SC_Helper_Purchase_sfUpdateOrderNameColTest extends SC_Helper_Purchase_TestBase { var $helper; + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; + /** @var array */ + private $order_temp_ids = []; protected function setUp() { parent::setUp(); - $this->setUpOrder(); - $this->setUpOrderTemp(); - $this->setUpPayment(); - $this->setUpDeliv(); - $this->setUpDelivTime(); - $this->setUpShippingOnDb(); + + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); + $this->order_temp_ids = $this->setUpOrderTemp($this->order_ids); $this->helper = new SC_Helper_Purchase(); } @@ -56,35 +60,46 @@ protected function tearDown() ///////////////////////////////////////// public function testSfUpdateOrderNameCol_TEMPフラグがOFFの場合_受注テーブルと発送テーブルが更新される() { - $order_id = '1002'; + $order_id = $this->order_ids[1]; + $this->helper->saveOrderTemp($this->order_temp_ids[1], ['payment_method' => '支払方法0002']); + $arrOrder = $this->objQuery->getRow('*', 'dtb_order', 'order_id = ?', [$order_id]); + $arrShipping = $this->objQuery->getRow('*', 'dtb_shipping', 'order_id = ? AND shipping_id = 0', [$order_id]); + $arrDelivTime = $this->objQuery->getRow('*', 'dtb_delivtime', 'deliv_id = ? AND time_id = ?', [$arrOrder['deliv_id'], $arrShipping['time_id']]); + $arrPayment = $this->objQuery->getRow('*', 'dtb_payment', 'payment_id = ?', [$arrOrder['payment_id']]); $this->helper->sfUpdateOrderNameCol($order_id); - $this->expected['shipping'] = array(array('shipping_time' => '午前')); - $this->expected['order'] = array(array('payment_method' => '支払方法1002')); - $this->expected['order_temp'] = array(array('payment_method' => '支払方法1001')); // 変更されていない + $this->expected['shipping'] = array(array('shipping_time' => $arrDelivTime['deliv_time'])); + $this->expected['order'] = array(array('payment_method' => $arrPayment['payment_method'])); + $this->expected['order_temp'] = array(array('payment_method' => '支払方法0002')); // 変更されていない $this->actual['shipping'] = $this->objQuery->select( 'shipping_time', 'dtb_shipping', 'order_id = ?', array($order_id) ); + $this->actual['order'] = $this->objQuery->select( 'payment_method', 'dtb_order', 'order_id = ?', array($order_id) ); $this->actual['order_temp'] = $this->objQuery->select( - 'payment_method', 'dtb_order_temp', 'order_temp_id = ?', array($order_id) + 'payment_method', 'dtb_order_temp', 'order_id = ?', array($order_id) ); $this->verify(); } public function testSfUpdateOrderNameCol_TEMPフラグがONの場合_一時テーブルが更新される() { - $order_id = '1002'; + $order_id = $this->order_ids[1]; + $this->helper->saveOrderTemp($this->order_temp_ids[1], ['payment_method' => '支払方法0002']); + $arrOrder = $this->objQuery->getRow('*', 'dtb_order', 'order_id = ?', [$order_id]); + $arrShipping = $this->objQuery->getRow('*', 'dtb_shipping', 'order_id = ? AND shipping_id = 0', [$order_id]); + $arrDelivTime = $this->objQuery->getRow('*', 'dtb_delivtime', 'deliv_id = ? AND time_id = ?', [$arrOrder['deliv_id'], $arrShipping['time_id']]); + $arrPayment = $this->objQuery->getRow('*', 'dtb_payment', 'payment_id = ?', [$arrOrder['payment_id']]); - $this->helper->sfUpdateOrderNameCol($order_id, true); + $this->helper->sfUpdateOrderNameCol($this->order_temp_ids[1], true); - $this->expected['shipping'] = array(array('shipping_time' => '午後')); // 変更されていない - $this->expected['order'] = array(array('payment_method' => '支払方法1001')); // 変更されていない - $this->expected['order_temp'] = array(array('payment_method' => '支払方法1002')); + $this->expected['shipping'] = array(array('shipping_time' => $arrDelivTime['deliv_time'])); + $this->expected['order'] = array(array('payment_method' => $arrPayment['payment_method'])); + $this->expected['order_temp'] = array(array('payment_method' => $arrPayment['payment_method'])); // 変更されている $this->actual['shipping'] = $this->objQuery->select( 'shipping_time', 'dtb_shipping', 'order_id = ?', array($order_id) @@ -93,7 +108,7 @@ public function testSfUpdateOrderNameCol_TEMPフラグがONの場合_一時テ 'payment_method', 'dtb_order', 'order_id = ?', array($order_id) ); $this->actual['order_temp'] = $this->objQuery->select( - 'payment_method', 'dtb_order_temp', 'order_temp_id = ?', array($order_id) + 'payment_method', 'dtb_order_temp', 'order_temp_id = ?', array($this->order_temp_ids[1]) ); $this->verify(); } diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_sfUpdateOrderStatusTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_sfUpdateOrderStatusTest.php index 7e338459a3..15ac886cf8 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_sfUpdateOrderStatusTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_sfUpdateOrderStatusTest.php @@ -33,14 +33,16 @@ */ class SC_Helper_Purchase_sfUpdateOrderStatusTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; private $helper; - protected function setUp() { parent::setUp(); - $this->setUpOrder(); - $this->setUpCustomer(); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); $this->helper = new SC_Helper_Purchase_sfUpdateOrderStatusMock(); } @@ -53,8 +55,9 @@ protected function tearDown() // オプションの引数:対応状況、使用ポイント、加算ポイント public function testSfUpdateOrderStatus_オプションの引数が未指定の場合_DBの値が引き継がれる() { - $order_id = '1001'; + $order_id = $this->order_ids[0]; $old_update_date = $this->objQuery->get('update_date', 'dtb_order', 'order_id = ?', array($order_id)); + $customer_point = $this->objQuery->get('point', 'dtb_customer', 'customer_id = ?', array($this->customer_ids[0])); $this->helper->usePoint = false; $this->helper->addPoint = false; @@ -67,14 +70,14 @@ public function testSfUpdateOrderStatus_オプションの引数が未指定の 'use_point' => '10' ), 'customer' => array( - 'point' => '100' + 'point' => $customer_point ) ); $this->actual['order'] = array_shift($this->objQuery->select( 'status, use_point, add_point', 'dtb_order', 'order_id = ?', array($order_id))); $this->actual['customer'] = array_shift($this->objQuery->select( - 'point', 'dtb_customer', 'customer_id = ?', '1001')); + 'point', 'dtb_customer', 'customer_id = ?', $this->customer_ids[0])); $this->verify(); @@ -94,10 +97,11 @@ public function testSfUpdateOrderStatus_ポイント使用しない設定の場 public function testSfUpdateOrderStatus_対応状況が発送済みに変更された場合_発送日が更新される() { - $order_id = '1001'; + $order_id = $this->order_ids[0]; $old_dates = $this->objQuery->select( 'update_date, commit_date, payment_date', 'dtb_order', 'order_id = ?', array($order_id)); + $customer_point = $this->objQuery->get('point', 'dtb_customer', 'customer_id = ?', array($this->customer_ids[0])); $this->helper->usePoint = false; $this->helper->addPoint = false; @@ -110,14 +114,14 @@ public function testSfUpdateOrderStatus_対応状況が発送済みに変更さ 'use_point' => '45' // 引数の設定どおりになる ), 'customer' => array( - 'point' => '100' // ポイントを使わない + 'point' => $customer_point // ポイントを使わない ) ); $this->actual['order'] = array_shift($this->objQuery->select( 'status, use_point, add_point', 'dtb_order', 'order_id = ?', array($order_id))); $this->actual['customer'] = array_shift($this->objQuery->select( - 'point', 'dtb_customer', 'customer_id = ?', '1001')); + 'point', 'dtb_customer', 'customer_id = ?', $this->customer_ids[0])); $this->verify(); @@ -131,7 +135,7 @@ public function testSfUpdateOrderStatus_対応状況が発送済みに変更さ public function testSfUpdateOrderStatus_対応状況が入金済みに変更された場合_入金日が更新される() { - $order_id = '1002'; + $order_id = $this->order_ids[1]; $old_dates = $this->objQuery->select( 'update_date, commit_date, payment_date', 'dtb_order', 'order_id = ?', array($order_id)); @@ -163,10 +167,11 @@ public function testSfUpdateOrderStatus_対応状況が入金済みに変更さ public function testSfUpdateOrderStatus_変更前の対応状況が利用対象の場合_変更前の使用ポイントを戻す() { - $order_id = '1002'; + $order_id = $this->order_ids[1]; $old_dates = $this->objQuery->select( 'update_date, commit_date, payment_date', 'dtb_order', 'order_id = ?', array($order_id)); + $customer_point = $this->objQuery->get('point', 'dtb_customer', 'customer_id = ?', array($this->customer_ids[1])); $this->helper->addPoint = false; // 加算は強制的にfalseにしておく $this->helper->sfUpdateOrderStatus($order_id, ORDER_CANCEL, 0, 45); @@ -185,14 +190,14 @@ public function testSfUpdateOrderStatus_変更前の対応状況が利用対象 'status, use_point, add_point', 'dtb_order', 'order_id = ?', array($order_id))); $this->actual['customer'] = array_shift($this->objQuery->select( - 'point', 'dtb_customer', 'customer_id = ?', array('1002'))); + 'point', 'dtb_customer', 'customer_id = ?', array($this->customer_ids[1]))); $this->verify(); } public function testSfUpdateOrderStatus_変更後の対応状況が利用対象の場合_変更後の使用ポイントを引く() { - $order_id = '1001'; + $order_id = $this->order_ids[0]; $old_dates = $this->objQuery->select( 'update_date, commit_date, payment_date', 'dtb_order', 'order_id = ?', array($order_id)); @@ -213,14 +218,14 @@ public function testSfUpdateOrderStatus_変更後の対応状況が利用対象 'status, use_point, add_point', 'dtb_order', 'order_id = ?', array($order_id))); $this->actual['customer'] = array_shift($this->objQuery->select( - 'point', 'dtb_customer', 'customer_id = ?', array('1001'))); + 'point', 'dtb_customer', 'customer_id = ?', array($this->customer_ids[0]))); $this->verify(); } public function testSfUpdateOrderStatus_変更前の対応状況が加算対象の場合_変更前の加算ポイントを戻す() { - $order_id = '1002'; + $order_id = $this->order_ids[1]; $old_dates = $this->objQuery->select( 'update_date, commit_date, payment_date', 'dtb_order', 'order_id = ?', array($order_id)); @@ -242,14 +247,14 @@ public function testSfUpdateOrderStatus_変更前の対応状況が加算対象 'status, use_point, add_point', 'dtb_order', 'order_id = ?', array($order_id))); $this->actual['customer'] = array_shift($this->objQuery->select( - 'point', 'dtb_customer', 'customer_id = ?', array('1002'))); + 'point', 'dtb_customer', 'customer_id = ?', array($this->customer_ids[1]))); $this->verify(); } public function testSfUpdateOrderStatus_変更後の対応状況が加算対象の場合_変更後の加算ポイントを足す() { - $order_id = '1001'; + $order_id = $this->order_ids[0]; $old_dates = $this->objQuery->select( 'update_date, commit_date, payment_date', 'dtb_order', 'order_id = ?', array($order_id)); @@ -270,14 +275,14 @@ public function testSfUpdateOrderStatus_変更後の対応状況が加算対象 'status, use_point, add_point', 'dtb_order', 'order_id = ?', array($order_id))); $this->actual['customer'] = array_shift($this->objQuery->select( - 'point', 'dtb_customer', 'customer_id = ?', array('1001'))); + 'point', 'dtb_customer', 'customer_id = ?', array($this->customer_ids[0]))); $this->verify(); } public function testSfUpdateOrderStatus_加算ポイントがプラスの場合_会員テーブルが更新される() { - $order_id = '1001'; + $order_id = $this->order_ids[0]; $old_dates = $this->objQuery->select( 'update_date, commit_date, payment_date', 'dtb_order', 'order_id = ?', array($order_id)); @@ -300,14 +305,14 @@ public function testSfUpdateOrderStatus_加算ポイントがプラスの場合_ 'status, use_point, add_point', 'dtb_order', 'order_id = ?', array($order_id))); $this->actual['customer'] = array_shift($this->objQuery->select( - 'point', 'dtb_customer', 'customer_id = ?', '1001')); + 'point', 'dtb_customer', 'customer_id = ?', $this->customer_ids[0])); $this->verify(); } public function testSfUpdateOrderStatus_加算ポイントが負でポイントが足りている場合_会員テーブルが更新される() { - $order_id = '1001'; + $order_id = $this->order_ids[0]; $old_dates = $this->objQuery->select( 'update_date, commit_date, payment_date', 'dtb_order', 'order_id = ?', array($order_id)); @@ -330,8 +335,7 @@ public function testSfUpdateOrderStatus_加算ポイントが負でポイント 'status, use_point, add_point', 'dtb_order', 'order_id = ?', array($order_id))); $this->actual['customer'] = array_shift($this->objQuery->select( - 'point', 'dtb_customer', 'customer_id = ?', '1001')); - + 'point', 'dtb_customer', 'customer_id = ?', $this->customer_ids[0])); $this->verify(); } From 2b798cfdede2fea0ad425fc46c9e1264cf86169c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Wed, 12 Jun 2019 16:35:28 +0900 Subject: [PATCH 03/14] =?UTF-8?q?setUpOrder=20=E3=81=A7=E6=B3=A8=E6=96=87?= =?UTF-8?q?=E6=98=8E=E7=B4=B0=E3=81=AE=E5=95=86=E5=93=81=E8=A6=8F=E6=A0=BC?= =?UTF-8?q?ID=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SC_Helper_Purchase_TestBase.php | 6 +- .../SC_Helper_Purchase_completeOrderTest.php | 26 ++++---- ...C_Helper_Purchase_getShipmentItemsTest.php | 62 ++++++++++--------- ...per_Purchase_registerOrderCompleteTest.php | 27 +++++--- 4 files changed, 67 insertions(+), 54 deletions(-) diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php index d005fadf5d..4da494aaf2 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php @@ -451,7 +451,7 @@ protected function setUpPayment() /** * DBに受注情報を設定します. */ - protected function setUpOrder($customer_ids = []) + protected function setUpOrder($customer_ids = [], $product_class_ids = []) { $orders = array( array( @@ -474,8 +474,8 @@ protected function setUpOrder($customer_ids = []) ); $this->objQuery->delete('dtb_order'); - return array_map(function ($properties) { - $order_id = $this->objGenerator->createOrder($properties['customer_id']); + return array_map(function ($properties) use ($product_class_ids) { + $order_id = $this->objGenerator->createOrder($properties['customer_id'], $product_class_ids); $this->objQuery->update('dtb_order', $properties, 'order_id = ?', [$order_id]); return $order_id; diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php index 23833cd557..82fcf29510 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php @@ -55,7 +55,7 @@ protected function setUp() 'pre_page' => 'pre', 'now_page' => 'now', 'regist_success' => TRUE, - 'uniqid' => '1001' + 'uniqid' => $this->order_temp_ids[0] ); $this->helper = new SC_Helper_Purchase_completeOrderMock(); @@ -75,28 +75,28 @@ public function testCompleteOrder_顧客IDが指定されている場合_購入 $this->expected = array( 'verifyChangeCart' => array( - 'uniqId' => '1001' + 'uniqId' => $this->order_temp_ids[0] ), 'getOrderTemp' => array( - 'uniqId' => '1001' + 'uniqId' => $this->order_temp_ids[0] ), 'registerOrderComplete' => array( - 'order_temp_id' => '1001', + 'order_temp_id' => $this->order_temp_ids[0], 'status' => ORDER_DELIV, 'cartKey' => '1' ), 'registerShipmentItem' => array( array( - 'order_id' => '1001', + 'order_id' => $this->order_ids[0], 'shipping_id' => '00001', 'shipment_item' => '商品1' ) ), 'registerShipping' => array( - 'order_id' => '1001' + 'order_id' => $this->order_ids[0], ), 'cleanupSession' => array( - 'order_id' => '1001', + 'order_id' => $this->order_ids[0], 'cartKey' => '1' ) ); @@ -112,28 +112,28 @@ public function testCompleteOrder_顧客IDが指定されていない場合_特 $this->expected = array( 'verifyChangeCart' => array( - 'uniqId' => '1001' + 'uniqId' => $this->order_temp_ids[0] ), 'getOrderTemp' => array( - 'uniqId' => '1001' + 'uniqId' => $this->order_temp_ids[0] ), 'registerOrderComplete' => array( - 'order_temp_id' => '1001', + 'order_temp_id' => $this->order_temp_ids[0], 'status' => ORDER_NEW, 'cartKey' => '1' ), 'registerShipmentItem' => array( array( - 'order_id' => '1001', + 'order_id' => $this->order_ids[0], 'shipping_id' => '00001', 'shipment_item' => '商品1' ) ), 'registerShipping' => array( - 'order_id' => '1001' + 'order_id' => $this->order_ids[0] ), 'cleanupSession' => array( - 'order_id' => '1001', + 'order_id' => $this->order_ids[0], 'cartKey' => '1' ) ); diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShipmentItemsTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShipmentItemsTest.php index 2cafa83f45..6dd2f1e5a5 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShipmentItemsTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShipmentItemsTest.php @@ -33,12 +33,16 @@ */ class SC_Helper_Purchase_getShipmentItemsTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; protected function setUp() { parent::setUp(); - $this->setUpShipmentItem(); - $this->setUpOrderDetail(); + + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids, [1, 2]); } protected function tearDown() @@ -71,25 +75,25 @@ public function testGetShipmentItems_存在しない配送先IDを指定した public function testGetShipmentItems_存在する受注IDと配送先IDを指定した場合_結果が取得できる() { - $order_id = '1001'; - $shipping_id = '1'; + $order_id = $this->order_ids[0]; + $shipping_id = '0'; $this->expected['count'] = 2; $this->expected['second'] = array( - 'order_id' => '1001', - 'shipping_id' => '1', - 'product_class_id' => '1001', - 'product_name' => '商品名01', - 'price' => '1500', - 'productsClass' => array('product_class_id' => '1001', 'product_id' => '1001') + 'order_id' => (string) $order_id, + 'shipping_id' => '0', + 'product_class_id' => '2', + 'product_name' => 'アイスクリーム', + 'price' => '1008', + 'productsClass' => array('product_class_id' => '2', 'product_id' => '1') ); $this->expected['first'] = array( - 'order_id' => '1001', - 'shipping_id' => '1', - 'product_class_id' => '1002', - 'product_name' => '商品名02', - 'price' => '2400', - 'productsClass' => array('product_class_id' => '1002', 'product_id' => '1002') + 'order_id' => (string) $order_id, + 'shipping_id' => '0', + 'product_class_id' => '1', + 'product_name' => 'アイスクリーム', + 'price' => '1008', + 'productsClass' => array('product_class_id' => '1', 'product_id' => '1') ); $result = SC_Helper_Purchase::getShipmentItems($order_id, $shipping_id); @@ -106,24 +110,24 @@ public function testGetShipmentItems_存在する受注IDと配送先IDを指定 public function testGetShipmentItems_詳細フラグをOFFにした場合_結果に詳細情報が含まれない() { - $order_id = '1001'; - $shipping_id = '1'; + $order_id = $this->order_ids[0]; + $shipping_id = '0'; $this->expected['count'] = 2; $this->expected['second'] = array( - 'order_id' => '1001', - 'shipping_id' => '1', - 'product_class_id' => '1001', - 'product_name' => '商品名01', - 'price' => '1500', + 'order_id' => (string) $order_id, + 'shipping_id' => '0', + 'product_class_id' => '2', + 'product_name' => 'アイスクリーム', + 'price' => '1008', 'productsClass' => null ); $this->expected['first'] = array( - 'order_id' => '1001', - 'shipping_id' => '1', - 'product_class_id' => '1002', - 'product_name' => '商品名02', - 'price' => '2400', + 'order_id' => (string) $order_id, + 'shipping_id' => '0', + 'product_class_id' => '1', + 'product_name' => 'アイスクリーム', + 'price' => '1008', 'productsClass' => null ); diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderCompleteTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderCompleteTest.php index 83c7b797ec..11781efe39 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderCompleteTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderCompleteTest.php @@ -34,11 +34,20 @@ class SC_Helper_Purchase_registerOrderCompleteTest extends SC_Helper_Purchase_TestBase { + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; + /** @var array */ + private $order_temp_ids = []; private $helper; protected function setUp() { parent::setUp(); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); + $this->order_temp_ids = $this->setUpOrderTemp($this->order_ids); $this->helper = new SC_Helper_Purchase_registerOrderCompleteMock(); } @@ -50,30 +59,31 @@ protected function tearDown() ///////////////////////////////////////// public function testRegisterOrderComplete_不要な変数が含まれている場合_登録前に除外される() { + // 引数の準備 $orderParams = array( - 'order_id' => '1001', + 'order_id' => $this->order_ids[0], 'status' => ORDER_PAY_WAIT, 'mail_maga_flg' => '1', 'order_tax_rate' => '5', 'order_tax_rule' => '1' ); $cartSession = new SC_CartSession_registerOrderCompleteMock(); - $_SESSION['site']['uniqid'] = '1001'; + $_SESSION['site']['uniqid'] = $this->order_temp_ids[0]; $this->helper->registerOrderComplete($orderParams, $cartSession, '1'); - + $this->expected = array( 'registerOrder' => array( - 'order_id' => '1001', + 'order_id' => $this->order_ids[0], 'status' => ORDER_PAY_WAIT, 'mailmaga_flg' => null ), 'registerOrderDetail' => array( - 'order_id' => '1001', + 'order_id' => $this->order_ids[0], 'params' => array( array( - 'order_id' => '1001', + 'order_id' => $this->order_ids[0], 'product_id' => '1002', 'product_class_id' => '1002', 'product_name' => '製品02', @@ -93,7 +103,7 @@ public function testRegisterOrderComplete_不要な変数が含まれている ); $this->actual = $_SESSION['testResult']; - $this->actual['del_flg'] = $this->objQuery->get('del_flg', 'dtb_order_temp', 'order_temp_id = ?', '1001'); + $this->actual['del_flg'] = $this->objQuery->get('del_flg', 'dtb_order_temp', 'order_temp_id = ?', $this->order_temp_ids[0]); $this->verify(); } @@ -110,7 +120,7 @@ public function testRegisterOrderComplete_ステータスの指定がない場 $_SESSION['site']['uniqid'] = '1001'; $this->helper->registerOrderComplete($orderParams, $cartSession, '1'); - + // 上の条件と重複する部分は確認を省略 $this->expected = array( 'registerOrder' => array( @@ -175,4 +185,3 @@ function getCartList($cartKey) } } ?> - From bf3fdc6d4aaae2a95c5733f6645f63b6e340346f Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Thu, 13 Jun 2019 14:23:25 +0900 Subject: [PATCH 04/14] =?UTF-8?q?dtb=5Forder=5Fdetail=20=E3=81=AE=E8=87=AA?= =?UTF-8?q?=E5=8B=95=E7=94=9F=E6=88=90=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SC_Helper_Purchase_completeOrderTest.php | 6 +- .../SC_Helper_Purchase_getOrderDetailTest.php | 4 +- .../SC_Helper_Purchase_getShippingsTest.php | 44 +++--- ...elper_Purchase_registerOrderDetailTest.php | 127 +++++++++--------- 4 files changed, 93 insertions(+), 88 deletions(-) diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php index 82fcf29510..239fe26cca 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_completeOrderTest.php @@ -124,16 +124,16 @@ public function testCompleteOrder_顧客IDが指定されていない場合_特 ), 'registerShipmentItem' => array( array( - 'order_id' => $this->order_ids[0], + 'order_id' => (string) $this->order_ids[0], 'shipping_id' => '00001', 'shipment_item' => '商品1' ) ), 'registerShipping' => array( - 'order_id' => $this->order_ids[0] + 'order_id' => (string) $this->order_ids[0] ), 'cleanupSession' => array( - 'order_id' => $this->order_ids[0], + 'order_id' => (string) $this->order_ids[0], 'cartKey' => '1' ) ); diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderDetailTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderDetailTest.php index e947897b30..58c1b8da26 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderDetailTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getOrderDetailTest.php @@ -42,7 +42,7 @@ protected function setUp() { parent::setUp(); $this->customer_ids = $this->setUpCustomer(); - $this->order_ids = $this->setUpOrder($this->customer_ids); + $this->order_ids = $this->setUpOrder($this->customer_ids, [1, 2, 3, 4, 5]); } protected function tearDown() @@ -69,6 +69,7 @@ public function testGetOrderDetail_存在する受注IDを指定した場合_対 'quantity', 'point_rate', 'status', 'payment_date', 'enable', 'effective', 'tax_rate', 'tax_rule']; + $this->objQuery->setOrder('order_detail_id'); $arrOrderDetails = $this->objQuery->select('*', 'dtb_order_detail T1 JOIN dtb_order T2 ON T1.order_id = T2.order_id', 'T1.order_id = ?', [$this->order_ids[0]]); // 不足しているダミーの情報を付与する @@ -104,6 +105,7 @@ public function testGetOrderDetail_ステータス取得フラグがOFFのの場 'quantity', 'point_rate', 'enable', 'effective', 'tax_rate', 'tax_rule']; + $this->objQuery->setOrder('order_detail_id'); $arrOrderDetails = $this->objQuery->select('*', 'dtb_order_detail T1 JOIN dtb_order T2 ON T1.order_id = T2.order_id', 'T1.order_id = ?', [$this->order_ids[0]]); // 不足しているダミーの情報を付与する $arrOrderDetails = array_map(function ($orderDetail) { diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingsTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingsTest.php index 75d9aea075..1ddd7a5bf1 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingsTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingsTest.php @@ -33,14 +33,16 @@ */ class SC_Helper_Purchase_getShippingsTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; protected function setUp() { parent::setUp(); - $this->setUpShipmentItem(); - $this->setUpShippingOnDb(); - $this->setUpOrderDetail(); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); } protected function tearDown() @@ -62,37 +64,39 @@ public function testGetShippings_存在しない受注IDを指定した場合_ public function testGetShippings_存在する受注IDを指定した場合_結果が取得できる() { - $order_id = '1001'; - + $order_id = $this->order_ids[0]; + $arrCustomer = $this->objQuery->getRow('*', 'dtb_customer', 'customer_id = ?', [$this->customer_ids[0]]); $this->expected['count'] = 1; $this->expected['first'] = array( - 'order_id' => '1001', - 'shipping_id' => '1', - 'shipping_name01' => '配送情報01', - 'shipping_date' => '2012-01-12 00:00:00' + 'order_id' => (string) $order_id, + 'shipping_id' => '0', + 'shipping_name01' => $arrCustomer['name01'], + 'shipping_date' => null ); - $this->expected['shipment_item_count'] = 2; + $this->expected['shipment_item_count'] = 3; $helper = new SC_Helper_Purchase(); $result = $helper->getShippings($order_id); + $this->actual['count'] = count($result); // shipping_idごとの配列になっているのでshipping_idで抽出 - $this->actual['first'] = Test_Utils::mapArray($result['1'], array( + $this->actual['first'] = Test_Utils::mapArray($result[0], array( 'order_id', 'shipping_id', 'shipping_name01', 'shipping_date')); - $this->actual['shipment_item_count'] = count($result['1']['shipment_item']); + $this->actual['shipment_item_count'] = count($result[0]['shipment_item']); $this->verify('配送情報'); } public function testGetShippings_商品取得フラグをOFFにした場合_結果に商品情報が含まれない() { - $order_id = '1001'; + $order_id = $this->order_ids[0]; + $arrCustomer = $this->objQuery->getRow('*', 'dtb_customer', 'customer_id = ?', [$this->customer_ids[0]]); $this->expected['count'] = 1; $this->expected['first'] = array( - 'order_id' => '1001', - 'shipping_id' => '1', - 'shipping_name01' => '配送情報01', - 'shipping_date' => '2012-01-12 00:00:00' + 'order_id' => (string) $order_id, + 'shipping_id' => '0', + 'shipping_name01' => $arrCustomer['name01'], + 'shipping_date' => null ); $this->expected['shipment_item_count'] = 0; @@ -100,9 +104,9 @@ public function testGetShippings_商品取得フラグをOFFにした場合_結 $result = $helper->getShippings($order_id, false); $this->actual['count'] = count($result); // shipping_idごとの配列になっているのでshipping_idで抽出 - $this->actual['first'] = Test_Utils::mapArray($result['1'], array( + $this->actual['first'] = Test_Utils::mapArray($result[0], array( 'order_id', 'shipping_id', 'shipping_name01', 'shipping_date')); - $this->actual['shipment_item_count'] = count($result['1']['shipment_item']); + $this->actual['shipment_item_count'] = count($result[0]['shipment_item']); $this->verify('配送情報'); } diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderDetailTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderDetailTest.php index b11271ed5e..a98330c9e1 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderDetailTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderDetailTest.php @@ -32,11 +32,15 @@ */ class SC_Helper_Purchase_registerOrderDetailTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; protected function setUp() { parent::setUp(); - $this->setUpOrderDetail(); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids); } protected function tearDown() @@ -47,74 +51,69 @@ protected function tearDown() ///////////////////////////////////////// public function testRegisterOrderDetail_該当の受注が存在する場合_削除後に新しい情報が登録される() { - if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 - $params = array( - array( - 'order_id' => '1001', - 'hoge' => '999', // DBに存在しないカラム - 'product_id' => '9001', - 'product_class_id' => '9001', - 'product_name' => '製品名9001' - ) - ); - SC_Helper_Purchase::registerOrderDetail('1001', $params); + $params = array( + array( + 'order_id' => $this->order_ids[0], + 'hoge' => '999', // DBに存在しないカラム + 'product_id' => '9001', + 'product_class_id' => '9001', + 'product_name' => '製品名9001' + ) + ); + SC_Helper_Purchase::registerOrderDetail($this->order_ids[0], $params); - $this->expected['count'] = '2'; // 同じorder_idのものが消されるので1行減る - $this->expected['content'] = array( - 'order_id' => '1001', - 'product_id' => '9001', - 'product_class_id' => '9001', - 'product_name' => '製品名9001', - 'product_code' => null // 古いデータにはあるが、deleteされたので消えている - ); + $this->expected['count'] = '1'; + $this->expected['content'] = array( + 'order_id' => $this->order_ids[0], + 'product_id' => '9001', + 'product_class_id' => '9001', + 'product_name' => '製品名9001', + 'product_code' => null // 古いデータにはあるが、deleteされたので消えている + ); - $this->actual['count'] = $this->objQuery->count('dtb_order_detail'); - $result = $this->objQuery->select( - 'order_id, product_id, product_class_id, product_name, product_code', - 'dtb_order_detail', - 'order_id = ?', - array('1001') - ); - $this->actual['content'] = $result[0]; + $this->actual['count'] = $this->objQuery->count('dtb_order_detail', 'order_id = ?', [$this->order_ids[0]]); + $this->actual['content'] = $this->objQuery->getRow( + 'order_id, product_id, product_class_id, product_name, product_code', + 'dtb_order_detail', + 'order_id = ?', + [$this->order_ids[0]] + ); - $this->verify(); - } + $this->verify(); } - public function testRegisterOrderDetail_該当の受注が存在しない場合_新しい情報が追加登録される() - { - if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 - $params = array( - array( - 'order_id' => '1003', - 'hoge' => '999', // DBに存在しないカラム - 'product_id' => '9003', - 'product_class_id' => '9003', - 'product_name' => '製品名9003' - ) - ); - SC_Helper_Purchase::registerOrderDetail('1003', $params); + public function testRegisterOrderDetail_該当の受注が存在しない場合_新しい情報が追加登録される() + { + $params = array( + array( + 'order_id' => '1003', + 'hoge' => '999', // DBに存在しないカラム + 'product_id' => '9003', + 'product_class_id' => '9003', + 'product_name' => '製品名9003' + ) + ); + SC_Helper_Purchase::registerOrderDetail('1003', $params); - $this->expected['count'] = '4'; - $this->expected['content'] = array( - 'order_id' => '1003', - 'product_id' => '9003', - 'product_class_id' => '9003', - 'product_name' => '製品名9003', - 'product_code' => null - ); + $this->expected['count'] = '1'; + $this->expected['content'] = array( + 'order_id' => '1003', + 'product_id' => '9003', + 'product_class_id' => '9003', + 'product_name' => '製品名9003', + 'product_code' => null + ); - $this->actual['count'] = $this->objQuery->count('dtb_order_detail'); - $result = $this->objQuery->select( - 'order_id, product_id, product_class_id, product_name, product_code', - 'dtb_order_detail', - 'order_id = ?', - array('1003') - ); - $this->actual['content'] = $result[0]; + $this->actual['count'] = $this->objQuery->count('dtb_order_detail', 'order_id = ?', [1003]); + $result = $this->objQuery->select( + 'order_id, product_id, product_class_id, product_name, product_code', + 'dtb_order_detail', + 'order_id = ?', + array('1003') + ); + $this->actual['content'] = $result[0]; - $this->verify(); - } - } + $this->verify(); + } ////////////////////////////////////////// -} \ No newline at end of file +} From 53c0e79062a95df11f3fe845259deed879bda749 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Thu, 13 Jun 2019 15:39:19 +0900 Subject: [PATCH 05/14] =?UTF-8?q?FixtureGenerator=20=E3=81=AE=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E3=81=AB=E4=BC=B4=E3=81=84=E6=9C=AA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/class/fixtures/FixtureGenerator.php | 19 +- .../SC_Helper_Purchase_TestBase.php | 376 ------------------ .../SC_Helper_Purchase_cancelOrderTest.php | 36 +- .../SC_Helper_Purchase_cleanupSessionTest.php | 21 +- ...lper_Purchase_registerShipmentItemTest.php | 26 +- ...elper_Purchase_setShipmentItemTempTest.php | 23 +- 6 files changed, 78 insertions(+), 423 deletions(-) diff --git a/tests/class/fixtures/FixtureGenerator.php b/tests/class/fixtures/FixtureGenerator.php index c3ebeb6990..bff10d5108 100644 --- a/tests/class/fixtures/FixtureGenerator.php +++ b/tests/class/fixtures/FixtureGenerator.php @@ -136,16 +136,17 @@ public function createProductAsArray($product_name = null) * * @param string $product_name 商品名 * @param int $product_class_num 商品規格の生成数 + * @param int $product_type_id 商品種別ID * @return int product_id */ - public function createProduct($product_name = null, $product_class_num = 3) + public function createProduct($product_name = null, $product_class_num = 3, $product_type_id = PRODUCT_TYPE_NORMAL) { $productValues = $this->createProductAsArray($product_name); $this->objQuery->insert('dtb_products', $productValues); if ($product_class_num == 0) { // 0 が指定した場合はデフォルトの商品規格のみを生成する - $this->createProductsClass($productValues['product_id']); + $this->createProductsClass($productValues['product_id'], 0, 0, 0, $product_type_id); } else { // 規格をランダムに抽出する $class_ids = $this->objQuery->getCol('class_id', 'dtb_class', 'del_flg = 0'); @@ -192,9 +193,9 @@ public function createProduct($product_name = null, $product_class_num = 3) if ($classcategory_id2 > 0) { $exist_classcategory_id2[] = $classcategory_id2; } - $this->createProductsClass($productValues['product_id'], $classcategory_id1, $classcategory_id2); + $this->createProductsClass($productValues['product_id'], $classcategory_id1, $classcategory_id2, 0, $product_type_id); } - $this->createProductsClass($productValues['product_id'], 0, 0, 1); + $this->createProductsClass($productValues['product_id'], 0, 0, 1, $product_type_id); } return $productValues['product_id']; @@ -207,9 +208,10 @@ public function createProduct($product_name = null, $product_class_num = 3) * @param int $classcategory_id1 規格分類ID1 * @param int $classcategory_id2 規格分類ID2 * @param int $del_flg 削除フラグ + * @param int $product_type_id 商品種別ID * @return array 商品規格のダミーデータの配列 */ - public function createProductsClassAsArray($product_id, $classcategory_id1 = 0, $classcategory_id2 = 0, $del_flg = 0) + public function createProductsClassAsArray($product_id, $classcategory_id1 = 0, $classcategory_id2 = 0, $del_flg = 0, $product_type_id = PRODUCT_TYPE_NORMAL) { $product_class_id = $this->objQuery->nextVal('dtb_products_class_product_class_id'); $stock = $this->faker->numberBetween(0, 100); @@ -221,7 +223,7 @@ public function createProductsClassAsArray($product_id, $classcategory_id1 = 0, 'classcategory_id1' => $classcategory_id1, 'classcategory_id2' => $classcategory_id2, 'product_code' => 'CODE_'.$product_id.'_'.$classcategory_id1.'_'.$classcategory_id2, - 'product_type_id' => 1, + 'product_type_id' => $product_type_id, 'stock_unlimited' => $stock === 0 ? 1 : 0, 'stock' => $stock, 'price01' => $price01, @@ -243,12 +245,13 @@ public function createProductsClassAsArray($product_id, $classcategory_id1 = 0, * @param int $classcategory_id1 規格分類ID1 * @param int $classcategory_id2 規格分類ID2 * @param int $del_flg 削除フラグ + * @param int $product_type_id 商品種別ID * @return int 商品規格ID */ - public function createProductsClass($product_id, $classcategory_id1 = 0, $classcategory_id2 = 0, $del_flg = 0) + public function createProductsClass($product_id, $classcategory_id1 = 0, $classcategory_id2 = 0, $del_flg = 0, $product_type_id = PRODUCT_TYPE_NORMAL) { - $values = $this->createProductsClassAsArray($product_id, $classcategory_id1, $classcategory_id2, $del_flg); + $values = $this->createProductsClassAsArray($product_id, $classcategory_id1, $classcategory_id2, $del_flg, $product_type_id); $this->objQuery->insert('dtb_products_class', $values); return $values['product_class_id']; diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php index 4da494aaf2..3247081e4c 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php @@ -124,330 +124,6 @@ protected function setUpShippingOnDb() } } - /** - * DBに配送商品情報を設定します。 - */ - protected function setUpShipmentItem() - { - $shipping_items = array( - array( - 'shipping_id' => '1', - 'product_class_id' => '1001', - 'order_id' => '1001', - 'product_name' => '商品名01', - 'price' => '1500' - ), - array( - 'shipping_id' => '1', - 'product_class_id' => '1002', - 'order_id' => '1001', - 'product_name' => '商品名02', - 'price' => '2400' - ) - ); - - $this->objQuery->delete('dtb_shipment_item'); - foreach ($shipping_items as $key => $item) { - $this->objQuery->insert('dtb_shipment_item', $item); - } - $this->setUpProductClass(); - } - - /** - * DBに商品クラス情報を設定します. - */ - protected function setUpProductClass() - { - $product_class = array( - array( - 'update_date' => '2000-01-01 00:00:00', - 'product_class_id' => '1001', - 'product_id' => '1001', - 'product_type_id' => '1', - 'product_code' => 'code1001', - 'classcategory_id1' => '1001', - 'classcategory_id2' => '1002', - 'price01' => '1500', - 'price02' => '1500', - 'creator_id' => '1', - 'stock' => '100', - 'del_flg' => '0' - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'product_class_id' => '1002', - 'product_id' => '1002', - 'product_type_id' => '2', - 'product_code' => 'code1002', - 'price02' => '2500', - 'creator_id' => '1', - 'stock' => '50', - 'del_flg' => '0' - ) - ); - - $this->objQuery->delete('dtb_products_class'); - foreach ($product_class as $key => $item) -{ - $this->objQuery->insert('dtb_products_class', $item); - } - $this->setUpClassCategory(); - $this->setUpProducts(); - } - - /** - * DBに製品カテゴリ情報を登録します. - */ - protected function setUpClassCategory() - { - $class_category = array( - array( - 'update_date' => '2000-01-01 00:00:00', - 'classcategory_id' => '1001', - 'class_id' => '1', - 'creator_id' => '1', - 'name' => 'cat1001' - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'classcategory_id' => '1002', - 'class_id' => '1', - 'creator_id' => '1', - 'name' => 'cat1002' - ) - ); - - // classcategory_id=0のものは削除しない - $this->objQuery->delete('dtb_classcategory', 'classcategory_id <> 0'); - foreach ($class_category as $key => $item) { - $this->objQuery->insert('dtb_classcategory', $item); - } - } - - /** - * DBに製品情報を登録します. - */ - protected function setUpProducts() - { - $products = array( - array( - 'update_date' => '2000-01-01 00:00:00', - 'product_id' => '1001', - 'name' => '製品名1001', - 'del_flg' => '0', - 'creator_id' => '1', - 'status' => '1' - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'product_id' => '1002', - 'name' => '製品名1002', - 'del_flg' => '0', - 'creator_id' => '1', - 'status' => '2' - ) - ); - - $this->objQuery->delete('dtb_products'); - foreach ($products as $key => $item) { - $this->objQuery->insert('dtb_products', $item); - } - } - - /** - * DBに支払方法の情報を登録します. - */ - protected function setUpPaymentOptions() - { - $payment_options = array( - array( - 'deliv_id' => '2001', - 'payment_id' => '2001', - 'rank' => '1' - ), - array( - 'deliv_id' => '1001', - 'payment_id' => '1001', - 'rank' => '2' - ), - array( - 'deliv_id' => '1001', - 'payment_id' => '1002', - 'rank' => '1' - ), - array( - 'deliv_id' => '1003', - 'payment_id' => '3001', - 'rank' => '1' - ), - array( - 'deliv_id' => '1003', - 'payment_id' => '3002', - 'rank' => '2' - ), - array( - 'deliv_id' => '1003', - 'payment_id' => '3003', - 'rank' => '3' - ), - array( - 'deliv_id' => '1003', - 'payment_id' => '3004', - 'rank' => '4' - ), - array( - 'deliv_id' => '1003', - 'payment_id' => '3005', - 'rank' => '5' - ) - ); - - foreach ($payment_options as $key => $item) { - $this->objQuery->insert('dtb_payment_options', $item); - } - } - - /** - * DBに配送業者の情報を登録します. - */ - protected function setUpDeliv() - { - $deliv = array( - array( // 削除フラグON - 'deliv_id' => '2001', - 'product_type_id' => '1001', - 'name' => '配送業者del', - 'rank' => '1', - 'creator_id' => '1', - 'del_flg' => '1', - 'update_date' => '2000-01-01 00:00:00' - ), - array( - 'deliv_id' => '1001', - 'product_type_id' => '1001', - 'name' => '配送業者01', - 'creator_id' => '1', - 'rank' => '2', - 'update_date' => '2000-01-01 00:00:00' - ), - array( - 'deliv_id' => '1002', - 'product_type_id' => '1001', - 'name' => '配送業者02', - 'creator_id' => '1', - 'rank' => '3', - 'update_date' => '2000-01-01 00:00:00' - ), - array( // 商品種別違い - 'deliv_id' => '1004', - 'product_type_id' => '2001', - 'name' => '配送業者21', - 'creator_id' => '1', - 'rank' => '4', - 'update_date' => '2000-01-01 00:00:00' - ), - ); - - foreach ($deliv as $key => $item) { - $this->objQuery->insert('dtb_deliv', $item); - } - } - - /** - * DBにお届け時間の情報を登録します. - */ - protected function setUpDelivTime() - { - $deliv_time = array( - array( - 'deliv_id' => '1002', - 'time_id' => '1', - 'deliv_time' => '午前' - ), - array( - 'deliv_id' => '1001', - 'time_id' => '2', - 'deliv_time' => '午後' - ), - array( - 'deliv_id' => '1001', - 'time_id' => '1', - 'deliv_time' => '午前' - ), - ); - - foreach ($deliv_time as $key => $item) { - $this->objQuery->insert('dtb_delivtime', $item); - } - } - - /** - * DBに支払方法の情報を登録します. - */ - protected function setUpPayment() - { - $payment = array( - array( - 'update_date' => '2000-01-01 00:00:00', - 'payment_id' => '1001', - 'creator_id' => '1', - 'payment_method' => '支払方法1001' - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'payment_id' => '1002', - 'creator_id' => '1', - 'payment_method' => '支払方法1002', - 'del_flg' => '1' - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'payment_id' => '1003', - 'creator_id' => '1', - 'payment_method' => '支払方法1003' - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'payment_id' => '3001', - 'creator_id' => '1', - 'payment_method' => '支払方法3001', - 'del_flg' => '1' - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'payment_id' => '3002', - 'creator_id' => '1', - 'payment_method' => '支払方法3002' - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'payment_id' => '3003', - 'creator_id' => '1', - 'payment_method' => '支払方法3003', - 'rule_max' => 10000 - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'payment_id' => '3004', - 'creator_id' => '1', - 'payment_method' => '支払方法3004', - 'upper_rule' => 20000 - ), - array( - 'update_date' => '2000-01-01 00:00:00', - 'payment_id' => '3005', - 'creator_id' => '1', - 'payment_method' => '支払方法3005', - 'rule_max' => 12000, - 'upper_rule' => 21000 - ) - ); - - foreach ($payment as $key => $item) { - $this->objQuery->insert('dtb_payment', $item); - } - } - /** * DBに受注情報を設定します. */ @@ -489,58 +165,6 @@ protected function setUpOrderTemp($order_ids) { return $this->objQuery->getCol('order_temp_id', 'dtb_order_temp', 'order_id IN ('.implode(',', array_pad([], count($order_ids), '?')).')', $order_ids); } - - /** - * DBに受注詳細を設定します. - */ - protected function setUpOrderDetail($order_ids) - { - $order_detail = array( - array( - 'order_detail_id' => '1001', - 'order_id' => '1001', - 'product_id' => '1002', - 'product_class_id' => '1002', - 'product_code' => 'pc1002', - 'product_name' => '製品名1002', - 'classcategory_name1' => 'cat10021', - 'classcategory_name2' => 'cat10022', - 'price' => 3000, - 'quantity' => 10, - 'point_rate' => 5, - 'tax_rate' => 5, - 'tax_rule' => 0 - ), - array( - 'order_detail_id' => '1002', - 'order_id' => '1001', - 'product_id' => '1001', - 'product_class_id' => '1001', - 'product_code' => 'pc1001', - 'product_name' => '製品名1001', - 'classcategory_name1' => 'cat10011', - 'classcategory_name2' => 'cat10012', - 'price' => 4000, - 'quantity' => 15, - 'point_rate' => 6, - 'tax_rate' => 3, - 'tax_rule' => 1 - ), - array( - 'order_detail_id' => '1003', - 'order_id' => '1002', - 'product_id' => '1001', - 'product_class_id' => '1001', - 'product_name' => '製品名1003' - ) - ); - - $this->objQuery->delete('dtb_order_detail'); - foreach ($order_detail as $item) { - $this->objQuery->insert('dtb_order_detail', $item); - } - } - /** * DBに顧客情報を設定します。 */ diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php index 4ba5d73d03..a0588a7013 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php @@ -32,13 +32,15 @@ */ class SC_Helper_Purchase_cancelOrderTest extends SC_Helper_Purchase_TestBase { - + /** @var array */ + private $arrProductsClasses; private $helper; protected function setUp() { parent::setUp(); - $this->setUpProductClass(); + $product_id = $this->objGenerator->createProduct(null, 2); + $this->arrProductsClasses = $this->objQuery->select('product_class_id, stock', 'dtb_products_class', 'product_id = ? AND del_flg = 0', [$product_id]); $this->helper = new SC_Helper_Purchase_cancelOrderMock(); } @@ -58,7 +60,9 @@ public function testCancelOrder_デフォルトの引数で呼び出した場合 $this->actual['testResult'] = $_SESSION['testResult']; $this->actual['productClass'] = $this->objQuery->select( 'stock', 'dtb_products_class', - 'product_class_id in (?, ?)', array('1001', '1002') + 'product_class_id in (?, ?)', array_map(function ($productsClass) { + return $productsClass['product_class_id']; + }, $this->arrProductsClasses) ); $this->expected = array( 'testResult' => array( @@ -72,9 +76,9 @@ public function testCancelOrder_デフォルトの引数で呼び出した場合 'order_id' => '1001' ) ), - 'productClass' => array( - array('stock' => '105'), - array('stock' => '51') + 'productClass' => array_map(function ($productsClass) { + return ['stock' => $productsClass['stock']]; + }, $this->arrProductsClasses ) ); $this->verify(); @@ -91,7 +95,9 @@ public function testCancelOrder_トランザクションが開始していない $this->actual['testResult'] = $_SESSION['testResult']; $this->actual['productClass'] = $this->objQuery->select( 'stock', 'dtb_products_class', - 'product_class_id in (?, ?)', array('1001', '1002') + 'product_class_id in (?, ?)', array_map(function ($productsClass) { + return $productsClass['product_class_id']; + }, $this->arrProductsClasses) ); $this->expected = array( 'testResult' => array( @@ -105,9 +111,9 @@ public function testCancelOrder_トランザクションが開始していない 'order_id' => '1001' ) ), - 'productClass' => array( - array('stock' => '105'), - array('stock' => '51') + 'productClass' => array_map(function ($productsClass) { + return ['stock' => $productsClass['stock']]; + }, $this->arrProductsClasses ) ); @@ -124,7 +130,9 @@ public function testCancelOrder_削除フラグが立っている場合_DB更新 $this->actual['testResult'] = $_SESSION['testResult']; $this->actual['productClass'] = $this->objQuery->select( 'stock', 'dtb_products_class', - 'product_class_id in (?, ?)', array('1001', '1002') + 'product_class_id in (?, ?)', array_map(function ($productsClass) { + return $productsClass['product_class_id']; + }, $this->arrProductsClasses) ); $this->expected = array( 'testResult' => array( @@ -139,9 +147,9 @@ public function testCancelOrder_削除フラグが立っている場合_DB更新 'order_id' => '1001' ) ), - 'productClass' => array( - array('stock' => '105'), - array('stock' => '51') + 'productClass' => array_map(function ($productsClass) { + return ['stock' => $productsClass['stock']]; + }, $this->arrProductsClasses ) ); diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cleanupSessionTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cleanupSessionTest.php index be5661b2bd..f1c1fe307f 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cleanupSessionTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cleanupSessionTest.php @@ -33,11 +33,18 @@ */ class SC_Helper_Purchase_cleanupSessionTest extends SC_Helper_Purchase_TestBase { - + /** @var int */ + private $product_class_id1; + /** @var int */ + private $product_class_id2; protected function setUp() { parent::setUp(); - $this->setUpProductClass(); + $product_id1 = $this->objGenerator->createProduct(null, 3, PRODUCT_TYPE_NORMAL); + $this->product_class_id1 = $this->objQuery->get('product_class_id', 'dtb_products_class', 'product_id = ?', [$product_id1]); + $product_id2 = $this->objGenerator->createProduct(null, 3, PRODUCT_TYPE_DOWNLOAD); + $this->product_class_id2 = $this->objQuery->get('product_class_id', 'dtb_products_class', 'product_id = ?', [$product_id2]); + } protected function tearDown() @@ -54,11 +61,11 @@ public function testCleanupSession__カートとセッションの配送情報 $customer = new SC_Customer(); // 削除前のデータを設定 - $cartSession->addProduct('1001', 5); // product_type_id=1 - $cartSession->addProduct('1002', 10); // product_type_id=2 + $cartSession->addProduct($this->product_class_id1, 5); // product_type_id=1 + $cartSession->addProduct($this->product_class_id2, 10); // product_type_id=2 $_SESSION['site']['uniqid'] = '100001'; - $helper->cleanupSession('1001', $cartSession, $customer, '1'); + $helper->cleanupSession(1001, $cartSession, $customer, PRODUCT_TYPE_NORMAL); $this->expected = array( 'cart_max_deleted' => 0, @@ -68,8 +75,8 @@ public function testCleanupSession__カートとセッションの配送情報 'multiple_temp' => null ); - $this->actual['cart_max_deleted'] = $cartSession->getMax('1'); - $this->actual['cart_max_notdeleted'] = $cartSession->getMax('2'); + $this->actual['cart_max_deleted'] = $cartSession->getMax(PRODUCT_TYPE_NORMAL); + $this->actual['cart_max_notdeleted'] = $cartSession->getMax(PRODUCT_TYPE_DOWNLOAD); $this->actual['uniqid'] = $_SESSION['site']['uniqid']; $this->actual['shipping'] = $_SESSION['shipping']; $this->actual['multiple_temp'] = $_SESSION['multiple_temp']; diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerShipmentItemTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerShipmentItemTest.php index 3eb2de6c06..62e9fec0a7 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerShipmentItemTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerShipmentItemTest.php @@ -33,11 +33,16 @@ */ class SC_Helper_Purchase_registerShipmentItemTest extends SC_Helper_Purchase_TestBase { + /** @var array */ + private $customer_ids = []; + /** @var array */ + private $order_ids = []; protected function setUp() { parent::setUp(); - $this->setUpShipmentItem(); + $this->customer_ids = $this->setUpCustomer(); + $this->order_ids = $this->setUpOrder($this->customer_ids, [1, 2]); } protected function tearDown() @@ -81,8 +86,8 @@ public function testRegisterShipmentItem_製品クラスIDが入っていない public function testRegisterShipmentItem_製品名等が指定されている場合_指定された値で登録を行う() { // 引数の設定 - $order_id = '1'; - $shipping_id = '1'; + $order_id = $this->order_ids[0]; + $shipping_id = '0'; $arrParams = array( array( 'product_class_id' => '1', @@ -113,6 +118,7 @@ public function testRegisterShipmentItem_製品名等が指定されている場 'order_id = ? and shipping_id = ?', array($order_id, $shipping_id) ); + $this->actual['count'] = count($result); $this->actual['first'] = $result[0]; @@ -122,11 +128,11 @@ public function testRegisterShipmentItem_製品名等が指定されている場 public function testRegisterShipmentItem_製品名等が指定されていない場合_DBからマスタ情報を取得して登録を行う() { // 引数の設定 - $order_id = '1'; + $order_id = $this->order_ids[0]; $shipping_id = '1'; $arrParams = array( array( - 'product_class_id' => '1001' + 'product_class_id' => '1' // 'product_name' => '追加製品名01', // 'product_code' => 'newcode01', // 'classcategory_name1' => 'newcat01', @@ -138,11 +144,11 @@ public function testRegisterShipmentItem_製品名等が指定されていない // 期待値の設定 $this->expected['count'] = 1; $this->expected['first'] = array( - 'product_class_id' => '1001', - 'product_name' => '製品名1001', - 'product_code' => 'code1001', - 'classcategory_name1' => 'cat1001', - 'classcategory_name2' => 'cat1002', + 'product_class_id' => '1', + 'product_name' => 'アイスクリーム', + 'product_code' => 'ice-01', + 'classcategory_name1' => '抹茶', + 'classcategory_name2' => 'S', // TODO 要確認price01, price02を設定しても価格が取れない。実際にはDBから取るケースが無い? //'price' => '1500' 'price' => null diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_setShipmentItemTempTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_setShipmentItemTempTest.php index 646603db65..9b7613f423 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_setShipmentItemTempTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_setShipmentItemTempTest.php @@ -33,13 +33,19 @@ */ class SC_Helper_Purchase_setShipmentItemTempTest extends SC_Helper_Purchase_TestBase { + /** @var int */ + private $product_id; + /** @var array */ + private $productsClass; private $helper; protected function setUp() { parent::setUp(); - $this->setUpProductClass(); - $this->setUpProducts(); + + $this->product_id = $this->objGenerator->createProduct(null); + $this->objQuery->setOrder('product_class_id'); + $this->productsClass = $this->objQuery->getRow('*', 'dtb_products_class', 'product_id = ?', [$this->product_id]); $_SESSION['shipping']['1001']['shipment_item'] = array( '1001' => array('productsClass' => array('price02' => 9000)) @@ -72,16 +78,17 @@ public function testSetShipmentItemTemp_製品情報が既に存在する場合_ public function testSetShipmentItemTemp_製品情報が存在しない場合_DBから取得した値が反映される() { - $this->helper->setShipmentItemTemp('1001', '1002', 10); + $quantity = 10; + $this->helper->setShipmentItemTemp('1001', $this->productsClass['product_class_id'], $quantity); $this->expected = array( 'shipping_id' => '1001', - 'product_class_id' => '1002', - 'quantity' => 10, - 'price' => '2500', - 'total_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax(25000), + 'product_class_id' => $this->productsClass['product_class_id'], + 'quantity' => $quantity, + 'price' => $this->productsClass['price02'], + 'total_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax($this->productsClass['price02']) * $quantity, ); - $result = $_SESSION['shipping']['1001']['shipment_item']['1002']; + $result = $_SESSION['shipping']['1001']['shipment_item'][$this->productsClass['product_class_id']]; unset($result['productsClass']); $this->actual = $result; From bea760d63343cbb18b5642824dd320f611fdadf6 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Thu, 13 Jun 2019 15:53:09 +0900 Subject: [PATCH 06/14] Fix sorting --- .../SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php index a0588a7013..5d522fb6ec 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php @@ -40,6 +40,7 @@ protected function setUp() { parent::setUp(); $product_id = $this->objGenerator->createProduct(null, 2); + $this->objQuery->setOrder('product_class_id'); $this->arrProductsClasses = $this->objQuery->select('product_class_id, stock', 'dtb_products_class', 'product_id = ? AND del_flg = 0', [$product_id]); $this->helper = new SC_Helper_Purchase_cancelOrderMock(); } From cee2406e268aa0b639fcc11159263e73f3e1c5b2 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 14 Jun 2019 10:59:45 +0900 Subject: [PATCH 07/14] =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=81=AE=20order=5Fid?= =?UTF-8?q?=20=E3=81=AE=E9=85=8D=E5=88=97=E3=81=AB=E5=BF=9C=E3=81=98?= =?UTF-8?q?=E3=81=9F=20order=5Ftemp=5Fid=20=E3=82=92=E8=BF=94=E3=81=99?= =?UTF-8?q?=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php index 3247081e4c..ff72fa5394 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php @@ -163,7 +163,9 @@ protected function setUpOrder($customer_ids = [], $product_class_ids = []) */ protected function setUpOrderTemp($order_ids) { - return $this->objQuery->getCol('order_temp_id', 'dtb_order_temp', 'order_id IN ('.implode(',', array_pad([], count($order_ids), '?')).')', $order_ids); + return array_map(function ($order_id) { + return $this->objQuery->get('order_temp_id', 'dtb_order_temp', 'order_id = ?', [$order_id]); + } , $order_ids); } /** * DBに顧客情報を設定します。 From 20b6a4c1dfbf938a8b44f1d6b1a73eede596d089 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 14 Jun 2019 11:17:19 +0900 Subject: [PATCH 08/14] Fix sequence names --- tests/class/fixtures/FixtureGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/class/fixtures/FixtureGenerator.php b/tests/class/fixtures/FixtureGenerator.php index bff10d5108..c8e3579e4c 100644 --- a/tests/class/fixtures/FixtureGenerator.php +++ b/tests/class/fixtures/FixtureGenerator.php @@ -497,7 +497,7 @@ public function createOrderDetailAsArray($product_class_id, $order_id) $classcategory_name2 = $this->objQuery->get('name', 'dtb_classcategory', 'classcategory_id = ?', [$productsClassValues['classcategory_id2']]); $taxRuleValues = SC_Helper_TaxRule_Ex::getTaxRule($productsValues['product_id'], $productsClassValues['product_class_id']); $values = [ - 'order_detail_id' => $this->objQuery->nextVal('dtb_order_detail_order_detail_id_seq'), + 'order_detail_id' => $this->objQuery->nextVal('dtb_order_detail_order_detail_id'), 'order_id' => $order_id, 'product_id' => $productsClassValues['product_id'], 'product_class_id' => $product_class_id, @@ -643,7 +643,7 @@ public function creatShipmentItemFromOrderDetailAsArray($orderDetailValues, $shi */ public function createOrder($customer_id = 0, $product_class_ids = [], $deliv_id = 1, $add_charge = 0, $add_discount = 0, $order_status_id = ORDER_NEW) { - $order_id = $this->objQuery->nextVal('dtb_order_order_id_seq'); + $order_id = $this->objQuery->nextVal('dtb_order_order_id'); if (empty($product_class_ids)) { // 既存の商品規格から選択する From d8ceba3237175e369fa96ecf61c903ff95f0385d Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 14 Jun 2019 12:39:03 +0900 Subject: [PATCH 09/14] Fix del_flg --- .../SC_Helper_Purchase_cleanupSessionTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cleanupSessionTest.php b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cleanupSessionTest.php index f1c1fe307f..3fc8346ec9 100644 --- a/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cleanupSessionTest.php +++ b/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cleanupSessionTest.php @@ -41,9 +41,9 @@ protected function setUp() { parent::setUp(); $product_id1 = $this->objGenerator->createProduct(null, 3, PRODUCT_TYPE_NORMAL); - $this->product_class_id1 = $this->objQuery->get('product_class_id', 'dtb_products_class', 'product_id = ?', [$product_id1]); + $this->product_class_id1 = $this->objQuery->get('product_class_id', 'dtb_products_class', 'product_id = ? AND del_flg = 0', [$product_id1]); $product_id2 = $this->objGenerator->createProduct(null, 3, PRODUCT_TYPE_DOWNLOAD); - $this->product_class_id2 = $this->objQuery->get('product_class_id', 'dtb_products_class', 'product_id = ?', [$product_id2]); + $this->product_class_id2 = $this->objQuery->get('product_class_id', 'dtb_products_class', 'product_id = ? AND del_flg = 0', [$product_id2]); } From b8a5eba8b5babf012fa7a66f28d1c4cc58851537 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 14 Jun 2019 17:11:42 +0900 Subject: [PATCH 10/14] =?UTF-8?q?Codeception=20=E3=81=AE=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E7=94=9F=E6=88=90=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ctests/acceptance/AcceptanceTester.php | 1542 ------------------------ ctests/acceptance/_bootstrap.php | 72 ++ 2 files changed, 72 insertions(+), 1542 deletions(-) delete mode 100644 ctests/acceptance/AcceptanceTester.php diff --git a/ctests/acceptance/AcceptanceTester.php b/ctests/acceptance/AcceptanceTester.php deleted file mode 100644 index 556ea8a962..0000000000 --- a/ctests/acceptance/AcceptanceTester.php +++ /dev/null @@ -1,1542 +0,0 @@ -scenario->runStep(new \Codeception\Step\Action('setHeader', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Sets 'url' configuration parameter to hosts subdomain. - * It does not open a page on subdomain. Use `amOnPage` for that - * - * ``` php - * amOnSubdomain('user'); - * $I->amOnPage('/'); - * // moves to http://user.mysite.com/ - * ?> - * ``` - * - * @param $subdomain - * - * @return mixed - * @see \Codeception\Module\PhpBrowser::amOnSubdomain() - */ - public function amOnSubdomain($subdomain) { - return $this->scenario->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Low-level API method. - * If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly - * - * Example: - * - * ``` php - * executeInGuzzle(function (\GuzzleHttp\Client $client) { - * $client->get('/get', ['query' => ['foo' => 'bar']]); - * }); - * ?> - * ``` - * - * It is not recommended to use this command on a regular basis. - * If Codeception lacks important Guzzle Client methods, implement them and submit patches. - * - * @param callable $function - * @see \Codeception\Module\PhpBrowser::executeInGuzzle() - */ - public function executeInGuzzle($function) { - return $this->scenario->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Authenticates user for HTTP_AUTH - * - * @param $username - * @param $password - * @see \Codeception\Lib\InnerBrowser::amHttpAuthenticated() - */ - public function amHttpAuthenticated($username, $password) { - return $this->scenario->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Opens the page. - * Requires relative uri as parameter - * - * Example: - * - * ``` php - * amOnPage('/'); - * // opens /register page - * $I->amOnPage('/register'); - * ?> - * ``` - * - * @param $page - * @see \Codeception\Lib\InnerBrowser::amOnPage() - */ - public function amOnPage($page) { - return $this->scenario->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Perform a click on link or button. - * Link or button are found by their names or CSS selector. - * Submits a form if button is a submit type. - * - * If link is an image it's found by alt attribute value of image. - * If button is image button is found by it's value - * If link or button can't be found by name they are searched by CSS selector. - * - * The second parameter is a context: CSS or XPath locator to narrow the search. - * - * Examples: - * - * ``` php - * click('Logout'); - * // button of form - * $I->click('Submit'); - * // CSS button - * $I->click('#form input[type=submit]'); - * // XPath - * $I->click('//form/*[@type=submit]'); - * // link in context - * $I->click('Logout', '#nav'); - * // using strict locator - * $I->click(['link' => 'Login']); - * ?> - * ``` - * - * @param $link - * @param $context - * @see \Codeception\Lib\InnerBrowser::click() - */ - public function click($link, $context = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('click', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check if current page contains the text specified. - * Specify the css selector to match only specific region. - * - * Examples: - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up','h1'); // I can suppose it's a signup page - * $I->see('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::see() - */ - public function canSee($text, $selector = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check if current page contains the text specified. - * Specify the css selector to match only specific region. - * - * Examples: - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up','h1'); // I can suppose it's a signup page - * $I->see('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * @see \Codeception\Lib\InnerBrowser::see() - */ - public function see($text, $selector = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('see', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check if current page doesn't contain the text specified. - * Specify the css selector to match only specific region. - * - * Examples: - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSee() - */ - public function cantSee($text, $selector = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check if current page doesn't contain the text specified. - * Specify the css selector to match only specific region. - * - * Examples: - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * @see \Codeception\Lib\InnerBrowser::dontSee() - */ - public function dontSee($text, $selector = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if there is a link with text specified. - * Specify url to match link with exact this url. - * - * Examples: - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param $text - * @param null $url - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeLink() - */ - public function canSeeLink($text, $url = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if there is a link with text specified. - * Specify url to match link with exact this url. - * - * Examples: - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param $text - * @param null $url - * @see \Codeception\Lib\InnerBrowser::seeLink() - */ - public function seeLink($text, $url = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if page doesn't contain the link with text specified. - * Specify url to narrow the results. - * - * Examples: - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * ?> - * ``` - * - * @param $text - * @param null $url - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeLink() - */ - public function cantSeeLink($text, $url = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if page doesn't contain the link with text specified. - * Specify url to narrow the results. - * - * Examples: - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * ?> - * ``` - * - * @param $text - * @param null $url - * @see \Codeception\Lib\InnerBrowser::dontSeeLink() - */ - public function dontSeeLink($text, $url = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current uri contains a value - * - * ``` php - * seeInCurrentUrl('home'); - * // to match: /users/1 - * $I->seeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() - */ - public function canSeeInCurrentUrl($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current uri contains a value - * - * ``` php - * seeInCurrentUrl('home'); - * // to match: /users/1 - * $I->seeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() - */ - public function seeInCurrentUrl($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current uri does not contain a value - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() - */ - public function cantSeeInCurrentUrl($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current uri does not contain a value - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() - */ - public function dontSeeInCurrentUrl($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url is equal to value. - * Unlike `seeInCurrentUrl` performs a strict check. - * - * ``` php - * seeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() - */ - public function canSeeCurrentUrlEquals($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url is equal to value. - * Unlike `seeInCurrentUrl` performs a strict check. - * - * ``` php - * seeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() - */ - public function seeCurrentUrlEquals($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url is not equal to value. - * Unlike `dontSeeInCurrentUrl` performs a strict check. - * - * ``` php - * dontSeeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() - */ - public function cantSeeCurrentUrlEquals($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url is not equal to value. - * Unlike `dontSeeInCurrentUrl` performs a strict check. - * - * ``` php - * dontSeeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() - */ - public function dontSeeCurrentUrlEquals($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url is matches a RegEx value - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() - */ - public function canSeeCurrentUrlMatches($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url is matches a RegEx value - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() - */ - public function seeCurrentUrlMatches($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url does not match a RegEx value - * - * ``` php - * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() - */ - public function cantSeeCurrentUrlMatches($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url does not match a RegEx value - * - * ``` php - * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() - */ - public function dontSeeCurrentUrlMatches($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Takes a parameters from current URI by RegEx. - * If no url provided returns full URI. - * - * ``` php - * grabFromCurrentUrl('~$/user/(\d+)/~'); - * $uri = $I->grabFromCurrentUrl(); - * ?> - * ``` - * - * @param null $uri - * - * @internal param $url - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() - */ - public function grabFromCurrentUrl($uri = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Assert if the specified checkbox is checked. - * Use css selector or xpath to match. - * - * Example: - * - * ``` php - * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. - * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); - * ?> - * ``` - * - * @param $checkbox - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() - */ - public function canSeeCheckboxIsChecked($checkbox) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Assert if the specified checkbox is checked. - * Use css selector or xpath to match. - * - * Example: - * - * ``` php - * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. - * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); - * ?> - * ``` - * - * @param $checkbox - * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() - */ - public function seeCheckboxIsChecked($checkbox) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Assert if the specified checkbox is unchecked. - * Use css selector or xpath to match. - * - * Example: - * - * ``` php - * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. - * ?> - * ``` - * - * @param $checkbox - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() - */ - public function cantSeeCheckboxIsChecked($checkbox) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Assert if the specified checkbox is unchecked. - * Use css selector or xpath to match. - * - * Example: - * - * ``` php - * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. - * ?> - * ``` - * - * @param $checkbox - * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() - */ - public function dontSeeCheckboxIsChecked($checkbox) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea contains value. - * Field is matched either by label or CSS or Xpath - * - * Example: - * - * ``` php - * seeInField('Body','Type your comment here'); - * $I->seeInField('form textarea[name=body]','Type your comment here'); - * $I->seeInField('form input[type=hidden]','hidden_value'); - * $I->seeInField('#searchform input','Search'); - * $I->seeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInField() - */ - public function canSeeInField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea contains value. - * Field is matched either by label or CSS or Xpath - * - * Example: - * - * ``` php - * seeInField('Body','Type your comment here'); - * $I->seeInField('form textarea[name=body]','Type your comment here'); - * $I->seeInField('form input[type=hidden]','hidden_value'); - * $I->seeInField('#searchform input','Search'); - * $I->seeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::seeInField() - */ - public function seeInField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea doesn't contain value. - * Field is matched either by label or CSS or Xpath - * Example: - * - * ``` php - * dontSeeInField('Body','Type your comment here'); - * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); - * $I->dontSeeInField('form input[type=hidden]','hidden_value'); - * $I->dontSeeInField('#searchform input','Search'); - * $I->dontSeeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInField() - */ - public function cantSeeInField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea doesn't contain value. - * Field is matched either by label or CSS or Xpath - * Example: - * - * ``` php - * dontSeeInField('Body','Type your comment here'); - * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); - * $I->dontSeeInField('form input[type=hidden]','hidden_value'); - * $I->dontSeeInField('#searchform input','Search'); - * $I->dontSeeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::dontSeeInField() - */ - public function dontSeeInField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Submits a form located on page. - * Specify the form by it's css or xpath selector. - * Fill the form fields values as array. - * - * Skipped fields will be filled by their values from page. - * You don't need to click the 'Submit' button afterwards. - * This command itself triggers the request to form's action. - * - * Examples: - * - * ``` php - * submitForm('#login', array('login' => 'davert', 'password' => '123456')); - * - * ``` - * - * For sample Sign Up form: - * - * ``` html - *
- * Login:
- * Password:
- * Do you agree to out terms?
- * Select pricing plan - * - *
- * ``` - * I can write this: - * - * ``` php - * submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true))); - * - * ``` - * Note, that pricing plan will be set to Paid, as it's selected on page. - * - * @param $selector - * @param $params - * @see \Codeception\Lib\InnerBrowser::submitForm() - */ - public function submitForm($selector, $params) { - return $this->scenario->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Fills a text field or textarea with value. - * - * Example: - * - * ``` php - * fillField("//input[@type='text']", "Hello World!"); - * $I->fillField(['name' => 'email'], 'jon@mail.com'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::fillField() - */ - public function fillField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\Action('fillField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Selects an option in select tag or in radio button group. - * - * Example: - * - * ``` php - * selectOption('form select[name=account]', 'Premium'); - * $I->selectOption('form input[name=payment]', 'Monthly'); - * $I->selectOption('//form/select[@name=account]', 'Monthly'); - * ?> - * ``` - * - * Can select multiple options if second argument is array: - * - * ``` php - * selectOption('Which OS do you use?', array('Windows','Linux')); - * ?> - * ``` - * - * @param $select - * @param $option - * @see \Codeception\Lib\InnerBrowser::selectOption() - */ - public function selectOption($select, $option) { - return $this->scenario->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Ticks a checkbox. - * For radio buttons use `selectOption` method. - * - * Example: - * - * ``` php - * checkOption('#agree'); - * ?> - * ``` - * - * @param $option - * @see \Codeception\Lib\InnerBrowser::checkOption() - */ - public function checkOption($option) { - return $this->scenario->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Unticks a checkbox. - * - * Example: - * - * ``` php - * uncheckOption('#notify'); - * ?> - * ``` - * - * @param $option - * @see \Codeception\Lib\InnerBrowser::uncheckOption() - */ - public function uncheckOption($option) { - return $this->scenario->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Attaches file from Codeception data directory to upload field. - * - * Example: - * - * ``` php - * attachFile('input[@type="file"]', 'prices.xls'); - * ?> - * ``` - * - * @param $field - * @param $filename - * @see \Codeception\Lib\InnerBrowser::attachFile() - */ - public function attachFile($field, $filename) { - return $this->scenario->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * If your page triggers an ajax request, you can perform it manually. - * This action sends a GET ajax request with specified params. - * - * See ->sendAjaxPostRequest for examples. - * - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() - */ - public function sendAjaxGetRequest($uri, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * If your page triggers an ajax request, you can perform it manually. - * This action sends a POST ajax request with specified params. - * Additional params can be passed as array. - * - * Example: - * - * Imagine that by clicking checkbox you trigger ajax request which updates user settings. - * We emulate that click by running this ajax request manually. - * - * ``` php - * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST - * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET - * - * ``` - * - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() - */ - public function sendAjaxPostRequest($uri, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * If your page triggers an ajax request, you can perform it manually. - * This action sends an ajax request with specified method and params. - * - * Example: - * - * You need to perform an ajax request specifying the HTTP method. - * - * ``` php - * sendAjaxRequest('PUT', /posts/7', array('title' => 'new title'); - * - * ``` - * - * @param $method - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() - */ - public function sendAjaxRequest($method, $uri, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Finds and returns text contents of element. - * Element is searched by CSS selector, XPath or matcher by regex. - * - * Example: - * - * ``` php - * grabTextFrom('h1'); - * $heading = $I->grabTextFrom('descendant-or-self::h1'); - * $value = $I->grabTextFrom('~ - * ``` - * - * @param $cssOrXPathOrRegex - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabTextFrom() - */ - public function grabTextFrom($cssOrXPathOrRegex) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs attribute value from an element. - * Fails if element is not found. - * - * ``` php - * grabAttributeFrom('#tooltip', 'title'); - * ?> - * ``` - * - * - * @param $cssOrXpath - * @param $attribute - * @internal param $element - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() - */ - public function grabAttributeFrom($cssOrXpath, $attribute) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $field - * - * @return array|mixed|null|string - * @see \Codeception\Lib\InnerBrowser::grabValueFrom() - */ - public function grabValueFrom($field) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Sets a cookie. - * - * @param $cookie - * @param $value - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::setCookie() - */ - public function setCookie($name, $val) { - return $this->scenario->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs a cookie value. - * - * @param $cookie - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabCookie() - */ - public function grabCookie($name) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that cookie is set. - * - * @param $cookie - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCookie() - */ - public function canSeeCookie($name) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that cookie is set. - * - * @param $cookie - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeCookie() - */ - public function seeCookie($name) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that cookie doesn't exist - * - * @param $cookie - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() - */ - public function cantSeeCookie($name) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that cookie doesn't exist - * - * @param $cookie - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() - */ - public function dontSeeCookie($name) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Unsets cookie - * - * @param $cookie - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::resetCookie() - */ - public function resetCookie($name) { - return $this->scenario->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if element exists on a page, matching it by CSS or XPath. - * You can also specify expected attributes of this element. - * - * ``` php - * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @return - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeElement() - */ - public function canSeeElement($selector, $attributes = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if element exists on a page, matching it by CSS or XPath. - * You can also specify expected attributes of this element. - * - * ``` php - * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @return - * @see \Codeception\Lib\InnerBrowser::seeElement() - */ - public function seeElement($selector, $attributes = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath - * You can also specify expected attributes of this element. - * - * Example: - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeElement() - */ - public function cantSeeElement($selector, $attributes = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if element does not exist (or is visible) on a page, matching it by CSS or XPath - * You can also specify expected attributes of this element. - * - * Example: - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * @see \Codeception\Lib\InnerBrowser::dontSeeElement() - */ - public function dontSeeElement($selector, $attributes = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if option is selected in select field. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() - */ - public function canSeeOptionIsSelected($select, $optionText) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if option is selected in select field. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() - */ - public function seeOptionIsSelected($select, $optionText) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if option is not selected in select field. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() - */ - public function cantSeeOptionIsSelected($select, $optionText) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if option is not selected in select field. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() - */ - public function dontSeeOptionIsSelected($select, $optionText) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that current page has 404 response status code. - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seePageNotFound() - */ - public function canSeePageNotFound() { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that current page has 404 response status code. - * @see \Codeception\Lib\InnerBrowser::seePageNotFound() - */ - public function seePageNotFound() { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that response code is equal to value provided. - * - * @param $code - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() - */ - public function canSeeResponseCodeIs($code) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that response code is equal to value provided. - * - * @param $code - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() - */ - public function seeResponseCodeIs($code) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that page title contains text. - * - * ``` php - * seeInTitle('Blog - Post #1'); - * ?> - * ``` - * - * @param $title - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInTitle() - */ - public function canSeeInTitle($title) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that page title contains text. - * - * ``` php - * seeInTitle('Blog - Post #1'); - * ?> - * ``` - * - * @param $title - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeInTitle() - */ - public function seeInTitle($title) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that page title does not contain text. - * - * @param $title - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() - */ - public function cantSeeInTitle($title) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that page title does not contain text. - * - * @param $title - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() - */ - public function dontSeeInTitle($title) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); - } -} diff --git a/ctests/acceptance/_bootstrap.php b/ctests/acceptance/_bootstrap.php index e71787bcfd..960f8a9d4d 100644 --- a/ctests/acceptance/_bootstrap.php +++ b/ctests/acceptance/_bootstrap.php @@ -1,5 +1,77 @@ count('dtb_customer'); + +if ($num < $config['fixture_customer_num']) { + $num = $config['fixture_customer_num'] - $num; + for ($i = 0; $i < $num; $i++) { + $progress('Generating Customers'); + $objGenerator->createCustomer(); + } + $progress('Generating Customers'); + $objGenerator->createCustomer(null, ['status' => '1']); // non-active member +} + +$num = $objQuery->count('dtb_products'); +$product_ids = []; +// 受注生成件数 + 初期データの商品が生成されているはず +if ($num < ($config['fixture_product_num'] + 2)) { + // 規格なしも含め $config['fixture_product_num'] の分だけ生成する + for ($i = 0; $i < $config['fixture_product_num'] - 1; $i++) { + $progress('Generating Products'); + $product_ids[] = $objGenerator->createProduct(); + } + $progress('Generating Products'); + $product_ids[] = $objGenerator->createProduct('規格なし商品', 0); + $category_ids = $objGenerator->createCategories(); + + foreach ($product_ids as $product_id) { + $objGenerator->relateProductCategories($product_id, array_rand($category_ids, $faker->numberBetween(1, count($category_ids) - 1))); + } + $objDb = new SC_Helper_DB_Ex(); + $objDb->sfCountCategory($objQuery); +} + +$num = $objQuery->count('dtb_order'); +$customer_ids = $objQuery->getCol('customer_id', 'dtb_customer', 'del_flg = 0'); +$product_class_ids = $objQuery->getCol('product_class_id', 'dtb_products_class', 'del_flg = 0'); +if ($num < $config['fixture_order_num']) { + foreach ($customer_ids as $customer_id) { + $target_product_class_ids = $product_class_ids[$faker->numberBetween(0, count($product_class_ids) - 1)]; + $charge = $faker->randomNumber(4); + $discount = $faker->numberBetween(0, $charge); + $order_count_per_customer = $objQuery->count('dtb_order', 'customer_id = ?', [$customer_id]); + for ($i = $order_count_per_customer; $i < $config['fixture_order_num'] / count($customer_ids); $i++) { + $progress('Generating Orders'); + $objGenerator->createOrder($customer_id, $target_product_class_ids, 1, $charge, $discount, $faker->numberBetween(1, 7)); + } + } +} From bfdbd0b8b415147c4a53ed66bdc917fc7d42e198 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 14 Jun 2019 18:22:14 +0900 Subject: [PATCH 11/14] =?UTF-8?q?https://github.com/EC-CUBE/eccube-2=5F13/?= =?UTF-8?q?pull/273=20=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ctests/acceptance/ProductListCept.php | 23 +++++++++++++++++++++++ ctests/acceptance/_bootstrap.php | 5 ++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ctests/acceptance/ProductListCept.php b/ctests/acceptance/ProductListCept.php index cc341dc472..82f95fec41 100644 --- a/ctests/acceptance/ProductListCept.php +++ b/ctests/acceptance/ProductListCept.php @@ -5,10 +5,33 @@ $I->see('EC-CUBE発!世界中を旅して見つけた立方体グルメを立方隊長が直送!'); $I->seeElement('#site_description'); +$I->expect('50件まで一覧表示する'); +$I->selectOption(['css' => '#page_navi_top > div > div.change > select'], '50件'); +$all_products = $I->grabMultiple(['css' => '#undercolumn > form > div > div.listrightbloc > h3 > a']); +if (count($all_products) <= 50) { + $I->see(count($all_products).'件', ['css' => '#undercolumn > div > span.attention']); +} else { + $I->comment('50件超過の商品が存在します'); + $I->dontSee(count($all_products).'件', ['css' => '#undercolumn > div > span.attention']); +} + $I->dontSeeElement('.error'); // 食品 $I->amOnPage('/products/list.php?category_id=3'); +$I->expect('50件まで一覧表示する'); +$I->selectOption(['css' => '#page_navi_top > div > div.change > select'], '50件'); + +$I->expect('カテゴリにアクセスすると商品が絞り込まれる'); +$I->comment('see https://github.com/EC-CUBE/eccube-2_13/pull/273'); +$products_in_category = $I->grabMultiple(['css' => '#undercolumn > form > div > div.listrightbloc > h3 > a']); + +if (count($products_in_category) <= 50) { + $I->see(count($products_in_category).'件', ['css' => '#undercolumn > div > span.attention']); +} else { + $I->comment('50件超過の商品が存在します'); + $I->dontSee(count($products_in_category).'件', ['css' => '#undercolumn > div > span.attention']); +} $I->dontSeeElement('.error'); diff --git a/ctests/acceptance/_bootstrap.php b/ctests/acceptance/_bootstrap.php index 960f8a9d4d..d20f72bc63 100644 --- a/ctests/acceptance/_bootstrap.php +++ b/ctests/acceptance/_bootstrap.php @@ -12,7 +12,7 @@ $objGenerator = new FixtureGenerator($objQuery, 'ja_JP'); Codeception\Util\Fixtures::add('objGenerator', $objGenerator); -$progress = (function () { +$progress = function () { $current = ''; return function ($key) use (&$current) { @@ -25,8 +25,7 @@ } echo '.'; }; -})(); - +}; $num = $objQuery->count('dtb_customer'); From 8eb4f013210020cbc677a1e77316d26376d7851c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 14 Jun 2019 19:18:29 +0900 Subject: [PATCH 12/14] =?UTF-8?q?Codeception=20=E3=81=8C=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=86=E3=81=9F=E3=82=81=E3=81=AE=E5=AF=BE=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - html/require.php に依存しないよう修正 - bootstrap でセッションをロードしないよう修正 --- tests/require.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/require.php b/tests/require.php index a46d31e87b..c6215c22b6 100644 --- a/tests/require.php +++ b/tests/require.php @@ -4,7 +4,11 @@ if (!class_exists('PHPUnit_Framework_TestCase')) { class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase'); } -require_once __DIR__."/../html/require.php"; + +defined('HTML_REALDIR') or define('HTML_REALDIR', __DIR__.'/../html/'); +require_once __DIR__.'/../html/define.php'; +defined('DATA_REALDIR') or define('DATA_REALDIR', HTML_REALDIR . HTML2DATA_DIR); +require_once __DIR__.'/../data/app_initial.php'; $classMap = function ($dir) { $map = []; From fc6c10c6ad98ca1a02136dd1c9d08b340e87069d Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 14 Jun 2019 19:39:41 +0900 Subject: [PATCH 13/14] Fix progress --- ctests/acceptance/_bootstrap.php | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/ctests/acceptance/_bootstrap.php b/ctests/acceptance/_bootstrap.php index d20f72bc63..47e5c93f04 100644 --- a/ctests/acceptance/_bootstrap.php +++ b/ctests/acceptance/_bootstrap.php @@ -12,46 +12,33 @@ $objGenerator = new FixtureGenerator($objQuery, 'ja_JP'); Codeception\Util\Fixtures::add('objGenerator', $objGenerator); -$progress = function () { - $current = ''; - - return function ($key) use (&$current) { - if ($current !== $key) { - if ($current !== '') { - echo PHP_EOL; - } - echo $key.' '; - $current = $key; - } - echo '.'; - }; -}; - $num = $objQuery->count('dtb_customer'); if ($num < $config['fixture_customer_num']) { $num = $config['fixture_customer_num'] - $num; + echo 'Generating Customers'; for ($i = 0; $i < $num; $i++) { - $progress('Generating Customers'); $objGenerator->createCustomer(); + echo '.'; } - $progress('Generating Customers'); $objGenerator->createCustomer(null, ['status' => '1']); // non-active member + echo '.'.PHP_EOL; } $num = $objQuery->count('dtb_products'); $product_ids = []; // 受注生成件数 + 初期データの商品が生成されているはず if ($num < ($config['fixture_product_num'] + 2)) { + echo 'Generating Products'; // 規格なしも含め $config['fixture_product_num'] の分だけ生成する for ($i = 0; $i < $config['fixture_product_num'] - 1; $i++) { - $progress('Generating Products'); $product_ids[] = $objGenerator->createProduct(); + echo '.'; } - $progress('Generating Products'); $product_ids[] = $objGenerator->createProduct('規格なし商品', 0); - $category_ids = $objGenerator->createCategories(); + echo '.'.PHP_EOL; + $category_ids = $objGenerator->createCategories(); foreach ($product_ids as $product_id) { $objGenerator->relateProductCategories($product_id, array_rand($category_ids, $faker->numberBetween(1, count($category_ids) - 1))); } @@ -63,14 +50,16 @@ $customer_ids = $objQuery->getCol('customer_id', 'dtb_customer', 'del_flg = 0'); $product_class_ids = $objQuery->getCol('product_class_id', 'dtb_products_class', 'del_flg = 0'); if ($num < $config['fixture_order_num']) { + echo 'Generating Orders'; foreach ($customer_ids as $customer_id) { $target_product_class_ids = $product_class_ids[$faker->numberBetween(0, count($product_class_ids) - 1)]; $charge = $faker->randomNumber(4); $discount = $faker->numberBetween(0, $charge); $order_count_per_customer = $objQuery->count('dtb_order', 'customer_id = ?', [$customer_id]); for ($i = $order_count_per_customer; $i < $config['fixture_order_num'] / count($customer_ids); $i++) { - $progress('Generating Orders'); $objGenerator->createOrder($customer_id, $target_product_class_ids, 1, $charge, $discount, $faker->numberBetween(1, 7)); + echo '.'; } } + echo PHP_EOL; } From 6400dd11b8967af33b47a4d21e771ccdd964455c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 14 Jun 2019 19:53:15 +0900 Subject: [PATCH 14/14] Add config.ini --- ctests/acceptance/config.ini | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 ctests/acceptance/config.ini diff --git a/ctests/acceptance/config.ini b/ctests/acceptance/config.ini new file mode 100644 index 0000000000..d83b6b39cd --- /dev/null +++ b/ctests/acceptance/config.ini @@ -0,0 +1,4 @@ +fixture_customer_num = 10 ; 各カスタマー作成時に注文を1つづつつくる。さらに、注文を作る際に1つ商品を作る + ; フロント側のテストとして3以上が必要 +fixture_product_num = 20 +fixture_order_num = 25 \ No newline at end of file