Example #1
0
 public function executeCart(sfWebRequest $request)
 {
     if ($this->getUser()->hasFlash('last_added_product')) {
         $this->product = tpyProductTable::getInstance()->findOneBySlug($this->getUser()->getFlash('last_added_product'));
     }
     $this->cart = tpyCart::getInstance($this->getUser());
 }
<?php

/**
 * PlugintimpanyProduct tests.
 */
include dirname(__FILE__) . '/../../../../../../test/bootstrap/unit.php';
$databaseManager = new sfDatabaseManager($configuration);
Doctrine_Core::loadData(sfConfig::get('sf_data_dir') . '/fixtures');
$t = new lime_test(2);
$product_1 = tpyProductTable::getInstance()->findOneById(1);
$t->is($product_1->getNetPrice(), 0.84, 'got expected net price');
$t->is(round($product_1->getGrossPrice('de'), 2), 0.9, 'gross price is correct');
Example #3
0
/**
 * tpyCart tests.
 */
include dirname(__FILE__) . '/../../../../../test/bootstrap/unit.php';
//$configuration = ProjectConfiguration::getApplicationConfiguration( 'frontend', 'test', true);
new sfDatabaseManager($configuration);
$t = new lime_test(24);
Doctrine_Core::loadData(dirname(__FILE__) . '/../../fixtures');
$_SERVER['session_id'] = 'test_guest';
$guestDispatcher = new sfEventDispatcher();
$guestSessionPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'symfony_tests_' . rand(1, 999);
$guestStorage = new sfSessionTestStorage(array('session_path' => $guestSessionPath));
$guestUser = new aSecurityUser($guestDispatcher, $guestStorage);
$product_1 = tpyProductTable::getInstance()->findOneById(1);
$product_2 = tpyProductTable::getInstance()->findOneById(2);
$guestCart = tpyCart::getInstance($guestUser);
$t->is($guestCart->isEmpty(), true, 'cart is empty');
$t->comment('Put one item into cart.');
$guestCart->addProduct($product_1);
$t->is($guestCart->isEmpty(), false, 'cart is not empty');
$t->is($guestCart->getItemCount(), 1, '1 item in cart');
$t->is($guestCart->getProductCount(), 1, '1 product in cart');
$t->is($guestCart->getNetSum(), 0.84, 'cart net sum is correct');
$t->is($guestCart->getGrossSum('de'), 0.9, 'cart gross sum is correct');
$t->comment('Put second item into cart.');
$guestCart->addProduct($product_2);
$t->is($guestCart->isEmpty(), false, 'cart is not empty');
$t->is($guestCart->getItemCount(), 2, '2 items in cart');
$t->is($guestCart->getProductCount(), 2, '2 products in cart');
$t->is($guestCart->getNetSum(), 0.84, 'cart net sum is correct');