Skip to content

Commit 30c5ce0

Browse files
committed
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
1 parent d5a4b93 commit 30c5ce0

7 files changed

Lines changed: 48 additions & 6 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
tests/Config.php
2+
13
# Third party libraries
24
phpdoc.xml
35
php.ini

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: php
2+
php:
3+
- 5.5
4+
- 5.4
5+
- hhvm
6+
before_script: cp tests/Config.php.travis-ci tests/Config.php

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
A PHP library for implementing Tin Can API.
22

3+
[![Build Status](https://travis-ci.org/RusticiSoftware/TinCanPHP.png)](https://travis-ci.org/RusticiSoftware/TinCanPHP)
4+
35
For hosted API documentation, basic usage instructions, supported version listing, etc. visit the main project website at:
46

57
http://rusticisoftware.github.io/TinCanPHP/

phpunit.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
date_default_timezone_set('UTC');
44

5+
require_once('tests/Config.php');
56
require_once('tests/Constants.php');
67

78
require_once('src/LRSInterface.php');

tests/Config.php.template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
$LRSs = [
4+
[
5+
'endpoint' => '',
6+
'username' => '',
7+
'password' => '',
8+
'version' => '1.0.1'
9+
]
10+
];

tests/Config.php.travis-ci

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
$LRSs = [
4+
[
5+
'endpoint' => 'https://cloud.scorm.com/tc/0CKX3A0SF2/sandbox/',
6+
'username' => 'PjRb2iE9WsUSso_UYCE',
7+
'password' => '3qoocGjKnfoYrtJhPrU',
8+
'version' => '1.0.1'
9+
]
10+
];

tests/RemoteLRSTest.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@
1818
use TinCan\RemoteLRS;
1919

2020
class RemoteLRSTest extends PHPUnit_Framework_TestCase {
21-
static private $endpoint = 'http://cloud.scorm.com/tc/3HYPTQLAI9/sandbox';
22-
static private $version = '1.0.1';
23-
static private $username = '';
24-
static private $password = '';
21+
static private $endpoint;
22+
static private $version;
23+
static private $username;
24+
static private $password;
25+
26+
public static function setUpBeforeClass() {
27+
self::$endpoint = $GLOBALS['LRSs'][0]['endpoint'];
28+
self::$version = $GLOBALS['LRSs'][0]['version'];
29+
self::$username = $GLOBALS['LRSs'][0]['username'];
30+
self::$password = $GLOBALS['LRSs'][0]['password'];
31+
}
2532

2633
public function testInstantiation() {
2734
$lrs = new RemoteLRS();
@@ -98,16 +105,20 @@ public function testQueryStatements() {
98105

99106
public function testMoreStatements() {
100107
$lrs = new RemoteLRS(self::$endpoint, self::$version, self::$username, self::$password);
101-
$queryResponse = $lrs->queryStatements(['limit' => 4]);
108+
$queryResponse = $lrs->queryStatements(['limit' => 1]);
102109

103110
if ($queryResponse->success) {
111+
if (! $queryResponse->content->getMore()) {
112+
$this->markTestSkipped('No more property in StatementsResult (not enough statements in endpoint?)');
113+
}
114+
104115
$response = $lrs->moreStatements($queryResponse->content);
105116

106117
$this->assertInstanceOf('TinCan\LRSResponse', $response);
107118
$this->assertInstanceOf('TinCan\StatementsResult', $response->content);
108119
}
109120
else {
110-
// TODO: skipped? throw?
121+
$this->markTestSkipped('Query to get "more" URL failed');
111122
}
112123
}
113124

0 commit comments

Comments
 (0)