Merge pull request #4152 from marc1706/ticket/14442

[ticket/14442] Use Goutte 2.0 for functional tests

* marc1706/ticket/14442:
  [ticket/14442] Use get_content() in functional test case
  [ticket/14442] Properly set plupload header
  [ticket/14442] Use get_content() in plupload functional tests
  [ticket/14442] Use Goutte 2.0 instead of outdated 1.0
This commit is contained in:
Tristan Darricau 2016-02-02 13:01:25 +01:00
commit 15e9367b5b
4 changed files with 228 additions and 35 deletions

View file

@ -47,8 +47,7 @@
"twig/twig": "1.*" "twig/twig": "1.*"
}, },
"require-dev": { "require-dev": {
"fabpot/goutte": "1.0.*", "fabpot/goutte": "~2.0",
"guzzle/guzzle": "3.9.*",
"phing/phing": "2.4.*", "phing/phing": "2.4.*",
"phpunit/dbunit": "1.3.*", "phpunit/dbunit": "1.3.*",
"phpunit/phpunit": "4.1.*", "phpunit/phpunit": "4.1.*",

238
phpBB/composer.lock generated
View file

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "b7cd29af73c4846ea28c2c9fbee1067b", "hash": "f76b5185058599cad6a87ef7c8c35fbf",
"content-hash": "321f60039c3712a7e8b351aee8f9aca1", "content-hash": "b89d3c18f8d9b3c4dc476f92030a83a1",
"packages": [ "packages": [
{ {
"name": "bantu/ini-get-wrapper", "name": "bantu/ini-get-wrapper",
@ -1356,41 +1356,34 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "fabpot/goutte", "name": "fabpot/goutte",
"version": "v1.0.7", "version": "v2.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/FriendsOfPHP/Goutte.git", "url": "https://github.com/FriendsOfPHP/Goutte.git",
"reference": "794b196e76bdd37b5155cdecbad311f0a3b07625" "reference": "0ad3ee6dc2d0aaa832a80041a1e09bf394e99802"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/794b196e76bdd37b5155cdecbad311f0a3b07625", "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/0ad3ee6dc2d0aaa832a80041a1e09bf394e99802",
"reference": "794b196e76bdd37b5155cdecbad311f0a3b07625", "reference": "0ad3ee6dc2d0aaa832a80041a1e09bf394e99802",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-curl": "*", "guzzlehttp/guzzle": ">=4,<6",
"guzzle/http": "~3.1", "php": ">=5.4.0",
"php": ">=5.3.0",
"symfony/browser-kit": "~2.1", "symfony/browser-kit": "~2.1",
"symfony/css-selector": "~2.1", "symfony/css-selector": "~2.1",
"symfony/dom-crawler": "~2.1", "symfony/dom-crawler": "~2.1"
"symfony/finder": "~2.1",
"symfony/process": "~2.1"
},
"require-dev": {
"guzzle/plugin-history": "~3.1",
"guzzle/plugin-mock": "~3.1"
}, },
"type": "application", "type": "application",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0-dev" "dev-master": "2.0-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Goutte": "." "Goutte\\": "Goutte"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -1404,11 +1397,11 @@
} }
], ],
"description": "A simple PHP Web Scraper", "description": "A simple PHP Web Scraper",
"homepage": "https://github.com/fabpot/Goutte", "homepage": "https://github.com/FriendsOfPHP/Goutte",
"keywords": [ "keywords": [
"scraper" "scraper"
], ],
"time": "2014-10-09 15:52:51" "time": "2015-05-05 21:14:57"
}, },
{ {
"name": "guzzle/guzzle", "name": "guzzle/guzzle",
@ -1505,6 +1498,165 @@
], ],
"time": "2015-03-18 18:23:50" "time": "2015-03-18 18:23:50"
}, },
{
"name": "guzzlehttp/guzzle",
"version": "5.3.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "f3c8c22471cb55475105c14769644a49c3262b93"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/f3c8c22471cb55475105c14769644a49c3262b93",
"reference": "f3c8c22471cb55475105c14769644a49c3262b93",
"shasum": ""
},
"require": {
"guzzlehttp/ringphp": "^1.1",
"php": ">=5.4.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.0",
"psr/log": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
],
"time": "2015-05-20 03:47:55"
},
{
"name": "guzzlehttp/ringphp",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/RingPHP.git",
"reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
"reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
"shasum": ""
},
"require": {
"guzzlehttp/streams": "~3.0",
"php": ">=5.4.0",
"react/promise": "~2.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "~4.0"
},
"suggest": {
"ext-curl": "Guzzle will use specific adapters if cURL is present"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Ring\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
"time": "2015-05-20 03:37:09"
},
{
"name": "guzzlehttp/streams",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/streams.git",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Stream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple abstraction over streams of data",
"homepage": "http://guzzlephp.org/",
"keywords": [
"Guzzle",
"stream"
],
"time": "2014-10-12 19:18:40"
},
{ {
"name": "michelf/php-markdown", "name": "michelf/php-markdown",
"version": "1.6.0", "version": "1.6.0",
@ -2129,6 +2281,50 @@
], ],
"time": "2013-03-08 08:21:40" "time": "2013-03-08 08:21:40"
}, },
{
"name": "react/promise",
"version": "v2.2.1",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "3b6fca09c7d56321057fa8867c8dbe1abf648627"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/3b6fca09c7d56321057fa8867c8dbe1abf648627",
"reference": "3b6fca09c7d56321057fa8867c8dbe1abf648627",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"React\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com"
}
],
"description": "A lightweight implementation of CommonJS Promises/A for PHP",
"time": "2015-07-03 13:48:55"
},
{ {
"name": "sami/sami", "name": "sami/sami",
"version": "v1.4.1", "version": "v1.4.1",

View file

@ -107,11 +107,11 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
if ($i < self::CHUNKS - 1) if ($i < self::CHUNKS - 1)
{ {
$this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::$client->getResponse()->getContent()); $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::get_content());
} }
else else
{ {
$response = json_decode(self::$client->getResponse()->getContent(), true); $response = json_decode(self::get_content(), true);
$this->assertEquals('valid.jpg', $response['data'][0]['real_filename']); $this->assertEquals('valid.jpg', $response['data'][0]['real_filename']);
} }
@ -134,7 +134,8 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
'error' => UPLOAD_ERR_OK, 'error' => UPLOAD_ERR_OK,
); );
$crawler = self::$client->request( self::$client->setServerParameter('HTTP_X_PHPBB_USING_PLUPLOAD', '1');
self::$client->request(
'POST', 'POST',
$url . '&sid=' . $this->sid, $url . '&sid=' . $this->sid,
array( array(
@ -144,11 +145,10 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
'real_filename' => 'valid.jpg', 'real_filename' => 'valid.jpg',
'add_file' => $this->lang('ADD_FILE'), 'add_file' => $this->lang('ADD_FILE'),
), ),
array('fileupload' => $file), array('fileupload' => $file)
array('X-PHPBB-USING-PLUPLOAD' => '1')
); );
$response = json_decode(self::$client->getResponse()->getContent(), true); $response = json_decode(self::get_content(), true);
$this->assertEquals('valid.jpg', $response['data'][0]['real_filename']); $this->assertEquals('valid.jpg', $response['data'][0]['real_filename']);
} }
} }

View file

@ -16,6 +16,7 @@ require_once __DIR__ . '/mock/phpbb_mock_null_installer_task.php';
class phpbb_functional_test_case extends phpbb_test_case class phpbb_functional_test_case extends phpbb_test_case
{ {
/** @var \Goutte\Client */
static protected $client; static protected $client;
static protected $cookieJar; static protected $cookieJar;
static protected $root_url; static protected $root_url;
@ -81,9 +82,6 @@ class phpbb_functional_test_case extends phpbb_test_case
self::$cookieJar = new CookieJar; self::$cookieJar = new CookieJar;
self::$client = new Goutte\Client(array(), null, self::$cookieJar); self::$client = new Goutte\Client(array(), null, self::$cookieJar);
// Reset the curl handle because it is 0 at this point and not a valid
// resource
self::$client->getClient()->getCurlMulti()->reset(true);
// Clear the language array so that things // Clear the language array so that things
// that were added in other tests are gone // that were added in other tests are gone
@ -169,7 +167,7 @@ class phpbb_functional_test_case extends phpbb_test_case
*/ */
static public function get_content() static public function get_content()
{ {
return self::$client->getResponse()->getContent(); return (string) self::$client->getResponse()->getContent();
} }
// bootstrap, called after board is set up // bootstrap, called after board is set up
@ -843,7 +841,7 @@ class phpbb_functional_test_case extends phpbb_test_case
static public function assert_response_html($status_code = 200) static public function assert_response_html($status_code = 200)
{ {
// Any output before the doc type means there was an error // Any output before the doc type means there was an error
$content = self::$client->getResponse()->getContent(); $content = self::get_content();
self::assertNotContains('[phpBB Debug]', $content); self::assertNotContains('[phpBB Debug]', $content);
self::assertStringStartsWith('<!DOCTYPE', trim($content), 'Output found before DOCTYPE specification.'); self::assertStringStartsWith('<!DOCTYPE', trim($content), 'Output found before DOCTYPE specification.');
@ -864,7 +862,7 @@ class phpbb_functional_test_case extends phpbb_test_case
static public function assert_response_xml($status_code = 200) static public function assert_response_xml($status_code = 200)
{ {
// Any output before the xml opening means there was an error // Any output before the xml opening means there was an error
$content = self::$client->getResponse()->getContent(); $content = self::get_content();
self::assertNotContains('[phpBB Debug]', $content); self::assertNotContains('[phpBB Debug]', $content);
self::assertStringStartsWith('<?xml', trim($content), 'Output found before XML specification.'); self::assertStringStartsWith('<?xml', trim($content), 'Output found before XML specification.');