-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSplFixedArrayVoterTest.php
More file actions
41 lines (32 loc) · 1.18 KB
/
Copy pathSplFixedArrayVoterTest.php
File metadata and controls
41 lines (32 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace DesignPatterns\Behavioral\TemplateMethod\Test;
use DesignPatterns\Behavioral\TemplateMethod\SplFixedArrayVoter;
use DesignPatterns\Behavioral\TemplateMethod\AbstractVoter;
/**
* Test @see SplFixedArrayVoter
*
* @author Vlad Riabchenko <contact@vria.eu>
*/
class SplFixedArrayVoterTest extends \PHPUnit_Framework_TestCase
{
public function testAccessGranted()
{
$voter = new SplFixedArrayVoter();
$hasAccess = $voter->vote(new \SplFixedArray(10), 'toArray');
$this->assertEquals(AbstractVoter::ACCESS_GRANTED, $hasAccess);
}
public function testAccessDenied()
{
$voter = new SplFixedArrayVoter();
$hasAccess = $voter->vote(new \SplFixedArray(), 'toArray');
$this->assertEquals(AbstractVoter::ACCESS_DENIED, $hasAccess);
}
public function accessAbstain()
{
$voter = new SplFixedArrayVoter();
$doublyLinkedList = new \SplDoublyLinkedList();
$this->assertEquals(AbstractVoter::ABSTAINED, $voter->vote($doublyLinkedList, "push"));
$fixedArray = new \SplFixedArray(10);
$this->assertEquals(AbstractVoter::ABSTAINED, $voter->vote($fixedArray, "count"));
}
}