Completed
Push — master ( 380778...4ffab1 )
by Aimeos
02:47
created

BaseTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A testCall() 0 4 1
A testCallInvalid() 0 5 1
A testGetContext() 0 4 1
A testGetController() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 */
7
8
9
namespace Aimeos\Controller\Frontend\Common\Decorator;
10
11
12
class BaseTest extends \PHPUnit_Framework_TestCase
13
{
14
	private $object;
15
16
17
	protected function setUp()
18
	{
19
		$context = \TestHelperFrontend::getContext();
20
		$cntl = new \Aimeos\Controller\Frontend\Catalog\Standard( $context );
21
22
		$this->object = new \Aimeos\Controller\Frontend\Common\Decorator\Example( $cntl, $context );
23
	}
24
25
26
	public function testCall()
27
	{
28
		$this->assertInstanceOf( '\Aimeos\MShop\Common\Manager\Iface', $this->object->createManager( 'product' ) );
1 ignored issue
show
Documentation Bug introduced by
The method createManager does not exist on object<Aimeos\Controller...mmon\Decorator\Example>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
29
	}
30
31
32
	public function testCallInvalid()
33
	{
34
		$this->setExpectedException( '\Aimeos\Controller\Frontend\Exception' );
35
		$this->object->invalidMethod();
1 ignored issue
show
Documentation Bug introduced by
The method invalidMethod does not exist on object<Aimeos\Controller...mmon\Decorator\Example>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
36
	}
37
38
39
	public function testGetContext()
40
	{
41
		$this->assertInstanceOf( '\Aimeos\MShop\Context\Item\Iface', $this->object->getContext() );
42
	}
43
44
45
	public function testGetController()
46
	{
47
		$this->assertInstanceOf( '\Aimeos\Controller\Frontend\Iface', $this->object->getController() );
48
	}
49
}