Permalink
Browse files

Added testing bootstrap and phpunit configuration (command line and CI)

Load classes using test environment configuration
  • Loading branch information...
1 parent 6697187 commit a5d26a5f186a6aa5c29b2484b588f03ba583bca6 @dluc dluc committed Mar 6, 2011
View
10 tests/bootstrap.php
@@ -0,0 +1,10 @@
+<?php
+
+/**
+ * Initialise testing environment
+ *
+ * @author Devis Lucato <devis@lucato.it>
+ */
+
+define('CONFIGURATION_FILEPATH', dirname(dirname(__FILE__)) . '/api.xml');
+define('MASHAPE_LIBRAY_PATH', dirname(dirname(__FILE__)) . '/mashape');
View
3 tests/configuration/restConfigurationLoaderTest.php
@@ -24,8 +24,7 @@
*
*/
-define("CONFIGURATION_FILEPATH", "./api.xml");
-require_once(dirname(__FILE__) . "/../../mashape/configuration/restConfigurationLoader.php");
+require_once(MASHAPE_LIBRAY_PATH . "/configuration/restConfigurationLoader.php");
class RESTConfigurationLoaderTest extends PHPUnit_Framework_TestCase
{
View
2 tests/json/jsonImplTest.php
@@ -24,7 +24,7 @@
*
*/
-require_once(dirname(__FILE__) . "/../../mashape/json/jsonImpl.php");
+require_once(MASHAPE_LIBRAY_PATH . "/json/jsonImpl.php");
class JsonImplTest extends PHPUnit_Framework_TestCase
{
View
2 tests/json/jsonUtilsTest.php
@@ -24,7 +24,7 @@
*
*/
-require_once(dirname(__FILE__) . "/../../mashape/json/jsonUtils.php");
+require_once(MASHAPE_LIBRAY_PATH . "/json/jsonUtils.php");
class JsonUtilsTest extends PHPUnit_Framework_TestCase
{
View
6 tests/methods/call/helpers/callHelperTest.php
@@ -24,9 +24,9 @@
*
*/
-require_once(dirname(__FILE__) . "/../../../../mashape/configuration/restMethod.php");
-require_once(dirname(__FILE__) . "/../../../../mashape/mashape.php");
-require_once(dirname(__FILE__) . "/../../../../mashape/methods/call/helpers/callHelper.php");
+require_once(MASHAPE_LIBRAY_PATH . "/configuration/restMethod.php");
+require_once(MASHAPE_LIBRAY_PATH . "/mashape.php");
+require_once(MASHAPE_LIBRAY_PATH . "/methods/call/helpers/callHelper.php");
define("SERVER_KEY", "serverkey");
View
4 tests/methods/discover/discoverTest.php
@@ -24,8 +24,8 @@
*
*/
-require_once(dirname(__FILE__) . "/../../../mashape/mashape.php");
-require_once(dirname(__FILE__) . "/../../../mashape/methods/discover/discover.php");
+require_once(MASHAPE_LIBRAY_PATH . "/mashape.php");
+require_once(MASHAPE_LIBRAY_PATH . "/methods/discover/discover.php");
class DiscoverTest extends PHPUnit_Framework_TestCase
{
View
8 tests/net/httpUtilsTest.php
@@ -24,10 +24,16 @@
*
*/
-require_once(dirname(__FILE__) . "/../../mashape/net/httpUtils.php");
+require_once(MASHAPE_LIBRAY_PATH . "/net/httpUtils.php");
class HttpUtilsTest extends PHPUnit_Framework_TestCase
{
+ /**
+ * @TODO: This is an integration test with www.mashape.com
+ * This test could fail if the site is unreachable (maintenance, dns, proxy, firewall etc.)
+ * The external resource should be mocked
+ * ~ dluc
+ */
function testMakeHttpRequest() {
$response = HttpUtils::makeHttpRequest("http://www.mashape.com");
$this->assertFalse(empty($response));
View
16 tests/phpunit.CI.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit
+ bootstrap="./bootstrap.php"
+ colors="false"
+ backupGlobals="false"
+ backupStaticAttributes="false">
+
+ <testsuite name="Mashape Test Suite">
+ <directory>./configuration</directory>
+ <directory>./json</directory>
+ <directory>./methods</directory>
+ <directory>./net</directory>
+ <directory>./utils</directory>
+ </testsuite>
+
+</phpunit>
View
16 tests/phpunit.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit
+ bootstrap="./bootstrap.php"
+ colors="true"
+ backupGlobals="false"
+ backupStaticAttributes="false">
+
+ <testsuite name="Mashape Test Suite">
+ <directory>./configuration</directory>
+ <directory>./json</directory>
+ <directory>./methods</directory>
+ <directory>./net</directory>
+ <directory>./utils</directory>
+ </testsuite>
+
+</phpunit>
View
2 tests/utils/arrayUtilsTest.php
@@ -24,7 +24,7 @@
*
*/
-require_once(dirname(__FILE__) . "/../../mashape/utils/arrayUtils.php");
+require_once(MASHAPE_LIBRAY_PATH . "/utils/arrayUtils.php");
class ArrayUtilsTest extends PHPUnit_Framework_TestCase
{

0 comments on commit a5d26a5

Please sign in to comment.