/** * @group shopobjects */ function testCreateShippingMethodOnlyName() { // GIVEN $shippingMethodParameter = $this->givenShippingMethodOnlyName(); // WHEN $shippingMethod = new PaymentMethod($shippingMethodParameter); // THEN $this->assertFalse($shippingMethod->error()); $this->assertEquals($shippingMethod->getName(), "DHL"); $this->assertNull($shippingMethod->getID()); }
/** * @group shopobjects */ function testCreatePaymentMethodOnlyName() { // GIVEN $paymentMethodParameter = $this->givenPaymentMethodOnlyName(); // WHEN $paymentMethod = new PaymentMethod($paymentMethodParameter); // THEN $this->assertFalse($paymentMethod->error()); $this->assertEquals($paymentMethod->getName(), "Paypal"); $this->assertNull($paymentMethod->getID()); }
/** * Creating a payment for creditNote * * @param CreditNote $creditNote * @param PaymentMethod $method * @param string $value * @param string $comments * * @return Ambigous <BaseEntityAbstract, GenericDAO> */ public static function createFromCreditNote(CreditNote &$creditNote, PaymentMethod $method, $value, $comments = '', $paymentDate = '') { $payment = new Payment(); $message = 'A ' . StringUtilsAbstract::getCurrency($value) . ' Credit Payment is made via ' . $method->getName() . ' for CreditNote(CreditNoteNo.=' . $creditNote->getCreditNoteNo() . ')' . (trim($comments) !== '' ? ': ' . $comments : '.'); $payment = $payment->setCreditNote($creditNote)->setMethod($method)->setValue($value)->setPaymentDate(new UDate(trim($paymentDate) === '' ? 'now' : trim($paymentDate)))->save()->addComment($message, Comments::TYPE_ACCOUNTING)->addLog($message, Log::TYPE_SYSTEM, get_class($payment) . '_CREATION', __CLASS__ . '::' . __FUNCTION__); $creditNote->addComment($message, Comments::TYPE_ACCOUNTING)->addLog($message, Log::TYPE_SYSTEM, 'Auto Log', __CLASS__ . '::' . __FUNCTION__); return $payment; }