Completed
Push — master ( 937f3b...5e44e2 )
by Aimeos
16:51 queued 07:27
created

BundleTest::testAddProductNoBundle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
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