Added proper tests for multipart.
This commit is contained in:
parent
d56be84bbb
commit
63170fe412
2 changed files with 37 additions and 8 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.2503.122055
|
||||
0.2503.122121
|
||||
|
|
|
@ -83,28 +83,57 @@ final class HttpFormContentTest extends TestCase {
|
|||
'----geckoformboundaryc23c64d876d81ed7258ada21a9eb0b06'
|
||||
);
|
||||
|
||||
// normal form api
|
||||
$this->assertFalse($form->hasParam('never_has_this'));
|
||||
$this->assertEquals(0, $form->getParamCount('never_has_this_either'));
|
||||
$this->assertNull($form->getParam('this_is_not_there_either'));
|
||||
$this->assertNull($form->getParamData('this_is_not_there_either'));
|
||||
$this->assertEquals(0401, $form->getParamAt('abusing_octal_notation_for_teto_reference', 3510, default: 0401));
|
||||
$this->assertEquals(null, $form->getParamDataAt('abusing_octal_notation_for_teto_reference', 3510));
|
||||
|
||||
$this->assertTrue($form->hasParam('meow'));
|
||||
$this->assertEquals(1, $form->getParamCount('meow'));
|
||||
$this->assertEquals('sfdsfs', $form->getParam('meow'));
|
||||
$meow = $form->getParamData('meow');
|
||||
$this->assertInstanceOf(ValueMultipartFormData::class, $meow);
|
||||
$this->assertEquals('meow', $meow->name);
|
||||
$this->assertEquals('sfdsfs', (string)$meow->stream);
|
||||
$this->assertEquals('form-data; name="meow"', $meow->getHeaderLine('Content-Disposition'));
|
||||
$this->assertEquals('sfdsfs', $meow->value);
|
||||
|
||||
$this->assertTrue($form->hasParam('mewow'));
|
||||
$this->assertEquals(1, $form->getParamCount('mewow'));
|
||||
$this->assertEquals('https://railgun.sh/sockchat', $form->getParam('mewow'));
|
||||
$mewow = $form->getParamData('mewow');
|
||||
$this->assertInstanceOf(ValueMultipartFormData::class, $mewow);
|
||||
$this->assertEquals('mewow', $mewow->name);
|
||||
$this->assertEquals('https://railgun.sh/sockchat', (string)$mewow->stream);
|
||||
$this->assertEquals('form-data; name="mewow"', $mewow->getHeaderLine('Content-Disposition'));
|
||||
$this->assertEquals('https://railgun.sh/sockchat', $mewow->value);
|
||||
|
||||
$this->assertTrue($form->hasParam('"the'));
|
||||
$this->assertEquals(2, $form->getParamCount('"the'));
|
||||
$this->assertEquals('value!', $form->getParam('"the'));
|
||||
$secondValue = $form->getParamAt('"the', 1);
|
||||
$this->assertIsString($secondValue);
|
||||
$this->assertEquals('8e3b3df1ab6be7498566e795cc9fe3b8f55e084d0e1fcf3e5323269cfc1bc884', hash('sha256', $secondValue));
|
||||
|
||||
// multipart specific api
|
||||
// tbd
|
||||
$the2Value = $form->getParamAt('"the', 1);
|
||||
$this->assertIsString($the2Value);
|
||||
$the2Hash = hash('sha256', $the2Value);
|
||||
$this->assertEquals('8e3b3df1ab6be7498566e795cc9fe3b8f55e084d0e1fcf3e5323269cfc1bc884', $the2Hash);
|
||||
$the1 = $form->getParamData('"the');
|
||||
$this->assertInstanceOf(ValueMultipartFormData::class, $the1);
|
||||
$this->assertEquals('"the', $the1->name);
|
||||
$this->assertEquals('value!', (string)$the1->stream);
|
||||
$this->assertEquals('form-data; name="%22the"', $the1->getHeaderLine('Content-Disposition'));
|
||||
$this->assertEquals('value!', $the1->value);
|
||||
$the2 = $form->getParamDataAt('"the', 1);
|
||||
$this->assertInstanceOf(FileMultipartFormData::class, $the2);
|
||||
$this->assertEquals('"the', $the2->name);
|
||||
$this->assertEquals('kagaglue.png', $the2->fileName);
|
||||
$this->assertEquals('kagaglue.png', $the2->getClientFilename());
|
||||
$this->assertEquals(766, $the2->getSize());
|
||||
$this->assertEquals('form-data; name="%22the"; filename="kagaglue.png"', $the2->getHeaderLine('Content-Disposition'));
|
||||
$this->assertEquals('image/png', $the2->getHeaderLine('Content-Type'));
|
||||
$this->assertEquals('image/png', $the2->getClientMediaType());
|
||||
$the2Path = tempnam(sys_get_temp_dir(), 'ndx-test-');
|
||||
$the2->moveTo($the2Path);
|
||||
$this->assertEquals($the2Hash, hash_file('sha256', $the2Path));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue