Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<!-- Third party files and build files don't need to comply with these coding standards. -->
<exclude-pattern>*/library/Requests/IRI\.php$</exclude-pattern>
<exclude-pattern>*/tests/IRI\.php$</exclude-pattern>
<exclude-pattern>*/tests/IRITest\.php$</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/tests/coverage/</exclude-pattern>

Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
"Requests": "library/"
}
},
"autoload-dev": {
"psr-4": {
"Requests\\Tests\\": "tests/"
}
},
"scripts": {
"lint": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
Expand Down
22 changes: 2 additions & 20 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,8 @@
verbose="true"
>
<testsuites>
<testsuite name="Authentication">
<directory suffix=".php">tests/Auth</directory>
</testsuite>
<testsuite name="Transports">
<directory suffix=".php">tests/Transport</directory>
</testsuite>
<testsuite name="Proxies">
<directory suffix=".php">tests/Proxy</directory>
</testsuite>
<testsuite name="General">
<file>tests/ChunkedEncoding.php</file>
<file>tests/Cookies.php</file>
<file>tests/Encoding.php</file>
<file>tests/IDNAEncoder.php</file>
<file>tests/IRI.php</file>
<file>tests/Requests.php</file>
<file>tests/Response/Headers.php</file>
<file>tests/Session.php</file>
<file>tests/SSL.php</file>
<file>tests/Utility/FilteredIterator.php</file>
<testsuite name="RequestsTests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

Expand Down
8 changes: 7 additions & 1 deletion tests/Auth/Basic.php → tests/Auth/BasicTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php

class RequestsTest_Auth_Basic extends RequestsTest_TestCase {
namespace Requests\Tests\Auth;

use Requests;
use Requests\Tests\TestCase;
use Requests_Auth_Basic;

class BasicTest extends TestCase {
public static function transportProvider() {
return array(
array('Requests_Transport_fsockopen'),
Expand Down
14 changes: 10 additions & 4 deletions tests/ChunkedEncoding.php → tests/ChunkedEncodingTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php

class RequestsTest_ChunkedDecoding extends RequestsTest_TestCase {
namespace Requests\Tests;

use Requests;
use Requests\Tests\Mock\TransportMock;
use Requests\Tests\TestCase;

class ChunkedDecodingTest extends TestCase {
public static function chunkedProvider() {
return array(
array(
Expand Down Expand Up @@ -34,7 +40,7 @@ public static function chunkedProvider() {
* @dataProvider chunkedProvider
*/
public function testChunked($body, $expected) {
$transport = new RequestsTest_Mock_Transport();
$transport = new TransportMock();
$transport->body = $body;
$transport->chunked = true;

Expand Down Expand Up @@ -62,7 +68,7 @@ public static function notChunkedProvider() {
* @dataProvider notChunkedProvider
*/
public function testNotActuallyChunked($body) {
$transport = new RequestsTest_Mock_Transport();
$transport = new TransportMock();
$transport->body = $body;
$transport->chunked = true;

Expand All @@ -80,7 +86,7 @@ public function testNotActuallyChunked($body) {
* that they're lying to us
*/
public function testMixedChunkiness() {
$transport = new RequestsTest_Mock_Transport();
$transport = new TransportMock();
$transport->body = "02\r\nab\r\nNot actually chunked!";
$transport->chunked = true;

Expand Down
13 changes: 12 additions & 1 deletion tests/Cookies.php → tests/CookiesTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<?php

class RequestsTest_Cookies extends RequestsTest_TestCase {
namespace Requests\Tests;

use Requests;
use Requests\Tests\TestCase;
use Requests_Cookie;
use Requests_Cookie_Jar;
use Requests_Exception;
use Requests_IRI;
use Requests_Response_Headers;
use Requests_Utility_CaseInsensitiveDictionary;

class CookiesTest extends TestCase {
public function testBasicCookie() {
$cookie = new Requests_Cookie('requests-testcookie', 'testvalue');

Expand Down
7 changes: 6 additions & 1 deletion tests/Encoding.php → tests/EncodingTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

class RequestsTests_Encoding extends RequestsTest_TestCase {
namespace Requests\Tests;

use Requests;
use Requests\Tests\TestCase;

class EncodingTest extends TestCase {
protected static function mapData($type, $data) {
$real_data = array();
foreach ($data as $value) {
Expand Down
7 changes: 6 additions & 1 deletion tests/IDNAEncoder.php → tests/IDNAEncoderTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

class RequestsTest_IDNAEncoder extends RequestsTest_TestCase {
namespace Requests\Tests;

use Requests\Tests\TestCase;
use Requests_IDNAEncoder;

class IDNAEncoderTest extends TestCase {
public static function specExamples() {
return array(
array(
Expand Down
7 changes: 6 additions & 1 deletion tests/IRI.php → tests/IRITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
*
*/

class RequestsTest_IRI extends RequestsTest_TestCase
namespace Requests\Tests;

use Requests_IRI;
use Requests\Tests\TestCase;

class IRITest extends TestCase
{
public static function rfc3986_tests()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

class RequestsTest_Mock_RawTransport implements Requests_Transport {
namespace Requests\Tests\Mock;

use Requests_Transport;

class RawTransportMock implements Requests_Transport {
public $data = '';
public function request($url, $headers = array(), $data = array(), $options = array()) {
return $this->data;
Expand Down
6 changes: 5 additions & 1 deletion tests/Mock/Transport.php → tests/Mock/TransportMock.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

class RequestsTest_Mock_Transport implements Requests_Transport {
namespace Requests\Tests\Mock;

use Requests_Transport;

class TransportMock implements Requests_Transport {
public $code = 200;
public $chunked = false;
public $body = 'Test Body';
Expand Down
8 changes: 7 additions & 1 deletion tests/Proxy/HTTP.php → tests/Proxy/HTTPTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php

class RequestsTest_Proxy_HTTP extends RequestsTest_TestCase {
namespace Requests\Tests\Proxy;

use Requests;
use Requests\Tests\TestCase;
use Requests_Proxy_HTTP;

class HTTPTest extends TestCase {
protected function checkProxyAvailable($type = '') {
switch ($type) {
case 'auth':
Expand Down
26 changes: 17 additions & 9 deletions tests/Requests.php → tests/RequestsTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?php

class RequestsTest_Requests extends RequestsTest_TestCase {
namespace Requests\Tests;

use Requests;
use Requests\Tests\Mock\RawTransportMock;
use Requests\Tests\Mock\TransportMock;
use Requests\Tests\TestCase;
use Requests_Response_Headers;

class RequestsTest extends TestCase {

public function testInvalidProtocol() {
$this->expectException('Requests_Exception');
Expand All @@ -17,7 +25,7 @@ public function testDefaultTransport() {
* Standard response header parsing
*/
public function testHeaderParsing() {
$transport = new RequestsTest_Mock_RawTransport();
$transport = new RawTransportMock();
$transport->data =
"HTTP/1.0 200 OK\r\n" .
"Host: localhost\r\n" .
Expand Down Expand Up @@ -52,7 +60,7 @@ public function testHeaderParsing() {
}

public function testProtocolVersionParsing() {
$transport = new RequestsTest_Mock_RawTransport();
$transport = new RawTransportMock();
$transport->data =
"HTTP/1.0 200 OK\r\n" .
"Host: localhost\r\n\r\n";
Expand All @@ -66,7 +74,7 @@ public function testProtocolVersionParsing() {
}

public function testRawAccess() {
$transport = new RequestsTest_Mock_RawTransport();
$transport = new RawTransportMock();
$transport->data =
"HTTP/1.0 200 OK\r\n" .
"Host: localhost\r\n\r\n" .
Expand All @@ -83,7 +91,7 @@ public function testRawAccess() {
* Headers with only \n delimiting should be treated as if they're \r\n
*/
public function testHeaderOnlyLF() {
$transport = new RequestsTest_Mock_RawTransport();
$transport = new RawTransportMock();
$transport->data = "HTTP/1.0 200 OK\r\nTest: value\nAnother-Test: value\r\n\r\n";

$options = array(
Expand All @@ -101,7 +109,7 @@ public function testHeaderOnlyLF() {
* new issue, and update your server/proxy to support a proper protocol.
*/
public function testInvalidProtocolVersion() {
$transport = new RequestsTest_Mock_RawTransport();
$transport = new RawTransportMock();
$transport->data = "HTTP/0.9 200 OK\r\n\r\n<p>Test";

$options = array(
Expand All @@ -117,7 +125,7 @@ public function testInvalidProtocolVersion() {
* HTTP/0.9 also appears to use a single CRLF instead of two.
*/
public function testSingleCRLFSeparator() {
$transport = new RequestsTest_Mock_RawTransport();
$transport = new RawTransportMock();
$transport->data = "HTTP/0.9 200 OK\r\n<p>Test";

$options = array(
Expand All @@ -130,7 +138,7 @@ public function testSingleCRLFSeparator() {
}

public function testInvalidStatus() {
$transport = new RequestsTest_Mock_RawTransport();
$transport = new RawTransportMock();
$transport->data = "HTTP/1.1 OK\r\nTest: value\nAnother-Test: value\r\n\r\nTest";

$options = array(
Expand All @@ -143,7 +151,7 @@ public function testInvalidStatus() {
}

public function test30xWithoutLocation() {
$transport = new RequestsTest_Mock_Transport();
$transport = new TransportMock();
$transport->code = 302;

$options = array(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

class RequestsTest_Response_Headers extends RequestsTest_TestCase {
namespace Requests\Tests\Response;

use Requests\Tests\TestCase;
use Requests_Response_Headers;

class HeadersTest extends TestCase {
public function testArrayAccess() {
$headers = new Requests_Response_Headers();
$headers['Content-Type'] = 'text/plain';
Expand Down
7 changes: 6 additions & 1 deletion tests/SSL.php → tests/SSLTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

class RequestsTest_SSL extends RequestsTest_TestCase {
namespace Requests\Tests;

use Requests\Tests\TestCase;
use Requests_SSL;

class SSLTest extends TestCase {
public static function domainMatchProvider() {
return array(
array('example.com', 'example.com'),
Expand Down
7 changes: 6 additions & 1 deletion tests/Session.php → tests/SessionTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

class RequestsTest_Session extends RequestsTest_TestCase {
namespace Requests\Tests;

use Requests\Tests\TestCase;
use Requests_Session;

class SessionTest extends TestCase {
public function testURLResolution() {
$session = new Requests_Session(httpbin('/'));

Expand Down
6 changes: 4 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use Yoast\PHPUnitPolyfills\TestCases\TestCase;
namespace Requests\Tests;

class RequestsTest_TestCase extends TestCase {
use Yoast\PHPUnitPolyfills\TestCases\TestCase as Polyfill_TestCase;

class TestCase extends Polyfill_TestCase {

}
Loading