Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http library moderinsation #25

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/push-run-test-suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: push-run-test-suite
run-name: ${{ github.event.repository.name }} ${{ github.event.ref }} ${{ github.event.head_commit.message }} run test suite.
on: [push]
jobs:
run-test-suite:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: xdebug
tools: composer:v2
- name : Install php-coveralls
run: composer global require php-coveralls/php-coveralls:~2.5
- name: Install dependencies
run: composer install --dev --no-interaction
- name: Create build directory
run: mkdir -p build/logs
- name: Run test suite
run: ./vendor/bin/phpunit --bootstrap vendor/autoload.php --coverage-clover build/logs/clover.xml test
- name: Upload coverage to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
php-coveralls --coverage_clover=build/logs/clover.xml -v

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vendor
composer.lock
.idea
.idea
.phpunit.cache
build
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php
php:
- "5.5"
- "8.2"

install:
- composer require satooshi/php-coveralls:~0.6@stable
- composer require php-coveralls/php-coveralls:~2.5

before_script:
- mkdir -p build/logs
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"php": ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit": "4.0.*"
"phpunit/phpunit": "^10"
},
"autoload": {
"psr-4": {
Expand Down
23 changes: 23 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
3 changes: 2 additions & 1 deletion src/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ class HttpRequest implements Request
protected $server;
protected $files;
protected $cookies;
protected $inputStream;

public function __construct(
array $get,
array $post,
array $cookies,
array $files,
array $server,
$inputStream = ''
string $inputStream = ''
) {
$this->getParameters = $get;
$this->postParameters = $post;
Expand Down
6 changes: 5 additions & 1 deletion test/Unit/CookieBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

use Http\CookieBuilder;

class CookieBuilderTest extends \PHPUnit_Framework_TestCase
/**
* @covers Http\CookieBuilder
* @covers Http\HttpCookie
*/
class CookieBuilderTest extends \PHPUnit\Framework\TestCase
{
public function testSetDefaultDomain()
{
Expand Down
5 changes: 4 additions & 1 deletion test/Unit/HttpCookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

use Http\HttpCookie;

class HttpCookieTest extends \PHPUnit_Framework_TestCase
/**
* @covers Http\HttpCookie
*/
class HttpCookieTest extends \PHPUnit\Framework\TestCase
{
public function testGetName()
{
Expand Down
34 changes: 12 additions & 22 deletions test/Unit/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

use Http\HttpRequest;

class HttpRequestTest extends \PHPUnit_Framework_TestCase
/**
* @covers Http\HttpRequest
* @uses Http\MissingRequestMetaVariableException
*/
class HttpRequestTest extends \PHPUnit\Framework\TestCase
{
public function testGetParameter()
{
Expand Down Expand Up @@ -241,11 +245,9 @@ public function testGetMethod()
);
}

/**
* @expectedException Http\MissingRequestMetaVariableException
*/
public function testGetMethodException()
{
$this->expectException(\Http\MissingRequestMetaVariableException::class);
$request = new HttpRequest([], [], [], [], []);
$request->getMethod();
}
Expand All @@ -271,11 +273,9 @@ public function testGetUri()
);
}

/**
* @expectedException Http\MissingRequestMetaVariableException
*/
public function testGetUriException()
{
$this->expectException(\Http\MissingRequestMetaVariableException::class);
$request = new HttpRequest([], [], [], [], []);
$request->getUri();
}
Expand Down Expand Up @@ -313,11 +313,9 @@ public function testGetHttpAccept()
);
}

/**
* @expectedException Http\MissingRequestMetaVariableException
*/
public function testGetHttpAcceptException()
{
$this->expectException(\Http\MissingRequestMetaVariableException::class);
$request = new HttpRequest([], [], [], [], []);
$request->getHttpAccept();
}
Expand All @@ -334,11 +332,9 @@ public function testGetReferer()
);
}

/**
* @expectedException Http\MissingRequestMetaVariableException
*/
public function testGetRefererException()
{
$this->expectException(\Http\MissingRequestMetaVariableException::class);
$request = new HttpRequest([], [], [], [], []);
$request->getReferer();
}
Expand All @@ -355,11 +351,9 @@ public function testGetUserAgent()
);
}

/**
* @expectedException Http\MissingRequestMetaVariableException
*/
public function testGetUserAgentException()
{
$this->expectException(\Http\MissingRequestMetaVariableException::class);
$request = new HttpRequest([], [], [], [], []);
$request->getUserAgent();
}
Expand All @@ -376,11 +370,9 @@ public function testGetIpAddress()
);
}

/**
* @expectedException Http\MissingRequestMetaVariableException
*/
public function testGetIpAddressException()
{
$this->expectException(\Http\MissingRequestMetaVariableException::class);
$request = new HttpRequest([], [], [], [], []);
$request->getIpAddress();
}
Expand Down Expand Up @@ -409,11 +401,9 @@ public function testGetQueryString()
);
}

/**
* @expectedException Http\MissingRequestMetaVariableException
*/
public function testGetQueryStringException()
{
$this->expectException(\Http\MissingRequestMetaVariableException::class);
$request = new HttpRequest([], [], [], [], []);
$request->getQueryString();
}
Expand Down
5 changes: 4 additions & 1 deletion test/Unit/HttpResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

use Http\HttpResponse;

class HttpResponseTest extends \PHPUnit_Framework_TestCase
/**
* @covers Http\HttpResponse
*/
class HttpResponseTest extends \PHPUnit\Framework\TestCase
{
public function testSetStatusCode()
{
Expand Down