Skip to content

Commit

Permalink
Generator::createOrder() で charge 及び discount の集計をサポート
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Sep 7, 2016
1 parent 88489bf commit 4ea2cdd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tests/Eccube/Tests/Entity/OrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,19 @@ public function testGetProductTypes()
$this->actual = $this->Order->getProductTypes();
$this->verify();
}

public function testGetTotalPrice()
{
$faker = $this->getFaker();
$Order = $this->app['eccube.fixture.generator']->createOrder(
$this->Customer,
array(),
null,
$faker->randomNumber(5),
$faker->randomNumber(5)
);
$this->expected = $Order->getSubTotal() + $Order->getCharge() + $Order->getDeliveryFeeTotal() - $Order->getDiscount();
$this->actual = $Order->getTotalPrice();
$this->verify();
}
}
8 changes: 7 additions & 1 deletion tests/Eccube/Tests/Fixture/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,12 @@ public function createProduct($product_name = null, $product_class_num = 3)
*
* @param \Eccube\Entity\Customer $Customer Customer インスタンス
* @param array $ProductClasses 明細行となる ProductClass の配列
* @param \Eccube\Entity\Delivery $Delivery Delivery インスタンス
* @param integer $add_charge Order に加算される手数料
* @param integer $add_discount Order に加算される値引き額
* @return \Eccube\Entity\Order
*/
public function createOrder(Customer $Customer, array $ProductClasses = array(), Delivery $Delivery = null)
public function createOrder(Customer $Customer, array $ProductClasses = array(), Delivery $Delivery = null, $add_charge = 0, $add_discount = 0)
{
$faker = $this->getFaker();
$quantity = $faker->randomNumber(2);
Expand Down Expand Up @@ -404,6 +407,9 @@ public function createOrder(Customer $Customer, array $ProductClasses = array(),
$Order->setDeliveryFeeTotal($Shipping->getShippingDeliveryFee());
$Order->setSubTotal($subTotal);

$Order->setCharge($Order->getCharge() + $add_charge);
$Order->setDiscount($Order->getDiscount() + $add_discount);

$total = $Order->getTotalPrice();
$Order->setTotal($total);
$Order->setPaymentTotal($total);
Expand Down

0 comments on commit 4ea2cdd

Please sign in to comment.