A simple php RESTful api wrapper.
Based on heavily (okay, practically copied) on https://github.com/ktamas77/firebase-php. His code is simply amazing! I helped him write the tests and the test stub. I reached out to him to fork and abstract the code but I never received a response.
https://github.com/ktamas77/firebase-php @author Tamas Kalman [email protected]
A RESTful API Wrapper Stub has been created to allow for integration with phpunit without actually interacting with an API.
$restful = new RESTful('https://<yourcompany>.com/<path>/<to>/<resource>', '<token>');
$restful->set($path, $value);
}
All the unit tests are found in the "/tests" directory. Due to the usage of an interface, the tests must run in isolation.
The RESTfulStub tests can be executed by running the following command:
$ phpunit --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml --testsuite restful
$ phpunit --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml --group <groupName>
$ phpunit --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests/unit/<file_name.php>
<?php
require_once '<path>/lib/RESTfulInterface.php';
require_once '<path>/lib/RESTfulStub.php';
class MyClass extends PHPUnit_Framework_TestCase
{
public function testSetRESTfulValue() {
$myClass = new MyClass();
$restfulStub = new RESTfulStub($uri, $token);
$myClass->setRESTFulValue($path, $value);
}
}
?>