Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Add integration tests #325

Merged
merged 9 commits into from Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions .travis.yml
Expand Up @@ -9,7 +9,7 @@ cache:
env:
global:
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="php-coveralls/php-coveralls"
- DEPENDENCIES=""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, we don't need to pre-define globals; the shell will resolve it to '' if not defined.

- LEGACY_DEPS="phpunit/phpunit"

matrix:
Expand All @@ -31,6 +31,7 @@ matrix:
- DEPS=locked
- CHECK_CS=true
- TEST_COVERAGE=true
- DEPENDENCIES="php-coveralls/php-coveralls"
- php: 7
env:
- DEPS=latest
Expand All @@ -52,6 +53,11 @@ matrix:
- php: 7.2
env:
- DEPS=latest
- php: 7.2
name: Integration tests
env:
- DEPENDENCIES="http-interop/http-factory-diactoros"


before_install:
- if [[ $TEST_COVERAGE != 'true' && "$(php --version | grep xdebug -ci)" -ge 1 ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
Expand All @@ -62,7 +68,7 @@ install:
- if [[ $TRAVIS_PHP_VERSION =~ ^5.6 ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
- if ! [ -v "$DEPENDENCIES" ]; then travis_retry composer require --dev $COMPOSER_ARGS $DEPENDENCIES ; fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should become if [[ $DEPENDENCIES != '' ]] to be consistent with our other checks.

Also, please rename it to INTEGRATION_DEPS so we know what kind of dependencies we're defining and using here.

- stty cols 120 && composer show

script:
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -30,6 +30,7 @@
"require-dev": {
"ext-dom": "*",
"ext-libxml": "*",
"php-http/psr7-integration-tests": "dev-master",
"phpunit/phpunit": "^5.7.16 || ^6.0.8 || ^7.2.7",
"zendframework/zend-coding-standard": "~1.0"
},
Expand Down
9 changes: 9 additions & 0 deletions phpunit.xml.dist
Expand Up @@ -10,4 +10,13 @@
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<php>
<const name="REQUEST_FACTORY" value="Http\Factory\Diactoros\RequestFactory"/>
<const name="RESPONSE_FACTORY" value="Http\Factory\Diactoros\ResponseFactory"/>
<const name="SERVER_REQUEST_FACTORY" value="Http\Factory\Diactoros\ServerRequestFactory"/>
<const name="STREAM_FACTORY" value="Http\Factory\Diactoros\StreamFactory"/>
<const name="UPLOADED_FILE_FACTORY" value="Http\Factory\Diactoros\UploadedFileFactory"/>
<const name="URI_FACTORY" value="Http\Factory\Diactoros\UriFactory"/>
</php>
</phpunit>
28 changes: 28 additions & 0 deletions test/Integration/RequestTest.php
@@ -0,0 +1,28 @@
<?php
/**
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this line in all new files to:

 * @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)

(Copyright extends from when the file is introduced. Also, updates to use SSL-enabled URL.)

* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Diactoros\Integration;

use Http\Factory\Diactoros\RequestFactory;
use Http\Psr7Test\RequestIntegrationTest;
use Zend\Diactoros\Request;

class RequestTest extends RequestIntegrationTest
{
public static function setUpBeforeClass()
{
if (! class_exists(RequestFactory::class)) {
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
}
parent::setUpBeforeClass();
}

public function createSubject()
{
return new Request('/', 'GET');
}
}
28 changes: 28 additions & 0 deletions test/Integration/ResponseTest.php
@@ -0,0 +1,28 @@
<?php
/**
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Diactoros\Integration;

use Http\Factory\Diactoros\RequestFactory;
use Http\Psr7Test\ResponseIntegrationTest;
use Zend\Diactoros\Response;

class ResponseTest extends ResponseIntegrationTest
{
public static function setUpBeforeClass()
{
if (! class_exists(RequestFactory::class)) {
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
}
parent::setUpBeforeClass();
}

public function createSubject()
{
return new Response();
}
}
28 changes: 28 additions & 0 deletions test/Integration/ServerRequestTest.php
@@ -0,0 +1,28 @@
<?php
/**
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Diactoros\Integration;

use Http\Factory\Diactoros\RequestFactory;
use Http\Psr7Test\ServerRequestIntegrationTest;
use Zend\Diactoros\ServerRequest;

class ServerRequestTest extends ServerRequestIntegrationTest
{
public static function setUpBeforeClass()
{
if (! class_exists(RequestFactory::class)) {
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
}
parent::setUpBeforeClass();
}

public function createSubject()
{
return new ServerRequest($_SERVER);
}
}
33 changes: 33 additions & 0 deletions test/Integration/StreamTest.php
@@ -0,0 +1,33 @@
<?php
/**
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Diactoros\Integration;

use Http\Factory\Diactoros\RequestFactory;
use Http\Psr7Test\StreamIntegrationTest;
use Psr\Http\Message\StreamInterface;
use Zend\Diactoros\Stream;

class StreamTest extends StreamIntegrationTest
{
public static function setUpBeforeClass()
{
if (! class_exists(RequestFactory::class)) {
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
}
parent::setUpBeforeClass();
}

public function createStream($data)
{
if ($data instanceof StreamInterface) {
return $data;
}

return new Stream($data);
}
}
32 changes: 32 additions & 0 deletions test/Integration/UploadedFileTest.php
@@ -0,0 +1,32 @@
<?php
/**
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Diactoros\Integration;

use Http\Factory\Diactoros\RequestFactory;
use Http\Psr7Test\UploadedFileIntegrationTest;
use Zend\Diactoros\Stream;
use Zend\Diactoros\UploadedFile;

class UploadedFileTest extends UploadedFileIntegrationTest
{
public static function setUpBeforeClass()
{
if (! class_exists(RequestFactory::class)) {
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
}
parent::setUpBeforeClass();
}

public function createSubject()
{
$stream = new Stream('php://memory', 'rw');
$stream->write('foobar');

return new UploadedFile($stream, $stream->getSize(), UPLOAD_ERR_OK);
}
}
28 changes: 28 additions & 0 deletions test/Integration/UriTest.php
@@ -0,0 +1,28 @@
<?php
/**
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Diactoros\Integration;

use Http\Factory\Diactoros\RequestFactory;
use Http\Psr7Test\UriIntegrationTest;
use Zend\Diactoros\Uri;

class UriTest extends UriIntegrationTest
{
public static function setUpBeforeClass()
{
if (! class_exists(RequestFactory::class)) {
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
}
parent::setUpBeforeClass();
}

public function createUri($uri)
{
return new Uri($uri);
}
}