Exemplo n.º 1
0
try {
    $stock1tovar1 = new rtShopStockToVariation();
    $stock1tovar1->setStockId($stock1->getId());
    $stock1tovar1->setVariationId($var1->getId());
    $stock1tovar1->save();
    $stock1tovar3 = new rtShopStockToVariation();
    $stock1tovar3->setStockId($stock1->getId());
    $stock1tovar3->setVariationId($var3->getId());
    $stock1tovar3->save();
    $stock2tovar2 = new rtShopStockToVariation();
    $stock2tovar2->setStockId($stock2->getId());
    $stock2tovar2->setVariationId($var2->getId());
    $stock2tovar2->save();
    $stock2tovar4 = new rtShopStockToVariation();
    $stock2tovar4->setStockId($stock2->getId());
    $stock2tovar4->setVariationId($var4->getId());
    $stock2tovar4->save();
    $t->pass('->save() on a rtShopStockToVariation object works');
} catch (Exception $e) {
    $t->fail('->save() on a rtShopStockToVariation failed!');
}
$t->diag('-----------------------------------------------------------------------------');
$t->diag('4. Check simple cart functionality');
$t->diag('-----------------------------------------------------------------------------');
$t->diag('-----------------------------------------------------------------------------');
$t->diag('4.1 Two products, just retail prices (no taxes, promotions,etc.)');
$t->diag('-----------------------------------------------------------------------------');
// Instanciate cart manager
try {
    $cm = new rtShopCartManager();
    $t->pass('->create() on a rtShopCartManager object works');
    $stock2->setSku(mt_rand(1, 100000));
    $stock2->setPriceRetail(40);
    $stock2->setPricePromotion(30);
    $stock2->save();
} catch (Exception $e) {
    throw new sfException('Stocks could not be added! Please check.');
}
// Stock to variation
try {
    $stock1tovar1 = new rtShopStockToVariation();
    $stock1tovar1->setStockId($stock1->getId());
    $stock1tovar1->setVariationId($var1->getId());
    $stock1tovar1->save();
    $stock1tovar2 = new rtShopStockToVariation();
    $stock1tovar2->setStockId($stock1->getId());
    $stock1tovar2->setVariationId($var2->getId());
    $stock1tovar2->save();
    $stock2tovar1 = new rtShopStockToVariation();
    $stock2tovar1->setStockId($stock2->getId());
    $stock2tovar1->setVariationId($var1->getId());
    $stock2tovar1->save();
    $stock2tovar2 = new rtShopStockToVariation();
    $stock2tovar2->setStockId($stock2->getId());
    $stock2tovar2->setVariationId($var2->getId());
    $stock2tovar2->save();
} catch (Exception $e) {
    throw new sfException('Stocks could not be added to variations! Please check.');
}
// Create cart manager instance
try {
    $cm = new rtShopCartManager();
    $stock7->setQuantity(5);
    $stock7->setSku(mt_rand(1, 100000));
    $stock7->setPriceRetail(40);
    $stock7->setPricePromotion(38);
    $stock7->save();
} catch (Exception $e) {
    throw new sfException('Stocks could not be added! Please check.');
}
try {
    $stock1tovar1 = new rtShopStockToVariation();
    $stock1tovar1->setStockId($stock1->getId());
    $stock1tovar1->setVariationId($var1->getId());
    $stock1tovar1->save();
    $stock1tovar2 = new rtShopStockToVariation();
    $stock1tovar2->setStockId($stock1->getId());
    $stock1tovar2->setVariationId($var2->getId());
    $stock1tovar2->save();
    $stock2tovar1 = new rtShopStockToVariation();
    $stock2tovar1->setStockId($stock2->getId());
    $stock2tovar1->setVariationId($var1->getId());
    $stock2tovar1->save();
    $stock2tovar2 = new rtShopStockToVariation();
    $stock2tovar2->setStockId($stock2->getId());
    $stock2tovar2->setVariationId($var2->getId());
    $stock2tovar2->save();
    $stock3tovar1 = new rtShopStockToVariation();
    $stock3tovar1->setStockId($stock3->getId());
    $stock3tovar1->setVariationId($var1->getId());
    $stock3tovar1->save();
    $stock3tovar2 = new rtShopStockToVariation();
    $stock3tovar2->setStockId($stock3->getId());