Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'phpunit'

  • Loading branch information...
commit f41bddcc280c067dbcb85870fb70500e4517c63d 2 parents 5cbb561 + 5f43ecc
@dluc dluc authored
View
2  mashape/utils/arrayUtils.php
@@ -33,7 +33,7 @@ public static function existKey($key, $array) {
return false;
}
- public function isAssociative($array) {
+ public static function isAssociative($array) {
if ( !is_array($array) || empty($array) ) {
return false;
}
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
41 tests/configuration/restConfigurationTest.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * Test RESTConfiguration class
+ *
+ * @author Devis Lucato <devis@lucato.it>
+ */
+
+require_once(MASHAPE_LIBRAY_PATH . "/configuration/restConfiguration.php");
+
+class RESTConfigurationTest extends PHPUnit_Framework_TestCase
+{
+ protected $_instance;
+
+ public function setUp()
+ {
+ $this->_instance = new RESTConfiguration();
+ }
+
+ /**
+ * @covers RESTConfiguration::setMethods
+ * @covers RESTConfiguration::getMethods
+ */
+ public function test_setMethods_and_getMethods()
+ {
+ $value = __METHOD__ . time();
+ $this->_instance->setMethods($value);
+ $this->assertEquals($value, $this->_instance->getMethods());
+ }
+
+ /**
+ * @covers RESTConfiguration::setObjects
+ * @covers RESTConfiguration::getObjects
+ */
+ public function test_setObjects_and_getObjects()
+ {
+ $value = __METHOD__ . time();
+ $this->_instance->setObjects($value);
+ $this->assertEquals($value, $this->_instance->getObjects());
+ }
+}
View
86 tests/configuration/restMethodTest.php
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * Test RESTMethod class
+ *
+ * @author Devis Lucato <devis@lucato.it>
+ */
+
+require_once(MASHAPE_LIBRAY_PATH . "/configuration/restMethod.php");
+
+class RESTMethodTest extends PHPUnit_Framework_TestCase
+{
+ protected $_instance;
+
+ public function setUp()
+ {
+ $this->_instance = new RESTMethod();
+ }
+
+ /**
+ * @covers RESTMethod::setResult
+ * @covers RESTMethod::getResult
+ */
+ public function test_setResult_and_getResult()
+ {
+ $value = __METHOD__ . time();
+ $this->_instance->setResult($value);
+ $this->assertEquals($value, $this->_instance->getResult());
+ }
+
+ /**
+ * @covers RESTMethod::setObject
+ * @covers RESTMethod::getObject
+ */
+ public function test_setObject_and_getObject()
+ {
+ $value = __METHOD__ . time();
+ $this->_instance->setObject($value);
+ $this->assertEquals($value, $this->_instance->getObject());
+ }
+
+ /**
+ * @covers RESTMethod::setName
+ * @covers RESTMethod::getName
+ */
+ public function test_setName_and_getName()
+ {
+ $value = __METHOD__ . time();
+ $this->_instance->setName($value);
+ $this->assertEquals($value, $this->_instance->getName());
+ }
+
+ /**
+ * @covers RESTMethod::setHttp
+ * @covers RESTMethod::getHttp
+ */
+ public function test_setHttp_and_getHttp()
+ {
+ $value = __METHOD__ . time();
+ $this->_instance->setHttp($value);
+ $this->assertEquals($value, $this->_instance->getHttp());
+ }
+
+ /**
+ * @covers RESTMethod::setRoute
+ * @covers RESTMethod::getRoute
+ */
+ public function test_setRoute_and_getRoute()
+ {
+ $value = __METHOD__ . time();
+ $this->_instance->setRoute($value);
+ $this->assertEquals($value, $this->_instance->getRoute());
+ }
+
+ /**
+ * @covers RESTMethod::setArray
+ * @covers RESTMethod::isArray
+ */
+ public function test_setArray_and_isArray()
+ {
+ $this->markTestSkipped('isArray() implementation does not verify if the value is an array');
+ $value = __METHOD__ . time();
+ $this->_instance->setArray($value);
+ $this->assertEquals($value, $this->_instance->isArray());
+ }
+}
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
{
Please sign in to comment.
Something went wrong with that request. Please try again.