From 30c5ce0396b33ee101ced5ef783202fe25cd0f13 Mon Sep 17 00:00:00 2001 From: "Brian J. Miller" Date: Tue, 16 Dec 2014 09:13:50 -0600 Subject: [PATCH 1/2] Improve test setup * Switch to use a configuration file for specifying LRS details * Setup a Travis CI config file and test configuration file * Fix 'more' URL test when not enough statements in the LRS --- .gitignore | 2 ++ .travis.yml | 6 ++++++ README.md | 2 ++ phpunit.php | 1 + tests/Config.php.template | 10 ++++++++++ tests/Config.php.travis-ci | 10 ++++++++++ tests/RemoteLRSTest.php | 23 +++++++++++++++++------ 7 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 .travis.yml create mode 100644 tests/Config.php.template create mode 100644 tests/Config.php.travis-ci 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..f878a96 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/ 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'); } } From 39a307a9de35a714140480b52481aae0e7c008ed Mon Sep 17 00:00:00 2001 From: "Brian J. Miller" Date: Tue, 16 Dec 2014 09:21:30 -0600 Subject: [PATCH 2/2] README updates --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f878a96..ba803c6 100644 --- a/README.md +++ b/README.md @@ -10,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 @@ -28,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