Skip to content

Commit

Permalink
Add travis ci, fix symfony tests, add easy coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Carsten Windler committed Sep 10, 2018
1 parent 6719970 commit bc58df6
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 254 deletions.
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

language: php

cache:
directories:
- vendor
- $HOME/.composer/cache

php:
- 7.0
- 7.1
- 7.2

install:
- composer install

script:
- vendor/bin/phpunit -c phpunit.xml --coverage-text
- vendor/bin/ecs check src
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,4 @@ For Symfony, the build-in serializers are used. Nice.

# Todo

* setup TravisCI
* make storage path of `*_to_file()` configurable
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
}
],
"require": {
"php": "^5.3 | ^7.0",
"php": ">=7.0",
"zendframework/zend-diactoros": "^1.3",
"symfony/http-foundation": "^2.7 |^3.3"
},
"require-dev": {
"phpunit/phpunit": "^5 | ^6.3",
"mockery/mockery": "0.9.*",
"mikey179/vfsStream": "^1.6.4"
"mikey179/vfsStream": "^1.6.4",
"symplify/easy-coding-standard": "^4.6"
},
"autoload": {
"files": [
Expand Down
4 changes: 4 additions & 0 deletions easy-coding-standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# easy-coding-standard.yml
imports:
- { resource: 'vendor/symplify/easy-coding-standard/config/clean-code.yml' }
- { resource: 'vendor/symplify/easy-coding-standard/config/psr2.yml' }
12 changes: 4 additions & 8 deletions src/HttpHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ function request_to_string($request)
{
$requestString = "unknown\r\n";

if (
class_exists('Symfony\Component\HttpFoundation\Request') &&
if (class_exists('Symfony\Component\HttpFoundation\Request') &&
$request instanceof Symfony\Component\HttpFoundation\Request
) {
$requestString = $request->__toString();
}

if (
interface_exists('Psr\Http\Message\RequestInterface') &&
if (interface_exists('Psr\Http\Message\RequestInterface') &&
$request instanceof Psr\Http\Message\RequestInterface
) {
$requestString = RequestSerializer::toString($request);
Expand Down Expand Up @@ -107,15 +105,13 @@ function response_to_string($response)
{
$responseString = "unknown\r\n";

if (
class_exists('Symfony\Component\HttpFoundation\Response') &&
if (class_exists('Symfony\Component\HttpFoundation\Response') &&
$response instanceof Symfony\Component\HttpFoundation\Response
) {
$responseString = $response->__toString();
}

if (
interface_exists('Psr\Http\Message\ResponseInterface') &&
if (interface_exists('Psr\Http\Message\ResponseInterface') &&
$response instanceof Psr\Http\Message\ResponseInterface
) {
$responseString = ResponseSerializer::toString($response);
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/Request/RequestToStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ public function symfony_request_to_string()

TestCase::assertEquals(
"POST / HTTP/1.1\r\n" .
"Accept: \r\n" .
"Accept-Charset: \r\n" .
"Accept-Language: \r\n" .
"Content-Type: application/x-www-form-urlencoded\r\n" .
"Host: www.carstenwindler.de\r\n\r\n",
"Host: www.carstenwindler.de\r\n" .
"User-Agent: \r\n\r\n",
request_to_string($request)
);
}
Expand Down
66 changes: 0 additions & 66 deletions tests/Unit/RequestToCurlTest.php

This file was deleted.

105 changes: 0 additions & 105 deletions tests/Unit/RequestToFileTest.php

This file was deleted.

71 changes: 0 additions & 71 deletions tests/Unit/RequestToStringTest.php

This file was deleted.

0 comments on commit bc58df6

Please sign in to comment.