示例#1
0
 /**
  * @covers sBasket::sDeleteArticle
  */
 public function testsDeleteArticle()
 {
     // No id, expect null
     $this->assertNull($this->module->sDeleteArticle(null));
     // Random id, expect null
     $this->assertNull($this->module->sDeleteArticle(9999999));
     $this->module->sSYSTEM->sSESSION_ID = uniqid();
     $this->session->offsetSet('sessionId', $this->module->sSYSTEM->sSESSION_ID);
     // Get random article and add it to the basket
     $randomArticle = $this->db->fetchRow('SELECT detail.* FROM s_articles_details detail
         LEFT JOIN s_articles article
           ON article.id = detail.articleID
         LEFT JOIN s_articles_avoid_customergroups avoid
           ON avoid.articleID = article.id
         WHERE detail.active = 1
         AND avoid.articleID IS NULL
         AND article.id NOT IN (
           SELECT articleID
           FROM s_articles_avoid_customergroups
           WHERE customergroupID = 1
         )
         AND (article.laststock = 0 OR detail.instock > 0)
         ORDER BY RAND() LIMIT 1');
     $idOne = $this->module->sAddArticle($randomArticle['ordernumber'], 1);
     $this->assertEquals(1, $this->module->sCountBasket());
     $this->module->sDeleteArticle($idOne);
     $this->assertEquals(0, $this->module->sCountBasket());
 }
示例#2
0
 /**
  * Delete an article from cart -
  * @param sDelete = id from s_basket identifying the product to delete
  * Forward to cart / confirmation page after success
  */
 public function deleteArticleAction()
 {
     if ($this->Request()->getParam('sDelete')) {
         $this->basket->sDeleteArticle($this->Request()->getParam('sDelete'));
     }
     $this->forward($this->Request()->getParam('sTargetAction', 'index'));
 }
示例#3
0
 /**
  * Ajax delete article action
  *
  * This action is a lightweight way to delete an article by the passed
  * basket item id.
  *
  * This id is expected to get passed by the 'sDelete' parameter.
  *
  * After the article was removed from the basket, the whole cart content will be returned.
  */
 public function ajaxDeleteArticleCartAction()
 {
     $itemId = $this->Request()->getParam('sDelete');
     if ($itemId) {
         $this->basket->sDeleteArticle($itemId);
     }
     $this->forward('ajaxCart');
 }