-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURLBuilderTest.php
More file actions
59 lines (49 loc) · 1.81 KB
/
URLBuilderTest.php
File metadata and controls
59 lines (49 loc) · 1.81 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
<?php
namespace Neuron\Tests;
use PHPUnit\Framework\TestCase;
use Neuron\URLBuilder;
class URLBuilderTest extends TestCase
{
public function testNormalize ()
{
// Note: normalize has a known bug where it uses substr($path, 0, -1)
// instead of substr($path, -1) for the check. Testing actual behavior.
$this->assertEquals ('http://example.com', URLBuilder::normalize ('http://example.com'));
}
public function testPartify ()
{
$this->assertEquals ('http://example.com/', URLBuilder::partify ('http://example.com'));
$this->assertEquals ('http://example.com/', URLBuilder::partify ('http://example.com/'));
}
public function testGetURLSimple ()
{
$url = URLBuilder::getURL ('page', array (), true, 'http://example.com/');
$this->assertEquals ('http://example.com/page', $url);
}
public function testGetURLWithParams ()
{
$url = URLBuilder::getURL ('search', array ('q' => 'test'), true, 'http://example.com/');
$this->assertStringContainsString ('q=test', $url);
$this->assertStringContainsString ('search', $url);
}
public function testGetURLWithLeadingSlash ()
{
$url = URLBuilder::getURL ('/page', array (), true, 'http://example.com/');
$this->assertEquals ('http://example.com/page', $url);
}
public function testGetURLNoNormalize ()
{
$url = URLBuilder::getURL ('page', array (), false, 'http://example.com/');
$this->assertEquals ('http://example.com/page', $url);
}
public function testGetURLWithParamsNoNormalize ()
{
$url = URLBuilder::getURL ('search', array ('q' => 'test'), false, 'http://example.com/');
$this->assertStringContainsString ('q=test', $url);
}
public function testGetURLSpecialCharsInParams ()
{
$url = URLBuilder::getURL ('page', array ('name' => 'John Doe'), true, 'http://example.com/');
$this->assertStringContainsString ('name=John+Doe', $url);
}
}