forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoutingFilterTest.php
More file actions
executable file
·66 lines (49 loc) · 2.2 KB
/
RoutingFilterTest.php
File metadata and controls
executable file
·66 lines (49 loc) · 2.2 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
use Mockery as m;
class RoutingFilterTest extends PHPUnit_Framework_TestCase {
public function tearDown()
{
m::close();
}
public function testBasicPropertiesAreSet()
{
$annotation = new Illuminate\Routing\Controllers\Filter(array('run' => 'foo', 'on' => array('post')));
$this->assertEquals('foo', $annotation->run);
$this->assertEquals(array('post'), $annotation->on);
}
public function testHeadIsAddedToOnWhenGetMethodIsIncluded()
{
$annotation = new Illuminate\Routing\Controllers\Filter(array('on' => array('get', 'post')));
$this->assertTrue(in_array('head', $annotation->on));
}
public function testApplicableExcludesByRequestMethod()
{
$annotation = new Illuminate\Routing\Controllers\Filter(array('on' => 'post'));
$request = m::mock('Symfony\Component\HttpFoundation\Request');
$request->shouldReceive('getMethod')->once()->andReturn('get');
$this->assertFalse($annotation->applicable($request, 'foo'));
$request2 = m::mock('Symfony\Component\HttpFoundation\Request');
$request2->shouldReceive('getMethod')->once()->andReturn('post');
$this->assertTrue($annotation->applicable($request2, 'foo'));
}
public function testApplicableExcludesByOnlyRule()
{
$annotation = new Illuminate\Routing\Controllers\Filter(array('only' => 'foo'));
$request = m::mock('Symfony\Component\HttpFoundation\Request');
$request->shouldReceive('getMethod')->once()->andReturn('get');
$this->assertFalse($annotation->applicable($request, 'foo-bar'));
$request2 = m::mock('Symfony\Component\HttpFoundation\Request');
$request2->shouldReceive('getMethod')->once()->andReturn('get');
$this->assertTrue($annotation->applicable($request2, 'foo'));
}
public function testApplicableExcludesByExceptRule()
{
$annotation = new Illuminate\Routing\Controllers\Filter(array('except' => 'foo'));
$request = m::mock('Symfony\Component\HttpFoundation\Request');
$request->shouldReceive('getMethod')->once()->andReturn('get');
$this->assertTrue($annotation->applicable($request, 'foo-bar'));
$request2 = m::mock('Symfony\Component\HttpFoundation\Request');
$request2->shouldReceive('getMethod')->once()->andReturn('get');
$this->assertFalse($annotation->applicable($request2, 'foo'));
}
}