|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @license MIT |
|
7
|
|
|
* @copyright 2013 - 2015 Cross Solution <http://cross-solution.de> |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** */ |
|
11
|
|
|
namespace AclTest\Assertion; |
|
12
|
|
|
|
|
13
|
|
|
use Acl\Assertion\AssertionManagerFactory; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Test the AssertionManagerFactory. |
|
17
|
|
|
* |
|
18
|
|
|
* @author Mathias Gelhausen <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class AssertionManagerFactoryTest extends \PHPUnit_Framework_TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
public function testImplementsInterface() |
|
24
|
|
|
{ |
|
25
|
|
|
$target = new AssertionManagerFactory(); |
|
26
|
|
|
|
|
27
|
|
|
$this->assertInstanceOf('\Zend\ServiceManager\FactoryInterface', $target); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function testCreateServiceReturnsAssertionManager() |
|
31
|
|
|
{ |
|
32
|
|
|
$services = $this->getMockBuilder('\Zend\ServiceManager\ServiceManager') |
|
33
|
|
|
->disableOriginalConstructor() |
|
34
|
|
|
->getMock(); |
|
35
|
|
|
|
|
36
|
|
|
$services->expects($this->once())->method('get')->with('Config') |
|
37
|
|
|
->willReturn(array()); |
|
38
|
|
|
|
|
39
|
|
|
$target = new AssertionManagerFactory(); |
|
40
|
|
|
$manager = $target->createService($services); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertInstanceOf('\Acl\Assertion\AssertionManager', $manager); |
|
43
|
|
|
$this->assertFalse($manager->shareByDefault(), 'The managers\' shareByDefault value must be set to FALSE by the factory.'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Note: We do not need to test the Configuration in detail here, because this is done in the test |
|
48
|
|
|
* for the config object in zend frameworks' unit tests already. |
|
49
|
|
|
* |
|
50
|
|
|
* @dataProvider provideConfigArrays |
|
51
|
|
|
*/ |
|
52
|
|
|
public function testCorrectConfigIsUsedToConfigureTheManager($config, $testName, $testResult) |
|
53
|
|
|
{ |
|
54
|
|
|
$services = $this->getMockBuilder('\Zend\ServiceManager\ServiceManager') |
|
55
|
|
|
->disableOriginalConstructor() |
|
56
|
|
|
->getMock(); |
|
57
|
|
|
|
|
58
|
|
|
$services->expects($this->once())->method('get')->with('Config') |
|
59
|
|
|
->willReturn($config); |
|
60
|
|
|
|
|
61
|
|
|
$target = new AssertionManagerFactory(); |
|
62
|
|
|
|
|
63
|
|
|
$manager = $target->createService($services); |
|
64
|
|
|
|
|
65
|
|
|
$this->assertTrue($testResult === $manager->has($testName), 'Expected managers\' has method to return ' . ($testResult ? 'TRUE' : 'FALSE') . ' on ' .$testName); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function provideConfigArrays() |
|
69
|
|
|
{ |
|
70
|
|
|
return array( |
|
71
|
|
|
array(array('acl' => array('nono' => array('invokables' => array('failTest' => 'noneClass')))), 'failTest', false), |
|
72
|
|
|
array(array('acl' => array('assertions' => array('invokables' => array('successTest' => 'existClass')))), 'successTest', true), |
|
73
|
|
|
); |
|
74
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
} |