Skip to content
This repository
Browse code

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

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

0 comments on commit a5d26a5

Please sign in to comment.
Something went wrong with that request. Please try again.