Changeset 22727
- Timestamp:
- 2013/03/10 12:54:59 (10 years ago)
- Location:
- branches/camp/camp-2_13-tests
- Files:
-
- 2 added
- 3 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/camp/camp-2_13-tests/data/class/helper/SC_Helper_Maker.php
r22578 r22727 38 38 * @return array 39 39 */ 40 public function get ($maker_id, $has_deleted = false)40 public function getMaker($maker_id, $has_deleted = false) 41 41 { 42 42 $objQuery =& SC_Query_Ex::getSingletonInstance(); … … 93 93 * @return multiple 登録成功:メーカーID, 失敗:FALSE 94 94 */ 95 public function save ($sqlval)95 public function saveMaker($sqlval) 96 96 { 97 97 $objQuery =& SC_Query_Ex::getSingletonInstance(); -
branches/camp/camp-2_13-tests/data/class/pages/admin/products/LC_Page_Admin_Products_Maker.php
r22578 r22727 116 116 // 編集前処理 117 117 case 'pre_edit': 118 $maker = $objMaker->get ($maker_id);118 $maker = $objMaker->getMaker($maker_id); 119 119 $objFormParam->setParam($maker); 120 120 … … 190 190 $sqlval['maker_id'] = $maker_id; 191 191 $sqlval['creator_id'] = $_SESSION['member_id']; 192 return $objMaker->save ($sqlval);192 return $objMaker->saveMaker($sqlval); 193 193 } 194 194 … … 208 208 if (!SC_Utils_Ex::sfIsInt($arrForm['maker_id']) 209 209 || SC_Utils_Ex::sfIsZeroFilling($arrForm['maker_id']) 210 || !$objMaker->get ($arrForm['maker_id'])210 || !$objMaker->getMaker($arrForm['maker_id']) 211 211 ) { 212 212 // maker_idが指定されていて、且つその値が不正と思われる場合はエラー -
branches/camp/camp-2_13-tests/data/class/pages/products/LC_Page_Products_List.php
r22607 r22727 317 317 if (strlen($arrSearchData['maker_id']) > 0) { 318 318 $objMaker = new SC_Helper_Maker_Ex(); 319 $maker = $objMaker->get ($arrSearchData['maker_id']);319 $maker = $objMaker->getMaker($arrSearchData['maker_id']); 320 320 $arrSearch['maker'] = $maker['name']; 321 321 } -
branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_Maker/SC_Helper_Maker_TestBase.php
r22656 r22727 25 25 */ 26 26 /** 27 * SC_Helper_ BestProductsのテストの基底クラス.27 * SC_Helper_Makerのテストの基底クラス. 28 28 * 29 29 * … … 31 31 * @version $Id$ 32 32 */ 33 class SC_Helper_ BestProducts_TestBase extends Common_TestCase33 class SC_Helper_Maker_TestBase extends Common_TestCase 34 34 { 35 35 … … 48 48 * DBにお勧め情報を登録します. 49 49 */ 50 protected function setUp BestProducts()50 protected function setUpMaker() 51 51 { 52 $ products = array(52 $makers = array( 53 53 array( 54 'best_id' => '1001', 55 'product_id'=>'2', 56 'category_id' => '0', 54 'maker_id' => '1001', 55 'name' => 'ソニン', 57 56 'rank' => '1', 58 'title' => 'タイトルですよ',59 'comment' => 'コメントですよ',60 57 'creator_id' => '1', 61 58 'create_date' => '2000-01-01 00:00:00', … … 64 61 ), 65 62 array( 66 'best_id' => '1002', 67 'product_id'=>'1', 68 'category_id' => '0', 63 'maker_id' => '1002', 64 'name' => 'パソナニック', 69 65 'rank' => '2', 70 'title' => 'タイトルですよ', 71 'comment' => 'コメントですよ', 72 'creator_id' => '1', 66 'creator_id' => '2', 73 67 'create_date' => '2000-01-01 00:00:00', 74 68 'update_date' => '2000-01-01 00:00:00', … … 76 70 ), 77 71 array( 78 'best_id' => '1003', 79 'product_id'=>'3', 80 'category_id' => '1', 72 'maker_id' => '1003', 73 'name' => 'シャンプー', 81 74 'rank' => '3', 82 'title' => 'タイトルですよ3', 83 'comment' => 'コメントですよ3', 84 'creator_id' => '3', 75 'creator_id' => '1', 76 'create_date' => '2000-01-01 00:00:00', 77 'update_date' => '2000-01-01 00:00:00', 78 'del_flg' => '0' 79 ), 80 array( 81 'maker_id' => '1004', 82 'name' => 'MEC', 83 'rank' => '4', 84 'creator_id' => '1', 85 85 'create_date' => '2000-01-01 00:00:00', 86 86 'update_date' => '2000-01-01 00:00:00', … … 89 89 ); 90 90 91 $this->objQuery->delete('dtb_ best_products');92 foreach ($ products as $item) {93 $this->objQuery->insert('dtb_ best_products', $item);91 $this->objQuery->delete('dtb_maker'); 92 foreach ($makers as $item) { 93 $this->objQuery->insert('dtb_maker', $item); 94 94 } 95 95 } 96 96 97 //dtb_best_productsを全て削除する 98 protected function deleteAllBestProducts(){ 99 $this->objQuery->delete('dtb_best_products'); 97 protected function deleteAllMaker(){ 98 $this->objQuery->delete('dtb_maker'); 100 99 } 101 100 } -
branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_Maker/SC_Helper_Maker_getListTest.php
r22660 r22727 2 2 3 3 $HOME = realpath(dirname(__FILE__)) . "/../../../.."; 4 require_once($HOME . "/tests/class/helper/SC_Helper_ BestProducts/SC_Helper_BestProducts_TestBase.php");4 require_once($HOME . "/tests/class/helper/SC_Helper_Maker/SC_Helper_Maker_TestBase.php"); 5 5 /* 6 6 * This file is part of EC-CUBE … … 26 26 27 27 /** 28 * SC_Helper_ BestProducts::getList()のテストクラス.28 * SC_Helper_Maker::getList()のテストクラス. 29 29 * 30 30 * @author hiroshi kakuta 31 31 */ 32 class SC_Helper_ BestProducts_getListTest extends SC_Helper_BestProducts_TestBase32 class SC_Helper_Maker_getListTest extends SC_Helper_Maker_TestBase 33 33 { 34 35 var $objHelperMaker; 36 34 37 protected function setUp() 35 38 { 36 39 parent::setUp(); 40 $this->objHelperMaker = new SC_Helper_Maker_Ex(); 41 $this->setUpMaker(); 42 37 43 38 44 } … … 48 54 { 49 55 50 $this->deleteAll BestProducts();56 $this->deleteAllMaker(); 51 57 52 58 $this->expected = array(); 53 $this->actual = SC_Helper_BestProducts::getList();59 $this->actual = $this->objHelperMaker->getList(); 54 60 55 61 $this->verify(); … … 58 64 public function testGetList_データがある場合_想定した結果が返る(){ 59 65 60 $this->setUpBestProducts();61 62 63 66 $this->expected = array( 64 0=>array( 65 'best_id' => '1001', 66 'product_id'=>'2', 67 'category_id' => '0', 68 'rank' => '1', 69 'title' => 'タイトルですよ', 70 'comment' => 'コメントですよ', 71 'creator_id' => '1', 72 'create_date' => '2000-01-01 00:00:00', 73 'update_date' => '2000-01-01 00:00:00', 74 'del_flg' => '0' 67 array( 68 'maker_id' => '1004', 69 'name' => 'MEC' 75 70 ), 76 1=>array( 77 'best_id' => '1003', 78 'product_id'=>'3', 79 'category_id' => '1', 80 'rank' => '3', 81 'title' => 'タイトルですよ3', 82 'comment' => 'コメントですよ3', 83 'creator_id' => '3', 84 'create_date' => '2000-01-01 00:00:00', 85 'update_date' => '2000-01-01 00:00:00', 86 'del_flg' => '0' 87 71 array( 72 'maker_id' => '1003', 73 'name' => 'シャンプー' 74 ), 75 array( 76 'maker_id' => '1001', 77 'name' => 'ソニン' 88 78 ) 89 79 ); 90 80 91 92 $this->actual = SC_Helper_BestProducts::getList(); 81 $this->actual = $this->objHelperMaker->getList(); 93 82 $this->verify(); 94 83 … … 97 86 public function testGetList_一覧取得has_deleteをtrueにした場合削除済みデータも取得(){ 98 87 99 $this->setUpBestProducts();100 101 102 88 $this->expected = array( 103 0=>array( 104 'best_id' => '1001', 105 'product_id'=>'2', 106 'category_id' => '0', 107 'rank' => '1', 108 'title' => 'タイトルですよ', 109 'comment' => 'コメントですよ', 110 'creator_id' => '1', 111 'create_date' => '2000-01-01 00:00:00', 112 'update_date' => '2000-01-01 00:00:00', 113 'del_flg' => '0' 89 array( 90 'maker_id' => '1004', 91 'name' => 'MEC' 114 92 ), 115 1=>array( 116 'best_id' => '1002', 117 'product_id'=>'1', 118 'category_id' => '0', 119 'rank' => '2', 120 'title' => 'タイトルですよ', 121 'comment' => 'コメントですよ', 122 'creator_id' => '1', 123 'create_date' => '2000-01-01 00:00:00', 124 'update_date' => '2000-01-01 00:00:00', 125 'del_flg' => '1' 93 array( 94 'maker_id' => '1003', 95 'name' => 'シャンプー' 126 96 ), 127 2=>array( 128 'best_id' => '1003', 129 'product_id'=>'3', 130 'category_id' => '1', 131 'rank' => '3', 132 'title' => 'タイトルですよ3', 133 'comment' => 'コメントですよ3', 134 'creator_id' => '3', 135 'create_date' => '2000-01-01 00:00:00', 136 'update_date' => '2000-01-01 00:00:00', 137 'del_flg' => '0' 138 97 array( 98 'maker_id' => '1002', 99 'name' => 'パソナニック' 100 ), 101 array( 102 'maker_id' => '1001', 103 'name' => 'ソニン' 139 104 ) 140 105 ); 141 106 142 143 $this->actual = SC_Helper_BestProducts::getList(0,0,true); 144 $this->verify(); 145 146 } 147 148 149 150 public function testGetList_ページングが想定した結果が返る_表示件数1_ページ番号2(){ 151 152 $this->setUpBestProducts(); 153 154 $this->expected = array( 155 0=>array( 156 'best_id' => '1003', 157 'product_id'=>'3', 158 'category_id' => '1', 159 'rank' => '3', 160 'title' => 'タイトルですよ3', 161 'comment' => 'コメントですよ3', 162 'creator_id' => '3', 163 'create_date' => '2000-01-01 00:00:00', 164 'update_date' => '2000-01-01 00:00:00', 165 'del_flg' => '0' 166 ) 167 ); 168 169 170 $this->actual = SC_Helper_BestProducts::getList(1,2); 171 $this->verify(); 172 173 } 174 175 176 public function testGetList_ページングが想定した結果が返る_表示件数1_ページ番号0(){ 177 178 $this->setUpBestProducts(); 179 180 181 $this->expected = array( 182 0=>array( 183 'best_id' => '1001', 184 'product_id'=>'2', 185 'category_id' => '0', 186 'rank' => '1', 187 'title' => 'タイトルですよ', 188 'comment' => 'コメントですよ', 189 'creator_id' => '1', 190 'create_date' => '2000-01-01 00:00:00', 191 'update_date' => '2000-01-01 00:00:00', 192 'del_flg' => '0' 193 ) 194 ); 195 196 $this->actual = SC_Helper_BestProducts::getList(1,0); 107 $this->actual = $this->objHelperMaker->getList(true); 197 108 $this->verify(); 198 109 -
branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_Maker/SC_Helper_Maker_getMakerTest.php
r22660 r22727 2 2 3 3 $HOME = realpath(dirname(__FILE__)) . "/../../../.."; 4 require_once($HOME . "/tests/class/helper/SC_Helper_ BestProducts/SC_Helper_BestProducts_TestBase.php");4 require_once($HOME . "/tests/class/helper/SC_Helper_Maker/SC_Helper_Maker_TestBase.php"); 5 5 /* 6 6 * This file is part of EC-CUBE … … 26 26 27 27 /** 28 * SC_Helper_ BestProducts::getBestProducts()のテストクラス.28 * SC_Helper_Maker::getMaker()のテストクラス. 29 29 * 30 30 * @author hiroshi kakuta 31 31 */ 32 class SC_Helper_ BestProducts_getBestProductsTest extends SC_Helper_BestProducts_TestBase32 class SC_Helper_Maker_getMakerTest extends SC_Helper_Maker_TestBase 33 33 { 34 35 var $objHelperMaker; 36 34 37 protected function setUp() 35 38 { 36 39 parent::setUp(); 37 $this->setUpBestProducts(); 40 $this->setUpMaker(); 41 $this->objHelperMaker = new SC_Helper_Maker_Ex(); 38 42 } 39 43 … … 43 47 } 44 48 45 /** best_idが存在しない場合、空を返す。49 /** maker_idが存在しない場合、空を返す。 46 50 */ 47 public function testGet BestProducts_おすすめidが存在しない場合_空を返す()51 public function testGetMaker_おすすめidが存在しない場合_空を返す() 48 52 { 49 $ best_id = '9999';53 $this->expected = null; 50 54 51 $this->expected = null; 52 $this->actual = SC_Helper_BestProducts::getBestProducts($best_id); 55 $this->actual = $this->objHelperMaker->getMaker("9999"); 53 56 54 57 $this->verify(); 55 58 } 56 59 57 // best_idが存在する場合、対応した結果を取得できる。 58 public function testGetBestProducts_おすすめIDが存在する場合_対応した結果を取得できる(){ 59 60 $best_id = '1001'; 60 // maker_idが存在する場合、対応した結果を取得できる。 61 public function testGetMaker_メーカーIDが存在する場合_対応した結果を取得できる(){ 61 62 62 63 63 64 $this->expected = array( 64 'category_id' => '0', 65 'maker_id' => '1001', 66 'name' => 'ソニン', 65 67 'rank' => '1', 66 'title' => 'タイトルですよ', 67 'comment' => 'コメントですよ', 68 'creator_id' => '1', 69 'create_date' => '2000-01-01 00:00:00', 70 'update_date' => '2000-01-01 00:00:00', 68 71 'del_flg' => '0' 69 72 ); 70 73 71 $result = SC_Helper_BestProducts::getBestProducts($best_id); 74 $result = $this->objHelperMaker->getMaker("1001"); 75 72 76 $this->actual = Test_Utils::mapArray($result, 73 array('category_id', 77 array('maker_id', 78 'name', 74 79 'rank', 75 'title', 76 'comment', 80 'creator_id', 81 'create_date', 82 'update_date', 77 83 'del_flg' 78 84 )); … … 83 89 84 90 85 // best_idが存在するが、del_flg=1の場合、空が帰る。 86 public function testGetBestProducts_おすすめIDがあり_かつ削除済みの場合_空が返る(){ 87 88 $best_id = '1002'; 91 public function testGetMaker_おすすめIDがあり_かつ削除済みの場合_空が返る(){ 89 92 90 93 $this->expected = null; 91 $this->actual = SC_Helper_BestProducts::getBestProducts($best_id); 94 95 $result = $this->objHelperMaker->getMaker("1002"); 92 96 93 97 $this->verify(); … … 96 100 97 101 // best_idが存在するが、del_flg=1の場合、かつ。$has_deleted=trueを指定 98 public function testGet BestProducts_削除済みでかつhas_deletedがtrueの場合_対応した結果が返る(){102 public function testGetMaker_削除済みでかつhas_deletedがtrueの場合_対応した結果が返る(){ 99 103 100 104 $best_id = '1002'; … … 102 106 103 107 $this->expected = array( 104 'category_id' => '0', 108 'maker_id' => '1002', 109 'name' => 'パソナニック', 105 110 'rank' => '2', 106 'title' => 'タイトルですよ', 107 'comment' => 'コメントですよ', 111 'creator_id' => '2', 112 'create_date' => '2000-01-01 00:00:00', 113 'update_date' => '2000-01-01 00:00:00', 108 114 'del_flg' => '1' 109 115 ); 110 116 111 $result = SC_Helper_BestProducts::getBestProducts($best_id,true); 117 $result = $this->objHelperMaker->getMaker("1002",true); 118 112 119 $this->actual = Test_Utils::mapArray($result, 113 array('category_id', 120 array('maker_id', 121 'name', 114 122 'rank', 115 'title', 116 'comment', 123 'creator_id', 124 'create_date', 125 'update_date', 117 126 'del_flg' 118 127 )); -
branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_Maker/SC_Helper_Maker_saveMakerTest.php
r22695 r22727 2 2 3 3 $HOME = realpath(dirname(__FILE__)) . "/../../../.."; 4 require_once($HOME . "/tests/class/helper/SC_Helper_ BestProducts/SC_Helper_BestProducts_TestBase.php");4 require_once($HOME . "/tests/class/helper/SC_Helper_Maker/SC_Helper_Maker_TestBase.php"); 5 5 /* 6 6 * This file is part of EC-CUBE … … 26 26 27 27 /** 28 * SC_Helper_BestProducts::saveBestProducts()のテストクラス.29 28 * 30 29 * @author hiroshi kakuta 31 30 */ 32 class SC_Helper_ BestProducts_saveBestProductsTest extends SC_Helper_BestProducts_TestBase31 class SC_Helper_Maker_saveMakerTest extends SC_Helper_Maker_TestBase 33 32 { 33 var $objHelperMaker; 34 34 35 protected function setUp() 35 36 { 37 36 38 parent::setUp(); 37 $this->setUpBestProducts(); 39 $this->setUpMaker(); 40 $this->objHelperMaker = new SC_Helper_Maker_Ex(); 38 41 } 39 42 … … 44 47 45 48 46 // best_idを指定して更新される。47 public function testSaveBestProducts_ベストIDがある場合_更新される(){48 49 50 public function testSaveMaker_メーカーIDを指定すると更新される(){ 51 //public function testSaveMaker_update(){ 49 52 $sqlVal = array( 50 'best_id' => '1001', 51 'product_id'=>'3', 52 'category_id' => '1', 53 'rank' => '2', 54 'title' => 'タイトルですよ1001', 55 'comment' => 'コメントですよ1001', 56 'creator_id' => '2', 57 'create_date' => '2000-01-01 00:00:00', 58 'update_date' => '2000-01-01 00:00:00', 59 'del_flg' => '0' 53 'maker_id' => '1001', 54 'name' => 'ソニンー', 60 55 ); 61 56 62 $ result = SC_Helper_BestProducts::saveBestProducts($sqlVal);57 $this->objHelperMaker->saveMaker($sqlVal); 63 58 64 59 $this->expected = array( 65 'product_id'=>'3', 66 'category_id' => '1', 67 'rank' => '2', 68 'title' => 'タイトルですよ1001', 69 'comment' => 'コメントですよ1001', 70 'creator_id' => '1', //変わらない 71 'create_date' => '2000-01-01 00:00:00', 72 'del_flg' => '0' 60 'name' => 'ソニンー', 73 61 ); 74 62 75 $this->actual = SC_Helper_BestProducts::getBestProducts('1001'); 76 77 $arrRet = SC_Helper_BestProducts::getBestProducts('1001'); 78 63 $arrRet = $this->objHelperMaker->getMaker('1001'); 79 64 80 65 $this->actual = Test_Utils::mapArray($arrRet, 81 array('product_id', 82 'category_id', 83 'rank', 84 'title', 85 'comment', 86 'creator_id', 87 'create_date', 88 'del_flg' 89 ) 66 array('name') 90 67 ); 91 68 … … 94 71 95 72 96 // best_idがnullでデータインサートされる。 97 public function testSaveBestProducts_ベストIDがない場合_インサートされる(){ 73 74 public function testSaveMaker_メーカーIDがない場合_インサートされる(){ 75 //public function testSaveMaker_insert(){ 98 76 99 77 if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 100 78 $sqlVal = array( 101 'product_id'=>'4', 102 'category_id' => '2', 103 'rank' => '4', 104 'title' => 'タイトルですよ1004', 105 'comment' => 'コメントですよ1004', 106 'creator_id' => '3', 79 'name' => 'フジスリー', 80 'creator_id' => '1', 107 81 'del_flg' => '0' 108 82 ); 109 83 110 $best_id = SC_Helper_BestProducts::saveBestProducts($sqlVal); 84 $maker_id = $this->objHelperMaker->saveMaker($sqlVal); 85 111 86 112 87 $this->expected = array( 113 'product_id'=>'4', 114 'category_id' => '2', 115 'rank' => '4', 116 'title' => 'タイトルですよ1004', 117 'comment' => 'コメントですよ1004', 118 'creator_id' => '3', 88 'name' => 'フジスリー', 89 'rank' => '5', 90 'creator_id' => '1', 119 91 'del_flg' => '0' 120 92 ); 121 93 122 $arrRet = SC_Helper_BestProducts::getBestProducts($best_id); 123 94 $arrRet = $this->objHelperMaker->getMaker($maker_id); 124 95 125 96 $this->actual = Test_Utils::mapArray($arrRet, 126 array( 'product_id',127 ' category_id',97 array( 98 'name', 128 99 'rank', 129 'title',130 'comment',131 100 'creator_id', 132 101 'del_flg' … … 137 106 } 138 107 139 140 }141 142 143 // best_idがnull、かつrankがnullの場合、想定されたランクが登録される144 public function testSaveBestProducts_インサート処理でrankがsetされてない場合_採番された値がセットされる(){145 146 if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避147 $sqlVal = array(148 'product_id'=>'5',149 'category_id' => '2',150 'title' => 'タイトルですよ5',151 'comment' => 'コメントですよ5',152 'creator_id' => '3',153 'del_flg' => '0'154 );155 156 $best_id = SC_Helper_BestProducts::saveBestProducts($sqlVal);157 158 $this->expected = "4"; //ランク159 160 $arrRet = SC_Helper_BestProducts::getBestProducts($best_id);161 162 163 $this->actual = $arrRet['rank'];164 165 $this->verify();166 }167 108 } 168 109
Note: See TracChangeset
for help on using the changeset viewer.