1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @category Zookal_Mock |
5
|
|
|
* @package Helper |
6
|
|
|
* @author Cyrill Schumacher | {firstName}@{lastName}.fm | @SchumacherFM |
7
|
|
|
* @copyright Copyright (c) Zookal Pty Ltd |
8
|
|
|
* @license OSL - Open Software Licence 3.0 | http://opensource.org/licenses/osl-3.0.php |
9
|
|
|
*/ |
10
|
|
|
class Zookal_Mock_Test_Helper_DataTest extends EcomDev_PHPUnit_Test_Case |
|
|
|
|
11
|
|
|
{ |
12
|
|
|
protected $_class = 'Zookal_Mock_Helper_Data'; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @param int $enabled |
16
|
|
|
* |
17
|
|
|
* @return PHPUnit_Framework_MockObject_MockObject|null |
18
|
|
|
*/ |
19
|
|
|
public function getStoreMock($enabled = 0) |
20
|
|
|
{ |
21
|
|
|
$stubStore = $this->getMock('Mage_Core_Model_Store'); |
22
|
|
|
$stubStore->expects($this->any()) |
23
|
|
|
->method('getConfig') |
24
|
|
|
->with('dev/zookalmock/enable_method_log') |
25
|
|
|
->will($this->returnValue($enabled)); |
26
|
|
|
return $stubStore; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param PHPUnit_Framework_MockObject_MockObject $mockStore |
31
|
|
|
* |
32
|
|
|
* @return Zookal_Mock_Helper_Data |
33
|
|
|
*/ |
34
|
|
|
public function getInstance($mockStore = null) |
35
|
|
|
{ |
36
|
|
|
if (null === $mockStore) { |
37
|
|
|
$mockStore = $this->getStoreMock(); |
38
|
|
|
} |
39
|
|
|
return new $this->_class($mockStore); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @test |
44
|
|
|
*/ |
45
|
|
|
public function itShouldExist() |
46
|
|
|
{ |
47
|
|
|
$this->assertInstanceOf($this->_class, $this->getInstance()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @test |
52
|
|
|
*/ |
53
|
|
|
public function itShouldExtendTheHelperAbstract() |
54
|
|
|
{ |
55
|
|
|
$this->assertInstanceOf('Mage_Core_Helper_Abstract', $this->getInstance()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @test |
60
|
|
|
*/ |
61
|
|
|
public function itShouldHaveAGetStoreMethod() |
62
|
|
|
{ |
63
|
|
|
$this->assertTrue(is_callable(array($this->_class, 'getStore'))); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @test |
68
|
|
|
* @depends itShouldHaveAGetStoreMethod |
69
|
|
|
*/ |
70
|
|
|
public function itShouldReturnTheInjectedStoreModel() |
71
|
|
|
{ |
72
|
|
|
$mockStore = $this->getMock('Mage_Core_Model_Store'); |
73
|
|
|
$instance = $this->getInstance($mockStore); |
74
|
|
|
$this->assertSame($mockStore, $instance->getStore()); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @test |
79
|
|
|
*/ |
80
|
|
|
public function itShouldHaveAMethodIsLogMethodEnabled() |
81
|
|
|
{ |
82
|
|
|
$this->assertTrue(is_callable(array($this->_class, 'isLogMethodEnabled'))); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @test |
87
|
|
|
* @depends itShouldHaveAMethodIsLogMethodEnabled |
88
|
|
|
*/ |
89
|
|
|
public function itShouldReturnEnabledLog() |
90
|
|
|
{ |
91
|
|
|
$mockStore = $this->getStoreMock(1); |
92
|
|
|
$instance = $this->getInstance($mockStore); |
93
|
|
|
$this->assertTrue($instance->isLogMethodEnabled()); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @test |
98
|
|
|
* @depends itShouldHaveAMethodIsLogMethodEnabled |
99
|
|
|
*/ |
100
|
|
|
public function itShouldReturnDisabledLog() |
101
|
|
|
{ |
102
|
|
|
$mockStore = $this->getStoreMock(0); |
103
|
|
|
$instance = $this->getInstance($mockStore); |
104
|
|
|
$this->assertFalse($instance->isLogMethodEnabled()); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @test |
109
|
|
|
*/ |
110
|
|
|
public function itShouldHaveAMethodSetMockPhpIncludePath() |
111
|
|
|
{ |
112
|
|
|
$this->assertTrue(is_callable(array($this->_class, 'setMockPhpIncludePath'))); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @test |
117
|
|
|
*/ |
118
|
|
|
public function itShouldNotSetTheMockPhpIncludePathAgain() |
119
|
|
|
{ |
120
|
|
|
$this->assertFalse($this->getInstance()->setMockPhpIncludePath()); |
121
|
|
|
$newIncludePath = get_include_path(); |
122
|
|
|
$this->assertContains('app/code/community/Zookal/Mock/Model/Mocks', $newIncludePath); |
123
|
|
|
} |
124
|
|
|
} |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.