forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestTest.php
More file actions
58 lines (47 loc) · 1.45 KB
/
Copy pathRequestTest.php
File metadata and controls
58 lines (47 loc) · 1.45 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
<?php namespace CodeIgniter\HTTP;
use Config\App;
/**
* @backupGlobals enabled
*/
class RequestTest extends \CIUnitTestCase
{
/**
* @var CodeIgniter\HTTP\Request
*/
protected $request;
public function setUp()
{
$this->request = new Request(new App());
}
//--------------------------------------------------------------------
public function ipAddressChecks()
{
return [
'empty' => [false, ''],
'zero' => [false , 0],
'large_ipv4' => [false, '256.256.256.999', 'ipv4'],
'good_ipv4' => [true, '100.100.100.0', 'ipv4'],
'good_default' => [true, '100.100.100.0'],
'zeroed_ipv4' => [true, '0.0.0.0'],
'large_ipv6' => [false, 'h123:0000:0000:0000:0000:0000:0000:0000', 'ipv6'],
'good_ipv6' => [true, '2001:0db8:85a3:0000:0000:8a2e:0370:7334'],
'confused_ipv6' => [false, '255.255.255.255', 'ipv6'],
];
}
//--------------------------------------------------------------------
/**
* @dataProvider ipAddressChecks
*/
public function testValidIPAddress($expected, $address, $type=null)
{
$this->assertEquals($expected, $this->request->isValidIP($address, $type));
}
//--------------------------------------------------------------------
public function testMethodReturnsRightStuff()
{
// Defaults method to GET now.
$this->assertEquals('get', $this->request->getMethod());
$this->assertEquals('GET', $this->request->getMethod(true));
}
//--------------------------------------------------------------------
}