Skip to content

Commit

Permalink
test enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k authored and phil-davis committed Aug 26, 2022
1 parent 3000a8a commit 78b519c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/HTTP/Auth/AWSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public function testNoHeader()
$this->assertEquals(AWS::ERR_NOAWSHEADER, $this->auth->errorCode);
}

public function testInvalidAuthorizationHeader()
{
$this->request->setMethod('GET');
$this->request->setHeader('Authorization', 'Invalid Auth Header');

$this->assertFalse($this->auth->init(), 'The Invalid AWS authorization header');
}

public function testIncorrectContentMD5()
{
$accessKey = 'accessKey';
Expand Down
32 changes: 32 additions & 0 deletions tests/HTTP/FunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@

class FunctionsTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider getHeaderValuesDataOnValues2
*/
public function testGetHeaderValuesOnValues2($result, $values1, $values2)
{
$this->assertEquals($result, getHeaderValues($values1, $values2));
}

public function getHeaderValuesDataOnValues2()
{
return [
[
['a', 'b'],
['a'],
['b'],
],
[
['a', 'b', 'c', 'd', 'e'],
['a', 'b', 'c'],
['d', 'e'],
],
];
}

/**
* @dataProvider getHeaderValuesData
*/
Expand Down Expand Up @@ -174,4 +198,12 @@ public function testToHTTPDate()
toDate($dt)
);
}

public function testParseMimeTypeOnInvalidMimeType()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Not a valid mime-type: invalid_mime_type');

parseMimeType('invalid_mime_type');
}
}
28 changes: 28 additions & 0 deletions tests/HTTP/SapiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,34 @@ public function testConstructFromServerArray()
$this->assertNull($request->getRawServerValue('FOO'));
}

public function testConstructFromServerArrayOnNullUrl()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The _SERVER array must have a REQUEST_URI key');

$request = Sapi::createFromServerArray([
'REQUEST_METHOD' => 'GET',
'HTTP_USER_AGENT' => 'Evert',
'CONTENT_TYPE' => 'text/xml',
'CONTENT_LENGTH' => '400',
'SERVER_PROTOCOL' => 'HTTP/1.0',
]);
}

public function testConstructFromServerArrayOnNullMethod()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The _SERVER array must have a REQUEST_METHOD key');

$request = Sapi::createFromServerArray([
'REQUEST_URI' => '/foo',
'HTTP_USER_AGENT' => 'Evert',
'CONTENT_TYPE' => 'text/xml',
'CONTENT_LENGTH' => '400',
'SERVER_PROTOCOL' => 'HTTP/1.0',
]);
}

public function testConstructPHPAuth()
{
$request = Sapi::createFromServerArray([
Expand Down

0 comments on commit 78b519c

Please sign in to comment.