[Svn-src-all:3287] [version-2_12-dev 22188] #1993 ([共通クラス]SC_Products)
nanasess
admin @ mail.ec-cube.net
2012年 12月 30日 (日) 18:24:50 JST
Subversion committed to /home/svn/open 22188
http://svn.ec-cube.net/open_trac/changeset/22188
┌────────────────────────────┐
│更新者 : nanasess │
│更新日時: 2012-12-30 18:24:50 +0900 (日, 30 12月 2012)│
└────────────────────────────┘
Log:
--------------------------------------------------------
#1993 ([共通クラス]SC_Products)
基底クラスと, 以下を追加
* SC_Product::findProductIdsOrder
* SC_Product_setProductsOrder
Changed: [U:修正,A:追加,D:削除]
--------------------------------------------------------
_U branches/version-2_12-dev/
A branches/version-2_12-dev/tests/class/SC_Product/
A branches/version-2_12-dev/tests/class/SC_Product/SC_Product_TestBase.php
A branches/version-2_12-dev/tests/class/SC_Product/SC_Product_findProductIdsOrderTest.php
A branches/version-2_12-dev/tests/class/SC_Product/SC_Product_setProductsOrderTest.php
追加: branches/version-2_12-dev/tests/class/SC_Product/SC_Product_TestBase.php
===================================================================
--- branches/version-2_12-dev/tests/class/SC_Product/SC_Product_TestBase.php (rev 0)
+++ branches/version-2_12-dev/tests/class/SC_Product/SC_Product_TestBase.php 2012-12-30 09:24:50 UTC (rev 22188)
@@ -0,0 +1,109 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Product_TestBase extends Common_TestCase {
+ protected function setUp() {
+ parent::setUp();
+ }
+
+ protected function tearDown() {
+ parent::tearDown();
+ }
+
+ /**
+ * DBに商品クラス情報を設定します.
+ */
+ protected function setUpProductClass() {
+ $product_class = array(
+ array(
+ 'update_date' => 'CURRENT_TIMESTAMP',
+ 'product_class_id' => '1001',
+ 'product_id' => '1001',
+ 'product_type_id' => '1001',
+ 'product_code' => 'code1001',
+ 'classcategory_id1' => '1001',
+ 'classcategory_id2' => '1002',
+ 'price01' => '1500',
+ 'price02' => '1500',
+ 'creator_id' => '1',
+ 'del_flg' => '0'
+ ),
+ array(
+ 'update_date' => 'CURRENT_TIMESTAMP',
+ 'product_class_id' => '1002',
+ 'product_id' => '1002',
+ 'product_type_id' => '1002',
+ 'price02' => '2500',
+ 'creator_id' => '1',
+ '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' => 'CURRENT_TIMESTAMP',
+ 'classcategory_id' => '1001',
+ 'class_id' => '1',
+ 'creator_id' => '1',
+ 'name' => 'cat1001'
+ ),
+ array(
+ 'update_date' => 'CURRENT_TIMESTAMP',
+ 'classcategory_id' => '1002',
+ 'class_id' => '1',
+ 'creator_id' => '1',
+ 'name' => 'cat1002'
+ )
+ );
+
+ $this->objQuery->delete('dtb_classcategory');
+ foreach ($class_category as $key => $item) {
+ $this->objQuery->insert('dtb_classcategory', $item);
+ }
+ }
+
+ /**
+ * DBに製品情報を登録します.
+ */
+ protected function setUpProducts() {
+ $products = array(
+ array(
+ 'update_date' => 'CURRENT_TIMESTAMP',
+ 'product_id' => '1001',
+ 'name' => '製品名1001',
+ 'del_flg' => '0',
+ 'creator_id' => '1',
+ 'status' => '1'
+ ),
+ array(
+ 'update_date' => 'CURRENT_TIMESTAMP',
+ '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);
+ }
+ }
+}
\ No newline at end of file
追加: branches/version-2_12-dev/tests/class/SC_Product/SC_Product_findProductIdsOrderTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/SC_Product/SC_Product_findProductIdsOrderTest.php (rev 0)
+++ branches/version-2_12-dev/tests/class/SC_Product/SC_Product_findProductIdsOrderTest.php 2012-12-30 09:24:50 UTC (rev 22188)
@@ -0,0 +1,48 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../..";
+require_once($HOME . "/tests/class/SC_Product/SC_Product_TestBase.php");
+/**
+ *
+ */
+class SC_Product_setProductsOrderTest extends SC_Product_TestBase {
+
+ protected function setUp() {
+ parent::setUp();
+ $this->objProducts = new SC_Product_Ex();
+ }
+
+ protected function tearDown() {
+ parent::tearDown();
+ }
+
+ /////////////////////////////////////////
+
+ public function testFindProductIdsOrder_商品ID降順() {
+ $this->setUpProductClass();
+ $this->setUpProducts();
+ $this->setUpClassCategory();
+
+ // 商品ID降順で商品IDを取得する
+ $this->objQuery->setOrder('product_id DESC');
+ $this->expected = array('1002', '1001');
+
+ $this->actual = $this->objProducts->findProductIdsOrder($this->objQuery);
+
+ $this->verify('商品ID降順');
+ }
+
+ public function testFindProductIdsOrder_商品名昇順() {
+ $this->setUpProductClass();
+ $this->setUpProducts();
+ $this->setUpClassCategory();
+
+ // 商品名昇順で商品IDを取得する
+ $this->objQuery->setOrder('product_id ASC');
+ $this->expected = array('1001', '1002');
+
+ $this->actual = $this->objProducts->findProductIdsOrder($this->objQuery);
+
+ $this->verify('商品ID昇順');
+ }
+}
追加: branches/version-2_12-dev/tests/class/SC_Product/SC_Product_setProductsOrderTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/SC_Product/SC_Product_setProductsOrderTest.php (rev 0)
+++ branches/version-2_12-dev/tests/class/SC_Product/SC_Product_setProductsOrderTest.php 2012-12-30 09:24:50 UTC (rev 22188)
@@ -0,0 +1,37 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../..";
+require_once($HOME . "/tests/class/SC_Product/SC_Product_TestBase.php");
+/**
+ *
+ */
+class SC_Product_setProductsOrderTest extends SC_Product_TestBase {
+
+ protected function setUp() {
+ parent::setUp();
+ $this->objProducts = new SC_Product_Ex();
+ }
+
+ protected function tearDown() {
+ parent::tearDown();
+ }
+
+ /////////////////////////////////////////
+ public function testSetProductsOrder_デフォルト引数() {
+ $this->objProducts->setProductsOrder('name');
+
+ $this->actual = $this->objProducts->arrOrderData;
+ $this->expected = array('col' => 'name', 'table' => 'dtb_products', 'order' => 'ASC');
+
+ $this->verify('デフォルト引数');
+ }
+
+ public function testSetProductsOrder_引数指定() {
+ $this->objProducts->setProductsOrder('name', 'dtb_products_class', 'DESC');
+
+ $this->actual = $this->objProducts->arrOrderData;
+ $this->expected = array('col' => 'name', 'table' => 'dtb_products_class', 'order' => 'DESC');
+
+ $this->verify('デフォルト引数');
+ }
+}
Svn-src-all メーリングリストの案内