83 lines
2.5 KiB
PHP
83 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace KupShop\OrderingBundle\Tests\Order;
|
|
|
|
use KupShop\DevelopmentBundle\Util\Tests\CartTestTrait;
|
|
|
|
class OrderSavePreferencesTest extends \DatabaseTestCase
|
|
{
|
|
use CartTestTrait;
|
|
|
|
/* Test na uložení adresy k novému uživateli, pokud se nejedná o typ osobní odběr nebo zásilkovna
|
|
Zde se má adresa uložit, jelikož ji typ dopravy vyžaduje */
|
|
public function testSaveUserAddress()
|
|
{
|
|
$this->loginUser(1);
|
|
$this->prepareCart();
|
|
|
|
$this->insertProduct(3);
|
|
/* Typ doručení kurýrem */
|
|
$this->setDeliveryType(3);
|
|
|
|
$old_user = \User::createFromId(1);
|
|
$this->assertEquals('Petr', $old_user->name);
|
|
|
|
$this->cart->setData('save_address', '1');
|
|
$this->cart->user->invoice['name'] = 'Joe';
|
|
|
|
$this->submitOrder();
|
|
|
|
$this->assertEquals('Joe', $this->order->invoice_name);
|
|
|
|
/* Tady se má adresa uložit, jelikož to je typ dopravy, který potřebuje adresu */
|
|
$new_user = \User::createFromId(1);
|
|
$this->assertEquals('Joe', $new_user->name);
|
|
$this->assertEquals('Wpj 123', $new_user->delivery_street);
|
|
}
|
|
|
|
/* Test na uložení adresy k novému uživateli, pokud se nejedná o typ osobní odběr nebo zásilkovna
|
|
Zde se nemá adresa uložit, jelikož ji typ dopravy nevyžaduje */
|
|
public function testNotSaveUserAddress()
|
|
{
|
|
$this->loginUser(1);
|
|
$this->prepareCart();
|
|
|
|
$this->insertProduct(3);
|
|
/* Osobní odběr */
|
|
$this->setDeliveryType(1);
|
|
|
|
$old_user = \User::createFromId(1);
|
|
$this->assertEquals('Petr', $old_user->name);
|
|
|
|
$this->cart->setData('save_address', '1');
|
|
$this->cart->user->invoice['name'] = 'Joe';
|
|
|
|
$this->submitOrder();
|
|
|
|
$this->assertEquals('Joe', $this->order->invoice_name);
|
|
|
|
/* Tady se adresa nemá uložit, jelikož to je typ dopravy, který nepotřebuje adresu */
|
|
$new_user = \User::createFromId(1);
|
|
$this->assertEquals('Joe', $new_user->name);
|
|
$this->assertEquals('', $new_user->delivery_street);
|
|
}
|
|
|
|
public function testSaveUserDeliveryType()
|
|
{
|
|
$this->loginUser(3);
|
|
$this->prepareCart();
|
|
|
|
$this->insertProduct(3);
|
|
|
|
$old_user = \User::createFromId(3);
|
|
$this->assertNull($old_user->prefer_transport);
|
|
|
|
$order = $this->submitOrder();
|
|
|
|
$this->assertEquals(1, $order->id_delivery);
|
|
|
|
$new_user = \User::createFromId(3);
|
|
$this->assertEquals(1, $new_user->prefer_transport);
|
|
}
|
|
}
|