Repository navigation
Expand file tree
/
Copy pathPrefixTest.php
More file actions
33 lines (27 loc) · 1.46 KB
/
Copy pathPrefixTest.php
File metadata and controls
33 lines (27 loc) · 1.46 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
<?php
namespace Dingo\Api\Tests\Http\Validation;
use Illuminate\Http\Request;
use PHPUnit_Framework_TestCase;
use Dingo\Api\Http\Validation\Prefix;
class PrefixTest extends PHPUnit_Framework_TestCase
{
public function testValidationFailsWithInvalidOrNullPrefix()
{
$validator = new Prefix('foo');
$this->assertFalse($validator->validate(Request::create('bar', 'GET')), 'Validation passed when it should have failed with an invalid prefix.');
$validator = new Prefix(null);
$this->assertFalse($validator->validate(Request::create('foo', 'GET')), 'Validation passed when it should have failed with a null prefix.');
}
public function testValidationPasses()
{
$validator = new Prefix('foo');
$this->assertTrue($validator->validate(Request::create('foo', 'GET')), 'Validation failed when it should have passed with a valid prefix.');
$this->assertTrue($validator->validate(Request::create('foo/bar', 'GET')), 'Validation failed when it should have passed with a valid prefix.');
}
public function testValidationPassesWithHyphenatedPrefix()
{
$validator = new Prefix('web-api');
$this->assertTrue($validator->validate(Request::create('web-api', 'GET')), 'Validation failed when it should have passed with a valid prefix.');
$this->assertTrue($validator->validate(Request::create('web-api/bar', 'GET')), 'Validation failed when it should have passed with a valid prefix.');
}
}