Skip to content

Commit fd9c820

Browse files
committed
IncomingRequest testing completed
1 parent 4a45483 commit fd9c820

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

tests/system/HTTP/IncomingRequestDetectingTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public function testPathDefault()
3535
$this->assertEquals($expected, $this->request->detectPath());
3636
}
3737

38+
public function testPathEmpty()
39+
{
40+
$this->request->uri = '/';
41+
$_SERVER['REQUEST_URI'] = '/';
42+
$_SERVER['SCRIPT_NAME'] = '/index.php';
43+
$expected = '/';
44+
$this->assertEquals($expected, $this->request->detectPath());
45+
}
46+
3847
public function testPathRequestURI()
3948
{
4049
$this->request->uri = '/index.php/woot?code=good#pos';

tests/system/HTTP/IncomingRequestTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public function testCanGrabPostBeforeGet()
6161

6262
//--------------------------------------------------------------------
6363

64+
public function testNoOldInput()
65+
{
66+
$this->assertNull($this->request->getOldInput('name'));
67+
}
68+
6469
public function testCanGetOldInput()
6570
{
6671
$_SESSION['_ci_old_input'] = [
@@ -83,6 +88,16 @@ public function testCanGetOldInputDotted()
8388
$this->assertEquals('two', $this->request->getOldInput('apple.name'));
8489
}
8590

91+
public function testMissingOldInput()
92+
{
93+
$_SESSION['_ci_old_input'] = [
94+
'get' => ['apple' => ['name' => 'two']],
95+
'post' => ['banana' => ['name' => 'foo']],
96+
];
97+
98+
$this->assertNull($this->request->getOldInput('pineapple.name'));
99+
}
100+
86101
// Reference: https://github.com/codeigniter4/CodeIgniter4/issues/1492
87102
public function testCanGetOldInputArray()
88103
{
@@ -349,4 +364,21 @@ public function testFileCollectionFactory()
349364
}
350365

351366
//--------------------------------------------------------------------
367+
368+
public function testGetFile()
369+
{
370+
$_FILES = [
371+
'userfile' => [
372+
'name' => 'someFile.txt',
373+
'type' => 'text/plain',
374+
'size' => '124',
375+
'tmp_name' => '/tmp/myTempFile.txt',
376+
'error' => 0,
377+
],
378+
];
379+
380+
$gotit = $this->request->getFile('userfile');
381+
$this->assertEquals(124, $gotit->getSize());
382+
}
383+
352384
}

0 commit comments

Comments
 (0)