Completed
Push — master ( b98343...f157ac )
by Aimeos
03:37
created

BaseTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
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\Admin\JQAdm\Common\Decorator;
10
11
12
class BaseTest extends \PHPUnit_Framework_TestCase
13
{
14
	private $object;
15
	private $mock;
16
17
18
	protected function setUp()
19
	{
20
		$this->mock = $this->getMockBuilder( 'Aimeos\Admin\JQAdm\Product\Standard' )
21
			->setMethods( array( 'copy', 'create', 'delete', 'get', 'save', 'search', 'getSubClient' ) )
22
			->disableOriginalConstructor()
23
			->getMock();
24
25
		$templatePaths = \TestHelperJqadm::getTemplatePaths();
26
		$context = \TestHelperJqadm::getContext();
27
28
		$this->object = new \Aimeos\Admin\JQAdm\Common\Decorator\Page( $this->mock, $context, $templatePaths );
29
	}
30
31
32
	protected function tearDown()
33
	{
34
		unset( $this->object, $this->mock );
35
	}
36
37
38
	public function testCallInvalid()
39
	{
40
		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
41
		$this->object->invalidMethod();
1 ignored issue
show
Documentation Bug introduced by
The method invalidMethod does not exist on object<Aimeos\Admin\JQAdm\Common\Decorator\Page>? 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...
42
	}
43
44
45
	public function testCopy()
46
	{
47
		$this->mock->expects( $this->once() )->method( 'copy' )->will( $this->returnValue( 'test' ) );
48
49
		$this->assertEquals( 'test', $this->object->copy() );
50
	}
51
52
53
	public function testCreate()
54
	{
55
		$this->mock->expects( $this->once() )->method( 'create' )->will( $this->returnValue( 'test' ) );
56
57
		$this->assertEquals( 'test', $this->object->create() );
58
	}
59
60
61
	public function testDelete()
62
	{
63
		$this->mock->expects( $this->once() )->method( 'delete' )->will( $this->returnValue( 'test' ) );
64
65
		$this->assertEquals( 'test', $this->object->delete() );
66
	}
67
68
69
	public function testGet()
70
	{
71
		$this->mock->expects( $this->once() )->method( 'get' )->will( $this->returnValue( 'test' ) );
72
73
		$this->assertEquals( 'test', $this->object->get() );
74
	}
75
76
77
	public function testSave()
78
	{
79
		$this->mock->expects( $this->once() )->method( 'save' )->will( $this->returnValue( 'test' ) );
80
81
		$this->assertEquals( 'test', $this->object->save() );
82
	}
83
84
85
	public function testSearch()
86
	{
87
		$this->mock->expects( $this->once() )->method( 'search' )->will( $this->returnValue( 'test' ) );
88
89
		$this->assertEquals( 'test', $this->object->search() );
90
	}
91
92
93
	public function testGetSubClient()
94
	{
95
		$this->mock->expects( $this->once() )->method( 'getSubClient' )->will( $this->returnValue( 'test' ) );
96
97
		$this->assertEquals( 'test', $this->object->getSubClient( 'invalid' ) );
98
	}
99
}
100