1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Frontend\Basket\Decorator; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class BundleTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
private $context; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
protected function setUp() |
19
|
|
|
{ |
20
|
|
|
$this->context = \TestHelperFrontend::getContext(); |
21
|
|
|
$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
22
|
|
|
$this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Bundle( $object, $this->context ); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
protected function tearDown() |
27
|
|
|
{ |
28
|
|
|
$this->object->clear(); |
29
|
|
|
$this->context->getSession()->set( 'aimeos', array() ); |
30
|
|
|
|
31
|
|
|
unset( $this->object ); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
public function testAddProductBundle() |
36
|
|
|
{ |
37
|
|
|
$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:BUNDLE' ); |
38
|
|
|
|
39
|
|
|
$this->object->addProduct( $item->getId(), 1 ); |
40
|
|
|
|
41
|
|
|
$this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
42
|
|
|
$this->assertEquals( 'U:BUNDLE', $this->object->get()->getProduct( 0 )->getProductCode() ); |
43
|
|
|
$this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getProducts() ) ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
public function testAddProductNoBundle() |
48
|
|
|
{ |
49
|
|
|
$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
50
|
|
|
|
51
|
|
|
$this->object->addProduct( $item->getId(), 1 ); |
52
|
|
|
|
53
|
|
|
$this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
54
|
|
|
$this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() ); |
55
|
|
|
$this->assertEquals( 0, count( $this->object->get()->getProduct( 0 )->getProducts() ) ); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|