diff --git a/.github/workflows/push-run-test-suite.yml b/.github/workflows/push-run-test-suite.yml new file mode 100644 index 0000000..e885c91 --- /dev/null +++ b/.github/workflows/push-run-test-suite.yml @@ -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 + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 116f35f..245be7d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ vendor composer.lock -.idea \ No newline at end of file +.idea +.phpunit.cache +build \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 927655c..24fd26e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/composer.json b/composer.json index 35ac94a..1d40c81 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php": ">=5.5.0" }, "require-dev": { - "phpunit/phpunit": "4.0.*" + "phpunit/phpunit": "^10" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..2f6c642 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,23 @@ + + + + + tests + + + + + + src + + + diff --git a/src/HttpRequest.php b/src/HttpRequest.php index b9dbd36..babd2b3 100644 --- a/src/HttpRequest.php +++ b/src/HttpRequest.php @@ -9,6 +9,7 @@ class HttpRequest implements Request protected $server; protected $files; protected $cookies; + protected $inputStream; public function __construct( array $get, @@ -16,7 +17,7 @@ public function __construct( array $cookies, array $files, array $server, - $inputStream = '' + string $inputStream = '' ) { $this->getParameters = $get; $this->postParameters = $post; diff --git a/test/Unit/CookieBuilderTest.php b/test/Unit/CookieBuilderTest.php index f858c64..9e90357 100644 --- a/test/Unit/CookieBuilderTest.php +++ b/test/Unit/CookieBuilderTest.php @@ -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() { diff --git a/test/Unit/HttpCookieTest.php b/test/Unit/HttpCookieTest.php index 42545b2..6650755 100644 --- a/test/Unit/HttpCookieTest.php +++ b/test/Unit/HttpCookieTest.php @@ -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() { diff --git a/test/Unit/HttpRequestTest.php b/test/Unit/HttpRequestTest.php index f47fd3f..167b9cc 100644 --- a/test/Unit/HttpRequestTest.php +++ b/test/Unit/HttpRequestTest.php @@ -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() { @@ -241,11 +245,9 @@ public function testGetMethod() ); } - /** - * @expectedException Http\MissingRequestMetaVariableException - */ public function testGetMethodException() { + $this->expectException(\Http\MissingRequestMetaVariableException::class); $request = new HttpRequest([], [], [], [], []); $request->getMethod(); } @@ -271,11 +273,9 @@ public function testGetUri() ); } - /** - * @expectedException Http\MissingRequestMetaVariableException - */ public function testGetUriException() { + $this->expectException(\Http\MissingRequestMetaVariableException::class); $request = new HttpRequest([], [], [], [], []); $request->getUri(); } @@ -313,11 +313,9 @@ public function testGetHttpAccept() ); } - /** - * @expectedException Http\MissingRequestMetaVariableException - */ public function testGetHttpAcceptException() { + $this->expectException(\Http\MissingRequestMetaVariableException::class); $request = new HttpRequest([], [], [], [], []); $request->getHttpAccept(); } @@ -334,11 +332,9 @@ public function testGetReferer() ); } - /** - * @expectedException Http\MissingRequestMetaVariableException - */ public function testGetRefererException() { + $this->expectException(\Http\MissingRequestMetaVariableException::class); $request = new HttpRequest([], [], [], [], []); $request->getReferer(); } @@ -355,11 +351,9 @@ public function testGetUserAgent() ); } - /** - * @expectedException Http\MissingRequestMetaVariableException - */ public function testGetUserAgentException() { + $this->expectException(\Http\MissingRequestMetaVariableException::class); $request = new HttpRequest([], [], [], [], []); $request->getUserAgent(); } @@ -376,11 +370,9 @@ public function testGetIpAddress() ); } - /** - * @expectedException Http\MissingRequestMetaVariableException - */ public function testGetIpAddressException() { + $this->expectException(\Http\MissingRequestMetaVariableException::class); $request = new HttpRequest([], [], [], [], []); $request->getIpAddress(); } @@ -409,11 +401,9 @@ public function testGetQueryString() ); } - /** - * @expectedException Http\MissingRequestMetaVariableException - */ public function testGetQueryStringException() { + $this->expectException(\Http\MissingRequestMetaVariableException::class); $request = new HttpRequest([], [], [], [], []); $request->getQueryString(); } diff --git a/test/Unit/HttpResponseTest.php b/test/Unit/HttpResponseTest.php index d0f7a58..e23ea9a 100644 --- a/test/Unit/HttpResponseTest.php +++ b/test/Unit/HttpResponseTest.php @@ -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() {