Skip to content

Commit

Permalink
Improve test setup
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
brianjmiller committed Dec 16, 2014
1 parent d5a4b93 commit 30c5ce0
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
tests/Config.php

# Third party libraries
phpdoc.xml
php.ini
Expand Down
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: php
php:
- 5.5
- 5.4
- hhvm
before_script: cp tests/Config.php.travis-ci tests/Config.php
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
1 change: 1 addition & 0 deletions phpunit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

date_default_timezone_set('UTC');

require_once('tests/Config.php');
require_once('tests/Constants.php');

require_once('src/LRSInterface.php');
Expand Down
10 changes: 10 additions & 0 deletions tests/Config.php.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$LRSs = [
[
'endpoint' => '',
'username' => '',
'password' => '',
'version' => '1.0.1'
]
];
10 changes: 10 additions & 0 deletions tests/Config.php.travis-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$LRSs = [
[
'endpoint' => 'https://cloud.scorm.com/tc/0CKX3A0SF2/sandbox/',
'username' => 'PjRb2iE9WsUSso_UYCE',
'password' => '3qoocGjKnfoYrtJhPrU',
'version' => '1.0.1'
]
];
23 changes: 17 additions & 6 deletions tests/RemoteLRSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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');
}
}

Expand Down

0 comments on commit 30c5ce0

Please sign in to comment.