[22202] | 1 | <?php |
---|
| 2 | |
---|
| 3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
| 4 | require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php"); |
---|
| 5 | /* |
---|
| 6 | * This file is part of EC-CUBE |
---|
| 7 | * |
---|
[22206] | 8 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
[22202] | 9 | * |
---|
| 10 | * http://www.lockon.co.jp/ |
---|
| 11 | * |
---|
| 12 | * This program is free software; you can redistribute it and/or |
---|
| 13 | * modify it under the terms of the GNU General Public License |
---|
| 14 | * as published by the Free Software Foundation; either version 2 |
---|
| 15 | * of the License, or (at your option) any later version. |
---|
| 16 | * |
---|
| 17 | * This program is distributed in the hope that it will be useful, |
---|
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 20 | * GNU General Public License for more details. |
---|
| 21 | * |
---|
| 22 | * You should have received a copy of the GNU General Public License |
---|
| 23 | * along with this program; if not, write to the Free Software |
---|
| 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 25 | */ |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * SC_Helper_Purchase::registerOrderDetail()のテストクラス. |
---|
| 29 | * |
---|
| 30 | * @author Hiroko Tamagawa |
---|
| 31 | * @version $Id$ |
---|
| 32 | */ |
---|
[22567] | 33 | class SC_Helper_Purchase_registerOrderDetailTest extends SC_Helper_Purchase_TestBase |
---|
| 34 | { |
---|
[22202] | 35 | |
---|
[22567] | 36 | protected function setUp() |
---|
| 37 | { |
---|
[22202] | 38 | parent::setUp(); |
---|
| 39 | $this->setUpOrderDetail(); |
---|
| 40 | } |
---|
| 41 | |
---|
[22567] | 42 | protected function tearDown() |
---|
| 43 | { |
---|
[22202] | 44 | parent::tearDown(); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | ///////////////////////////////////////// |
---|
[22567] | 48 | public function testRegisterOrderDetail_該当の受注が存在する場合_削除後に新しい情報が登録される() |
---|
| 49 | { |
---|
[22735] | 50 | if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 |
---|
| 51 | $params = array( |
---|
| 52 | array( |
---|
| 53 | 'order_id' => '1001', |
---|
| 54 | 'hoge' => '999', // DBに存在しないカラム |
---|
| 55 | 'product_id' => '9001', |
---|
| 56 | 'product_class_id' => '9001', |
---|
| 57 | 'product_name' => '製品名9001' |
---|
| 58 | ) |
---|
| 59 | ); |
---|
| 60 | SC_Helper_Purchase::registerOrderDetail('1001', $params); |
---|
[22202] | 61 | |
---|
[22735] | 62 | $this->expected['count'] = '2'; // 同じorder_idのものが消されるので1行減る |
---|
| 63 | $this->expected['content'] = array( |
---|
| 64 | 'order_id' => '1001', |
---|
| 65 | 'product_id' => '9001', |
---|
| 66 | 'product_class_id' => '9001', |
---|
| 67 | 'product_name' => '製品名9001', |
---|
| 68 | 'product_code' => null // 古いデータにはあるが、deleteされたので消えている |
---|
| 69 | ); |
---|
[22202] | 70 | |
---|
[22735] | 71 | $this->actual['count'] = $this->objQuery->count('dtb_order_detail'); |
---|
| 72 | $result = $this->objQuery->select( |
---|
| 73 | 'order_id, product_id, product_class_id, product_name, product_code', |
---|
| 74 | 'dtb_order_detail', |
---|
| 75 | 'order_id = ?', |
---|
| 76 | array('1001') |
---|
| 77 | ); |
---|
| 78 | $this->actual['content'] = $result[0]; |
---|
[22202] | 79 | |
---|
[22735] | 80 | $this->verify(); |
---|
| 81 | } |
---|
[22202] | 82 | } |
---|
| 83 | |
---|
[22735] | 84 | public function testRegisterOrderDetail_該当の受注が存在しない場合_新しい情報が追加登録される() |
---|
| 85 | { |
---|
| 86 | if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 |
---|
| 87 | $params = array( |
---|
| 88 | array( |
---|
| 89 | 'order_id' => '1003', |
---|
| 90 | 'hoge' => '999', // DBに存在しないカラム |
---|
| 91 | 'product_id' => '9003', |
---|
| 92 | 'product_class_id' => '9003', |
---|
| 93 | 'product_name' => '製品名9003' |
---|
| 94 | ) |
---|
| 95 | ); |
---|
| 96 | SC_Helper_Purchase::registerOrderDetail('1003', $params); |
---|
[22202] | 97 | |
---|
[22735] | 98 | $this->expected['count'] = '4'; |
---|
| 99 | $this->expected['content'] = array( |
---|
| 100 | 'order_id' => '1003', |
---|
| 101 | 'product_id' => '9003', |
---|
| 102 | 'product_class_id' => '9003', |
---|
| 103 | 'product_name' => '製品名9003', |
---|
| 104 | 'product_code' => null |
---|
| 105 | ); |
---|
[22202] | 106 | |
---|
[22735] | 107 | $this->actual['count'] = $this->objQuery->count('dtb_order_detail'); |
---|
| 108 | $result = $this->objQuery->select( |
---|
| 109 | 'order_id, product_id, product_class_id, product_name, product_code', |
---|
| 110 | 'dtb_order_detail', |
---|
| 111 | 'order_id = ?', |
---|
| 112 | array('1003') |
---|
| 113 | ); |
---|
| 114 | $this->actual['content'] = $result[0]; |
---|
[22202] | 115 | |
---|
[22735] | 116 | $this->verify(); |
---|
| 117 | } |
---|
| 118 | } |
---|
[22202] | 119 | ////////////////////////////////////////// |
---|
| 120 | |
---|
[22735] | 121 | } |
---|