Skip to content

Commit

Permalink
Merge pull request #20 from brianjmiller/master
Browse files Browse the repository at this point in the history
Improve test setup
  • Loading branch information
bscSCORM committed Dec 16, 2014
2 parents d5a4b93 + 39a307a commit 9f27ea5
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 8 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
8 changes: 6 additions & 2 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 All @@ -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

Expand All @@ -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
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 9f27ea5

Please sign in to comment.