Completed
Push — master ( b46c0d...fe698d )
by Aimeos
06:27
created

BundleTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A tearDown() 0 7 1
A testAddProductBundle() 0 10 1
1
<?php
2
3
namespace Aimeos\Controller\Frontend\Basket\Decorator;
4
5
6
class BundleTest extends \PHPUnit_Framework_TestCase
7
{
8
	private $object;
9
	private $context;
10
11
12
	protected function setUp()
13
	{
14
		$this->context = \TestHelperFrontend::getContext();
15
		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
16
		$this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Bundle( $object, $this->context );
17
	}
18
19
20
	protected function tearDown()
21
	{
22
		$this->object->clear();
23
		$this->context->getSession()->set( 'aimeos', array() );
24
25
		unset( $this->object );
26
	}
27
28
29
	public function testAddProductBundle()
30
	{
31
		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:BUNDLE' );
32
33
		$this->object->addProduct( $item->getId(), 1 );
34
35
		$this->assertEquals( 1, count( $this->object->get()->getProducts() ) );
36
		$this->assertEquals( 'U:BUNDLE', $this->object->get()->getProduct( 0 )->getProductCode() );
37
		$this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getProducts() ) );
38
	}
39
}
40