/**
  * @return mixed
  */
 public function createDelivery()
 {
     $faker = $this->getFaker();
     // create new delivery
     $Delivery = $this->app['eccube.repository.delivery']->findOrCreate(0);
     $Delivery->setConfirmUrl($faker->url);
     $Delivery->setDelFlg(Constant::DISABLED);
     $this->app['orm.em']->persist($Delivery);
     $this->app['orm.em']->flush();
     $Prefs = $this->app['eccube.repository.master.pref']->findAll();
     foreach ($Prefs as $Pref) {
         $DeliveryFee = $this->app['eccube.repository.delivery_fee']->findOrCreate(array('Delivery' => $Delivery, 'Pref' => $Pref));
         $DeliveryFee->setFee($faker->randomNumber(3));
         $this->app['orm.em']->persist($DeliveryFee);
         $this->app['orm.em']->flush();
         $Delivery->addDeliveryFee($DeliveryFee);
     }
     $Payment = $this->app['eccube.repository.payment']->findOrCreate(0);
     $this->app['orm.em']->persist($Payment);
     $this->app['orm.em']->flush();
     $PaymentOption = new PaymentOption();
     $PaymentOption->setDelivery($Delivery);
     $PaymentOption->setPayment($Payment);
     $PaymentOption->setDeliveryId($Delivery->getId());
     $PaymentOption->setPaymentId($Payment->getId());
     $this->app['orm.em']->persist($PaymentOption);
     $this->app['orm.em']->flush();
     $Delivery->addPaymentOption($PaymentOption);
     $this->app['orm.em']->persist($Delivery);
     $this->app['orm.em']->flush();
     return $Delivery;
 }
Exemple #2
0
 /**
  * Payment オプジェクトを生成して返す.
  *
  * @param Delivery $Delivery デフォルトで設定する配送オブジェクト
  * @param string $method 支払い方法名称
  * @param integer $charge 手数料
  * @param integer $rule_min 下限金額
  * @param integer $rule_max 上限金額
  * @return \Eccube\Entity\Payment
  */
 public function createPayment(Delivery $Delivery, $method, $charge = 0, $rule_min = 0, $rule_max = 999999999)
 {
     $Member = $this->app['eccube.repository.member']->find(2);
     $Payment = new Payment();
     $Payment->setMethod($method)->setCharge($charge)->setRuleMin($rule_min)->setRuleMax($rule_max)->setCreator($Member)->setDelFlg(Constant::DISABLED);
     $this->app['orm.em']->persist($Payment);
     $this->app['orm.em']->flush($Payment);
     $PaymentOption = new PaymentOption();
     $PaymentOption->setDeliveryId($Delivery->getId())->setPaymentId($Payment->getId())->setDelivery($Delivery)->setPayment($Payment);
     $Payment->addPaymentOption($PaymentOption);
     $this->app['orm.em']->persist($PaymentOption);
     $this->app['orm.em']->flush($PaymentOption);
     return $Payment;
 }