diff --git a/.gitignore b/.gitignore index ace854a..fef1fa2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +tests/Config.php + # Third party libraries phpdoc.xml php.ini diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..26ae676 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: php +php: + - 5.5 + - 5.4 + - hhvm +before_script: cp tests/Config.php.travis-ci tests/Config.php diff --git a/README.md b/README.md index 7d5194a..ba803c6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ A PHP library for implementing Tin Can API. +[![Build Status](https://travis-ci.org/RusticiSoftware/TinCanPHP.png)](https://travis-ci.org/RusticiSoftware/TinCanPHP) + For hosted API documentation, basic usage instructions, supported version listing, etc. visit the main project website at: http://rusticisoftware.github.io/TinCanPHP/ @@ -8,7 +10,7 @@ For more information about the Tin Can API visit: http://tincanapi.com/ -Requires PHP 5.4 or later. +Requires PHP 5.4 or later. (If you must run something older you should look at the PHP_5_2 branch.) ### Installation @@ -26,7 +28,9 @@ require 'vendor/autoload.php'; ### Testing -Tests are implemented using PHPUnit. +Tests are implemented using PHPUnit. Configure the LRS endpoint and credentials by copying the `tests/Config.php.template` to `tests/Config.php` then setting the values for your LRS. + +Once configured run: ``` phpunit tests diff --git a/phpunit.php b/phpunit.php index b38f794..3684097 100644 --- a/phpunit.php +++ b/phpunit.php @@ -2,6 +2,7 @@ date_default_timezone_set('UTC'); +require_once('tests/Config.php'); require_once('tests/Constants.php'); require_once('src/LRSInterface.php'); diff --git a/tests/Config.php.template b/tests/Config.php.template new file mode 100644 index 0000000..0e999b1 --- /dev/null +++ b/tests/Config.php.template @@ -0,0 +1,10 @@ + '', + 'username' => '', + 'password' => '', + 'version' => '1.0.1' + ] +]; diff --git a/tests/Config.php.travis-ci b/tests/Config.php.travis-ci new file mode 100644 index 0000000..b76e6dd --- /dev/null +++ b/tests/Config.php.travis-ci @@ -0,0 +1,10 @@ + 'https://cloud.scorm.com/tc/0CKX3A0SF2/sandbox/', + 'username' => 'PjRb2iE9WsUSso_UYCE', + 'password' => '3qoocGjKnfoYrtJhPrU', + 'version' => '1.0.1' + ] +]; diff --git a/tests/RemoteLRSTest.php b/tests/RemoteLRSTest.php index d03a53c..6875317 100644 --- a/tests/RemoteLRSTest.php +++ b/tests/RemoteLRSTest.php @@ -18,10 +18,17 @@ use TinCan\RemoteLRS; class RemoteLRSTest extends PHPUnit_Framework_TestCase { - static private $endpoint = 'http://cloud.scorm.com/tc/3HYPTQLAI9/sandbox'; - static private $version = '1.0.1'; - static private $username = ''; - static private $password = ''; + static private $endpoint; + static private $version; + static private $username; + static private $password; + + public static function setUpBeforeClass() { + self::$endpoint = $GLOBALS['LRSs'][0]['endpoint']; + self::$version = $GLOBALS['LRSs'][0]['version']; + self::$username = $GLOBALS['LRSs'][0]['username']; + self::$password = $GLOBALS['LRSs'][0]['password']; + } public function testInstantiation() { $lrs = new RemoteLRS(); @@ -98,16 +105,20 @@ public function testQueryStatements() { public function testMoreStatements() { $lrs = new RemoteLRS(self::$endpoint, self::$version, self::$username, self::$password); - $queryResponse = $lrs->queryStatements(['limit' => 4]); + $queryResponse = $lrs->queryStatements(['limit' => 1]); if ($queryResponse->success) { + if (! $queryResponse->content->getMore()) { + $this->markTestSkipped('No more property in StatementsResult (not enough statements in endpoint?)'); + } + $response = $lrs->moreStatements($queryResponse->content); $this->assertInstanceOf('TinCan\LRSResponse', $response); $this->assertInstanceOf('TinCan\StatementsResult', $response->content); } else { - // TODO: skipped? throw? + $this->markTestSkipped('Query to get "more" URL failed'); } }