forked from joomla/joomla-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport JHttp tests from Platform repo, add Apache config to repo to…
… enable future testing
- Loading branch information
Showing
9 changed files
with
659 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<VirtualHost *:80> | ||
DocumentRoot %TRAVIS_BUILD_DIR% | ||
|
||
<Directory "%TRAVIS_BUILD_DIR%"> | ||
Options FollowSymLinks MultiViews ExecCGI | ||
AllowOverride All | ||
Order deny,allow | ||
Allow from all | ||
</Directory> | ||
|
||
# Wire up Apache to use Travis CI's php-fpm. | ||
<IfModule mod_fastcgi.c> | ||
AddHandler php5-fcgi .php | ||
Action php5-fcgi /php5-fcgi | ||
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi | ||
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization | ||
</IfModule> | ||
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
sudo apt-get install apache2 libapache2-mod-fastcgi | ||
# enable php-fpm | ||
sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf | ||
sudo a2enmod rewrite actions fastcgi alias | ||
echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini | ||
~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm | ||
# configure apache virtual hosts | ||
sudo cp -f build/travis/apache2/php-apache /etc/apache2/sites-available/default | ||
sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default | ||
sudo service apache2 restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* @package Joomla.UnitTest | ||
* @subpackage Http | ||
* | ||
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
/** | ||
* This is a stub file to aid in testing the JHttp transports. The idea is to echo | ||
* back data that is sent from the transports so that assertions can be made and | ||
* it can be ensured that proper data is being sent in the request. | ||
* | ||
* This file must be placed on a webserver in a location that can be accessed | ||
* by the system that the test is running. | ||
*/ | ||
|
||
$response = new stdClass; | ||
|
||
$response->method = getVar($_SERVER, 'REQUEST_METHOD'); | ||
$response->http_user_agent = getVar($_SERVER, 'HTTP_USER_AGENT'); | ||
$response->request_uri = getVar($_SERVER, 'REQUEST_URI'); | ||
$response->query_string = getVar($_SERVER, 'QUERY_STRING'); | ||
$response->http_accept = getVar($_SERVER, 'HTTP_ACCEPT'); | ||
$response->http_accept_charset = getVar($_SERVER, 'HTTP_ACCEPT_CHARSET'); | ||
$response->http_accept_encoding = getVar($_SERVER, 'HTTP_ACCEPT_ENCODING'); | ||
|
||
$response->http_referer = getVar($_SERVER, 'HTTP_REFERER'); | ||
|
||
$response->get = $_GET; | ||
$response->post = $_POST; | ||
$response->files = $_FILES; | ||
$response->cookies = $_COOKIE; | ||
|
||
echo json_encode($response); | ||
|
||
|
||
/** | ||
* Retrieves a value from an array, returning a default value if not present | ||
* | ||
* @param array $array The array from which to retrieve a value. | ||
* @param string $key The value to retrieve. | ||
* @param mixed $default The value to return if the key isn't present. | ||
* | ||
* @return mixed | ||
* | ||
* @since 3.4 | ||
*/ | ||
function getVar($array, $key, $default = '') | ||
{ | ||
return isset($array[$key]) ? $array[$key] : $default; | ||
} |
88 changes: 88 additions & 0 deletions
88
tests/unit/suites/libraries/joomla/http/JHttpFactoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* @package Joomla.UnitTest | ||
* @subpackage Http | ||
* | ||
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
/** | ||
* Test class for JHttpFactory. | ||
* | ||
* @package Joomla.UnitTest | ||
* @subpackage Http | ||
* @since 3.4 | ||
*/ | ||
class JHttpFactoryTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Tests the getHttp method. | ||
* | ||
* @return void | ||
* | ||
* @since 3.4 | ||
*/ | ||
public function testGetHttp() | ||
{ | ||
$this->assertInstanceOf( | ||
'JHttp', | ||
JHttpFactory::getHttp() | ||
); | ||
} | ||
|
||
/** | ||
* Tests the getHttp method for an exception. | ||
* | ||
* @return void | ||
* | ||
* @since 3.4 | ||
* @expectedException RuntimeException | ||
*/ | ||
public function testGetHttpException() | ||
{ | ||
$this->markTestSkipped('Cannot test correctly because a class_exists check is not performed.'); | ||
|
||
JHttpFactory::getHttp(new \Joomla\Registry\Registry, array('fopen')); | ||
} | ||
|
||
/** | ||
* Tests the getAvailableDriver method. | ||
* | ||
* @return void | ||
* | ||
* @since 3.4 | ||
*/ | ||
public function testGetAvailableDriver() | ||
{ | ||
$this->assertFalse( | ||
JHttpFactory::getAvailableDriver(new \Joomla\Registry\Registry, array()), | ||
'Passing an empty array should return false due to there being no adapters to test' | ||
); | ||
|
||
$this->markTestIncomplete('Cannot test next assertion correctly because a class_exists check is not performed.'); | ||
|
||
$this->assertFalse( | ||
JHttpFactory::getAvailableDriver(new \Joomla\Registry\Registry, array('fopen')), | ||
'A false should be returned if a class is not present or supported' | ||
); | ||
} | ||
|
||
/** | ||
* Tests the getHttpTransports method. | ||
* | ||
* @return void | ||
* | ||
* @since 3.4 | ||
*/ | ||
public function testGetHttpTransports() | ||
{ | ||
$transports = JHttpFactory::getHttpTransports(); | ||
|
||
$this->assertEquals( | ||
'curl', | ||
$transports[0], | ||
'CURL should be the first transport returned.' | ||
); | ||
} | ||
} |
Oops, something went wrong.