-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSplDoublyLinkedListVoterTest.php
More file actions
50 lines (38 loc) · 1.61 KB
/
Copy pathSplDoublyLinkedListVoterTest.php
File metadata and controls
50 lines (38 loc) · 1.61 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
42
43
44
45
46
47
48
49
50
<?php
namespace DesignPatterns\Behavioral\TemplateMethod\Test;
use DesignPatterns\Behavioral\TemplateMethod\AbstractVoter;
use DesignPatterns\Behavioral\TemplateMethod\SplDoublyLinkedListVoter;
/**
* Test @see SplDoublyLinkedListVoterTest
*
* @author Vlad Riabchenko <contact@vria.eu>
*/
class SplDoublyLinkedListVoterTest extends \PHPUnit_Framework_TestCase
{
public function testAccessGranted()
{
$voter = new SplDoublyLinkedListVoter();
$list = new \SplDoublyLinkedList();
$this->assertEquals(AbstractVoter::ACCESS_GRANTED, $voter->vote($list, "unshift"));
$this->assertEquals(AbstractVoter::ACCESS_GRANTED, $voter->vote($list, "push"));
$list->push("foo");
$list->push("bar");
$this->assertEquals(AbstractVoter::ACCESS_GRANTED, $voter->vote($list, "shift"));
$this->assertEquals(AbstractVoter::ACCESS_GRANTED, $voter->vote($list, "pop"));
}
public function testAccessDenied()
{
$voter = new SplDoublyLinkedListVoter();
$list = new \SplDoublyLinkedList();
$this->assertEquals(AbstractVoter::ACCESS_DENIED, $voter->vote($list, "shift"));
$this->assertEquals(AbstractVoter::ACCESS_DENIED, $voter->vote($list, "pop"));
}
public function testAbstain()
{
$voter = new SplDoublyLinkedListVoter();
$doublyLinkedList = new \SplDoublyLinkedList();
$this->assertEquals(AbstractVoter::ABSTAINED, $voter->vote($doublyLinkedList, "next"));
$fixedArray = new \SplFixedArray(10);
$this->assertEquals(AbstractVoter::ABSTAINED, $voter->vote($fixedArray, "toArray"));
}
}