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

Commit 9ca94c5

Browse files
committed
Add integration tests
1 parent 3e4edb8 commit 9ca94c5

9 files changed

+194
-2
lines changed

.travis.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cache:
99
env:
1010
global:
1111
- COMPOSER_ARGS="--no-interaction"
12-
- COVERAGE_DEPS="php-coveralls/php-coveralls"
12+
- DEPENDENCIES=""
1313
- LEGACY_DEPS="phpunit/phpunit"
1414

1515
matrix:
@@ -31,6 +31,7 @@ matrix:
3131
- DEPS=locked
3232
- CHECK_CS=true
3333
- TEST_COVERAGE=true
34+
- DEPENDENCIES="php-coveralls/php-coveralls"
3435
- php: 7
3536
env:
3637
- DEPS=latest
@@ -52,6 +53,11 @@ matrix:
5253
- php: 7.2
5354
env:
5455
- DEPS=latest
56+
- php: 7.2
57+
name: Integration tests
58+
env:
59+
- DEPENDENCIES="http-interop/http-factory-diactoros"
60+
5561

5662
before_install:
5763
- if [[ $TEST_COVERAGE != 'true' && "$(php --version | grep xdebug -ci)" -ge 1 ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
@@ -62,7 +68,7 @@ install:
6268
- if [[ $TRAVIS_PHP_VERSION =~ ^5.6 ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
6369
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
6470
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
65-
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
71+
- if ! [ -v "$DEPENDENCIES" ]; then travis_retry composer require --dev $COMPOSER_ARGS $DEPENDENCIES ; fi
6672
- stty cols 120 && composer show
6773

6874
script:

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"require-dev": {
3131
"ext-dom": "*",
3232
"ext-libxml": "*",
33+
"php-http/psr7-integration-tests": "dev-master",
3334
"phpunit/phpunit": "^5.7.16 || ^6.0.8 || ^7.2.7",
3435
"zendframework/zend-coding-standard": "~1.0"
3536
},

phpunit.xml.dist

+9
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,13 @@
1010
<directory suffix=".php">src</directory>
1111
</whitelist>
1212
</filter>
13+
14+
<php>
15+
<const name="REQUEST_FACTORY" value="Http\Factory\Diactoros\RequestFactory"/>
16+
<const name="RESPONSE_FACTORY" value="Http\Factory\Diactoros\ResponseFactory"/>
17+
<const name="SERVER_REQUEST_FACTORY" value="Http\Factory\Diactoros\ServerRequestFactory"/>
18+
<const name="STREAM_FACTORY" value="Http\Factory\Diactoros\StreamFactory"/>
19+
<const name="UPLOADED_FILE_FACTORY" value="Http\Factory\Diactoros\UploadedFileFactory"/>
20+
<const name="URI_FACTORY" value="Http\Factory\Diactoros\UriFactory"/>
21+
</php>
1322
</phpunit>

test/Integration/RequestTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Diactoros\Integration;
9+
10+
use Http\Factory\Diactoros\RequestFactory;
11+
use Http\Psr7Test\RequestIntegrationTest;
12+
use Zend\Diactoros\Request;
13+
14+
class RequestTest extends RequestIntegrationTest
15+
{
16+
public static function setUpBeforeClass()
17+
{
18+
if (!class_exists(RequestFactory::class)) {
19+
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
20+
}
21+
parent::setUpBeforeClass();
22+
}
23+
24+
public function createSubject()
25+
{
26+
return new Request('/', 'GET');
27+
}
28+
}

test/Integration/ResponseTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Diactoros\Integration;
9+
10+
use Http\Factory\Diactoros\RequestFactory;
11+
use Http\Psr7Test\ResponseIntegrationTest;
12+
use Zend\Diactoros\Response;
13+
14+
class ResponseTest extends ResponseIntegrationTest
15+
{
16+
public static function setUpBeforeClass()
17+
{
18+
if (!class_exists(RequestFactory::class)) {
19+
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
20+
}
21+
parent::setUpBeforeClass();
22+
}
23+
24+
public function createSubject()
25+
{
26+
return new Response();
27+
}
28+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Diactoros\Integration;
9+
10+
use Http\Factory\Diactoros\RequestFactory;
11+
use Http\Psr7Test\ServerRequestIntegrationTest;
12+
use Zend\Diactoros\ServerRequest;
13+
14+
class ServerRequestTest extends ServerRequestIntegrationTest
15+
{
16+
public static function setUpBeforeClass()
17+
{
18+
if (!class_exists(RequestFactory::class)) {
19+
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
20+
}
21+
parent::setUpBeforeClass();
22+
}
23+
24+
public function createSubject()
25+
{
26+
return new ServerRequest($_SERVER);
27+
}
28+
}

test/Integration/StreamTest.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Diactoros\Integration;
9+
10+
use Http\Factory\Diactoros\RequestFactory;
11+
use Http\Psr7Test\StreamIntegrationTest;
12+
use Zend\Diactoros\Stream;
13+
14+
class StreamTest extends StreamIntegrationTest
15+
{
16+
public static function setUpBeforeClass()
17+
{
18+
if (!class_exists(RequestFactory::class)) {
19+
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
20+
}
21+
parent::setUpBeforeClass();
22+
}
23+
24+
public function createStream($data)
25+
{
26+
if ($data instanceof StreamInterface) {
27+
return $data;
28+
}
29+
30+
return new Stream($data);
31+
}
32+
}

test/Integration/UploadedFileTest.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Diactoros\Integration;
9+
10+
use Http\Factory\Diactoros\RequestFactory;
11+
use Http\Psr7Test\UploadedFileIntegrationTest;
12+
use Zend\Diactoros\Stream;
13+
use Zend\Diactoros\UploadedFile;
14+
15+
class UploadedFileTest extends UploadedFileIntegrationTest
16+
{
17+
public static function setUpBeforeClass()
18+
{
19+
if (!class_exists(RequestFactory::class)) {
20+
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
21+
}
22+
parent::setUpBeforeClass();
23+
}
24+
25+
public function createSubject()
26+
{
27+
$stream = new Stream('php://memory', 'rw');
28+
$stream->write('foobar');
29+
30+
return new UploadedFile($stream, $stream->getSize(), UPLOAD_ERR_OK);
31+
}
32+
}

test/Integration/UriTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Diactoros\Integration;
9+
10+
use Http\Factory\Diactoros\RequestFactory;
11+
use Http\Psr7Test\UriIntegrationTest;
12+
use Zend\Diactoros\Uri;
13+
14+
class UriTest extends UriIntegrationTest
15+
{
16+
public static function setUpBeforeClass()
17+
{
18+
if (!class_exists(RequestFactory::class)) {
19+
self::markTestSkipped('You need to install http-interop/http-factory-diactoros to run integration tests');
20+
}
21+
parent::setUpBeforeClass();
22+
}
23+
24+
public function createUri($uri)
25+
{
26+
return new Uri($uri);
27+
}
28+
}

0 commit comments

Comments
 (0)