@@ 602-629 (lines=28) @@ | ||
599 | } |
|
600 | ||
601 | ||
602 | public function testEditProductNotEnoughStock() |
|
603 | { |
|
604 | $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
605 | $search = $productManager->createSearch(); |
|
606 | $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
607 | $items = $productManager->searchItems( $search ); |
|
608 | ||
609 | if( ( $item = reset( $items ) ) === false ) { |
|
610 | throw new \Exception( 'Product not found' ); |
|
611 | } |
|
612 | ||
613 | $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
614 | ||
615 | $item = $this->object->get()->getProduct( 0 ); |
|
616 | $this->assertEquals( 2, $item->getQuantity() ); |
|
617 | ||
618 | try |
|
619 | { |
|
620 | $this->object->editProduct( 0, 5 ); |
|
621 | throw new \Exception( 'Expected exception not thrown' ); |
|
622 | } |
|
623 | catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
624 | { |
|
625 | $item = $this->object->get()->getProduct( 0 ); |
|
626 | $this->assertEquals( 3, $item->getQuantity() ); |
|
627 | $this->assertEquals( 'IJKL', $item->getProductCode() ); |
|
628 | } |
|
629 | } |
|
630 | ||
631 | ||
632 | public function testEditProductNoStock() |
|
@@ 668-689 (lines=22) @@ | ||
665 | } |
|
666 | ||
667 | ||
668 | public function testEditProductStockNotChecked() |
|
669 | { |
|
670 | $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
671 | $search = $productManager->createSearch(); |
|
672 | $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
673 | $items = $productManager->searchItems( $search ); |
|
674 | ||
675 | if( ( $item = reset( $items ) ) === false ) { |
|
676 | throw new \Exception( 'Product not found' ); |
|
677 | } |
|
678 | ||
679 | $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
680 | ||
681 | $item = $this->object->get()->getProduct( 0 ); |
|
682 | $this->assertEquals( 2, $item->getQuantity() ); |
|
683 | ||
684 | $this->object->editProduct( 0, 5, array( 'stock' => false ) ); |
|
685 | ||
686 | $item = $this->object->get()->getProduct( 0 ); |
|
687 | $this->assertEquals( 5, $item->getQuantity() ); |
|
688 | $this->assertEquals( 'IJKL', $item->getProductCode() ); |
|
689 | } |
|
690 | ||
691 | ||
692 | public function testEditProductFlagError() |