diff --git a/.travis.yml b/.travis.yml index 873079f..4bc627b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ php: - 5.6 - 5.5 - hhvm +matrix: + allow_failures: + - php: hhvm before_script: - cp tests/config/config.travis-ci.php tests/config/config.php - composer install --dev diff --git a/README.md b/README.md index caa7c3b..a08f064 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,23 @@ For more information about the Experience API visit: http://experienceapi.com/ +### Requirements + Requires PHP 5.5 or later. (If you must run something older you should look at the 0.x release series or the PHP_5_2 branch.) +Compatible with HHVM 3.4.0 through 3.14.5. +HHVM 3.15.0 introduced a bug that causes ```RemoteLRS->sendRequest()``` to fail. The +[issue](https://github.com/facebook/hhvm/issues/7684) has been reported and fixed in +[PR #8048](https://github.com/facebook/hhvm/pull/8048). Until the fix is released, edit ```RemoteLRS->sendRequest()```, +search for this line: +```php +$context = stream_context_create(array( 'http' => $http )); +``` +and precede it with this line. +```php +$http['header'] = implode("\r\n", $http['header']); +``` + ### Installation TinCanPHP is available via [Composer](http://getcomposer.org). diff --git a/composer.json b/composer.json index 7786424..7f1c0c8 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ }, "require-dev": { "phpdocumentor/phpdocumentor": "2.*", - "phpunit/phpunit": "@stable" + "phpunit/phpunit": "4.8.* || 5.7.*" }, "autoload": { "psr-4": { diff --git a/tests/AboutTest.php b/tests/AboutTest.php index 8b7b43e..7367022 100644 --- a/tests/AboutTest.php +++ b/tests/AboutTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\About; -class AboutTest extends \PHPUnit_Framework_TestCase { +class AboutTest extends TestCase { const VERSION_1 = '1.0.0'; public function testInstantiation() { diff --git a/tests/ActivityDefinitionTest.php b/tests/ActivityDefinitionTest.php index 2427b7e..b1b1721 100644 --- a/tests/ActivityDefinitionTest.php +++ b/tests/ActivityDefinitionTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\ActivityDefinition; -class ActivityDefinitionTest extends \PHPUnit_Framework_TestCase { +class ActivityDefinitionTest extends TestCase { const NAME = 'testName'; private $emptyProperties = array( diff --git a/tests/ActivityProfileTest.php b/tests/ActivityProfileTest.php index dbe0f98..83e02c5 100644 --- a/tests/ActivityProfileTest.php +++ b/tests/ActivityProfileTest.php @@ -17,10 +17,11 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\ActivityProfile; use TinCan\Activity; -class ActivityProfileTest extends \PHPUnit_Framework_TestCase { +class ActivityProfileTest extends TestCase { public function testSetActivity() { $profile = new ActivityProfile(); $profile->setActivity(['id' => COMMON_ACTIVITY_ID]); diff --git a/tests/ActivityTest.php b/tests/ActivityTest.php index 44f3fe7..ad164f5 100644 --- a/tests/ActivityTest.php +++ b/tests/ActivityTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Activity; -class ActivityTest extends \PHPUnit_Framework_TestCase { +class ActivityTest extends TestCase { use TestCompareWithSignatureTrait; static private $DEFINITION; diff --git a/tests/AgentAccountTest.php b/tests/AgentAccountTest.php index f863a73..15f7993 100644 --- a/tests/AgentAccountTest.php +++ b/tests/AgentAccountTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\AgentAccount; -class AgentAccountTest extends \PHPUnit_Framework_TestCase { +class AgentAccountTest extends TestCase { use TestCompareWithSignatureTrait; const HOMEPAGE = 'http://tincanapi.com'; diff --git a/tests/AgentProfileTest.php b/tests/AgentProfileTest.php index 3881aee..4a63b7f 100644 --- a/tests/AgentProfileTest.php +++ b/tests/AgentProfileTest.php @@ -17,11 +17,12 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\AgentProfile; use TinCan\Agent; use TinCan\Group; -class AgentProfileTest extends \PHPUnit_Framework_TestCase { +class AgentProfileTest extends TestCase { public function testSetAgent() { $profile = new AgentProfile(); $profile->setAgent(['mbox' => COMMON_MBOX]); diff --git a/tests/AgentTest.php b/tests/AgentTest.php index a027de8..16a5433 100644 --- a/tests/AgentTest.php +++ b/tests/AgentTest.php @@ -17,10 +17,11 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Agent; use TinCan\AgentAccount; -class AgentTest extends \PHPUnit_Framework_TestCase { +class AgentTest extends TestCase { use TestCompareWithSignatureTrait; public function testInstantiation() { diff --git a/tests/AsVersionTraitTest.php b/tests/AsVersionTraitTest.php index 4c8b8d3..a73bde3 100644 --- a/tests/AsVersionTraitTest.php +++ b/tests/AsVersionTraitTest.php @@ -17,7 +17,9 @@ namespace TinCanTest; -class AsVersionTraitTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class AsVersionTraitTest extends TestCase { public function testTraitExists() { $this->assertTrue(trait_exists('TinCan\AsVersionTrait')); diff --git a/tests/AttachmentTest.php b/tests/AttachmentTest.php index 5ce76d8..91fffd3 100644 --- a/tests/AttachmentTest.php +++ b/tests/AttachmentTest.php @@ -17,10 +17,11 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Attachment; use TinCan\Version; -class AttachmentTest extends \PHPUnit_Framework_TestCase { +class AttachmentTest extends TestCase { use TestCompareWithSignatureTrait; const USAGE_TYPE = 'http://id.tincanapi.com/attachment/supporting_media'; diff --git a/tests/ContextActivitiesTest.php b/tests/ContextActivitiesTest.php index f101205..82d64a0 100644 --- a/tests/ContextActivitiesTest.php +++ b/tests/ContextActivitiesTest.php @@ -17,10 +17,11 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Activity; use TinCan\ContextActivities; -class ContextActivitiesTest extends \PHPUnit_Framework_TestCase { +class ContextActivitiesTest extends TestCase { use TestCompareWithSignatureTrait; static private $listProps = ['category', 'parent', 'grouping', 'other']; diff --git a/tests/ContextTest.php b/tests/ContextTest.php index e90117b..68827ef 100644 --- a/tests/ContextTest.php +++ b/tests/ContextTest.php @@ -17,6 +17,7 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Agent; use TinCan\Context; use TinCan\ContextActivities; @@ -25,7 +26,7 @@ use TinCan\StatementRef; use TinCan\Util; -class ContextTest extends \PHPUnit_Framework_TestCase { +class ContextTest extends TestCase { use TestCompareWithSignatureTrait; private $emptyProperties = array( diff --git a/tests/DocumentTest.php b/tests/DocumentTest.php index 0494cf4..8026630 100644 --- a/tests/DocumentTest.php +++ b/tests/DocumentTest.php @@ -17,11 +17,12 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Document; class StubDocument extends Document {} -class DocumentTest extends \PHPUnit_Framework_TestCase { +class DocumentTest extends TestCase { public function testExceptionOnInvalidDateTime() { $this->setExpectedException( "InvalidArgumentException", diff --git a/tests/ExtensionsTest.php b/tests/ExtensionsTest.php index 6bfd2c3..6c2cefa 100644 --- a/tests/ExtensionsTest.php +++ b/tests/ExtensionsTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Extensions; -class ExtensionsTest extends \PHPUnit_Framework_TestCase { +class ExtensionsTest extends TestCase { use TestCompareWithSignatureTrait; public function testInstantiation() { diff --git a/tests/GroupTest.php b/tests/GroupTest.php index 1905d2e..163d28e 100644 --- a/tests/GroupTest.php +++ b/tests/GroupTest.php @@ -17,11 +17,12 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Agent; use TinCan\AgentAccount; use TinCan\Group; -class GroupTest extends \PHPUnit_Framework_TestCase { +class GroupTest extends TestCase { use TestCompareWithSignatureTrait; public function testInstantiation() { diff --git a/tests/ISO8601Test.php b/tests/ISO8601Test.php index 0ab3c94..836ca59 100644 --- a/tests/ISO8601Test.php +++ b/tests/ISO8601Test.php @@ -19,10 +19,11 @@ use DateTime; use DateTimeZone; +use PHPUnit\Framework\TestCase; use TinCan\Statement; use TinCan\State; -class ISO8601Test extends \PHPUnit_Framework_TestCase { +class ISO8601Test extends TestCase { public function testProperties() { $str_datetime = '2014-12-15T19:16:05+00:00'; $str_datetime_tz = '2014-12-15T13:16:05-06:00'; diff --git a/tests/JSONParseErrorExceptionTest.php b/tests/JSONParseErrorExceptionTest.php index a74b8ae..4f8046a 100644 --- a/tests/JSONParseErrorExceptionTest.php +++ b/tests/JSONParseErrorExceptionTest.php @@ -15,9 +15,12 @@ limitations under the License. */ +namespace TinCanTest; + +use PHPUnit\Framework\TestCase; use TinCan\JSONParseErrorException; -class JSONParseErrorExceptionTest extends PHPUnit_Framework_TestCase +class JSONParseErrorExceptionTest extends TestCase { private $exception; private $malformedValue = '.....'; diff --git a/tests/LRSResponseTest.php b/tests/LRSResponseTest.php index 9612497..ed32754 100644 --- a/tests/LRSResponseTest.php +++ b/tests/LRSResponseTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\LRSResponse; -class LRSResponseTest extends \PHPUnit_Framework_TestCase { +class LRSResponseTest extends TestCase { public function testInstantiation() { $obj = new LRSResponse(true, '', false); $this->assertTrue($obj->success); diff --git a/tests/LanguageMapTest.php b/tests/LanguageMapTest.php index 56ab20b..c3607a6 100644 --- a/tests/LanguageMapTest.php +++ b/tests/LanguageMapTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\LanguageMap; -class LanguageMapTest extends \PHPUnit_Framework_TestCase { +class LanguageMapTest extends TestCase { const NAME = 'testName'; public function testInstantiation() { diff --git a/tests/MapTest.php b/tests/MapTest.php index 484bfd9..a774e97 100644 --- a/tests/MapTest.php +++ b/tests/MapTest.php @@ -17,11 +17,12 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Map; class StubMap extends Map {} -class MapTest extends \PHPUnit_Framework_TestCase { +class MapTest extends TestCase { public function testInstantiation() { $obj = new StubMap(); } diff --git a/tests/PersonTest.php b/tests/PersonTest.php index bceb7e8..64b7194 100644 --- a/tests/PersonTest.php +++ b/tests/PersonTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Person; -class PersonTest extends \PHPUnit_Framework_TestCase { +class PersonTest extends TestCase { use TestCompareWithSignatureTrait; public function testInstantiation() { diff --git a/tests/RemoteLRSTest.php b/tests/RemoteLRSTest.php index c41f4cc..2954aca 100644 --- a/tests/RemoteLRSTest.php +++ b/tests/RemoteLRSTest.php @@ -17,6 +17,7 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Activity; use TinCan\Agent; use TinCan\Attachment; @@ -28,7 +29,7 @@ use TinCan\Verb; use TinCan\Version; -class RemoteLRSTest extends \PHPUnit_Framework_TestCase { +class RemoteLRSTest extends TestCase { static private $endpoint; static private $version; static private $username; diff --git a/tests/ResultTest.php b/tests/ResultTest.php index a2f50bd..b707e3f 100644 --- a/tests/ResultTest.php +++ b/tests/ResultTest.php @@ -17,11 +17,12 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Extensions; use TinCan\Result; use TinCan\Score; -class ResultTest extends \PHPUnit_Framework_TestCase { +class ResultTest extends TestCase { use TestCompareWithSignatureTrait; private $emptyProperties = array( diff --git a/tests/ScoreTest.php b/tests/ScoreTest.php index f66623a..f0ea788 100644 --- a/tests/ScoreTest.php +++ b/tests/ScoreTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Score; -class ScoreTest extends \PHPUnit_Framework_TestCase { +class ScoreTest extends TestCase { use TestCompareWithSignatureTrait; private $emptyProperties = array( diff --git a/tests/SignatureComparisonTraitTest.php b/tests/SignatureComparisonTraitTest.php index 6c217b4..ef2a580 100644 --- a/tests/SignatureComparisonTraitTest.php +++ b/tests/SignatureComparisonTraitTest.php @@ -17,6 +17,8 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; + class SignatureComparisonStub { use \TinCan\SignatureComparisonTrait; @@ -25,7 +27,7 @@ public static function runDoMatch($a, $b, $description) { } } -class SignatureComparisonTraitTest extends \PHPUnit_Framework_TestCase { +class SignatureComparisonTraitTest extends TestCase { public function testDoMatch() { $description = "A test Description"; diff --git a/tests/StateTest.php b/tests/StateTest.php index afb4302..d1e8524 100644 --- a/tests/StateTest.php +++ b/tests/StateTest.php @@ -17,10 +17,11 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\State; use TinCan\Group; -class StateTest extends \PHPUnit_Framework_TestCase { +class StateTest extends TestCase { public function testCanSetActivityWithArray() { $args = [ 'id' => COMMON_ACTIVITY_ID, diff --git a/tests/StatementBaseTest.php b/tests/StatementBaseTest.php index f32f4a0..e6682fb 100644 --- a/tests/StatementBaseTest.php +++ b/tests/StatementBaseTest.php @@ -17,6 +17,7 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\StatementBase; use TinCan\SubStatement; use TinCan\Verb; @@ -26,7 +27,7 @@ class StubStatementBase extends StatementBase {} -class StatementBaseTest extends \PHPUnit_Framework_TestCase { +class StatementBaseTest extends TestCase { public function testInstantiation() { $obj = new StubStatementBase(); } diff --git a/tests/StatementRefTest.php b/tests/StatementRefTest.php index 3567d31..6d117f2 100644 --- a/tests/StatementRefTest.php +++ b/tests/StatementRefTest.php @@ -17,10 +17,11 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\StatementRef; use TinCan\Util; -class StatementRefTest extends \PHPUnit_Framework_TestCase { +class StatementRefTest extends TestCase { public function testInstantiation() { $obj = new StatementRef(); $this->assertInstanceOf('TinCan\StatementRef', $obj); diff --git a/tests/StatementTest.php b/tests/StatementTest.php index ba04c09..f1d7c57 100644 --- a/tests/StatementTest.php +++ b/tests/StatementTest.php @@ -17,6 +17,7 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Activity; use TinCan\Agent; use TinCan\Attachment; @@ -28,7 +29,7 @@ use TinCan\Version; use Namshi\JOSE\JWS; -class StatementTest extends \PHPUnit_Framework_TestCase { +class StatementTest extends TestCase { use TestCompareWithSignatureTrait; public function testInstantiation() { @@ -601,20 +602,38 @@ public function testHasAttachmentWithContent() { public function testSignNoArgs() { $obj = new Statement(); - $this->setExpectedException( - 'PHPUnit_Framework_Error_Warning', - (getenv('TRAVIS_PHP_VERSION') == "hhvm" ? 'sign() expects at least 2 parameters, 0 given' : 'Missing argument 1') - ); + # PHP 7.1 promoted "too few arguments" warning to an error exception + if (version_compare(PHP_VERSION, '7.1') >= 0) { + $this->setExpectedExceptionRegExp( + 'ArgumentCountError', + '/Too few arguments to function ' . preg_quote(get_class($obj)) . '::sign\(\), 0 passed in ' + . preg_quote(__FILE__) . ' on line \d+ and at least 2 expected/' + ); + } else { + $this->setExpectedException( + 'PHPUnit_Framework_Error_Warning', + (getenv('TRAVIS_PHP_VERSION') == "hhvm" ? 'sign() expects at least 2 parameters, 0 given' : 'Missing argument 1') + ); + } $obj->sign(); } public function testSignOneArg() { $obj = new Statement(); - $this->setExpectedException( - 'PHPUnit_Framework_Error_Warning', - (getenv('TRAVIS_PHP_VERSION') == "hhvm" ? 'sign() expects at least 2 parameters, 1 given' : 'Missing argument 2') - ); + # PHP 7.1 promoted "too few arguments" warning to an error exception + if (version_compare(PHP_VERSION, '7.1') >= 0) { + $this->setExpectedExceptionRegExp( + 'ArgumentCountError', + '/Too few arguments to function ' . preg_quote(get_class($obj)) . '::sign\(\), 1 passed in ' + . preg_quote(__FILE__) . ' on line \d+ and at least 2 expected/' + ); + } else { + $this->setExpectedException( + 'PHPUnit_Framework_Error_Warning', + (getenv('TRAVIS_PHP_VERSION') == "hhvm" ? 'sign() expects at least 2 parameters, 1 given' : 'Missing argument 2') + ); + } $obj->sign('test'); } diff --git a/tests/StatementVariationsTest.php b/tests/StatementVariationsTest.php index 91c8772..8bef35d 100644 --- a/tests/StatementVariationsTest.php +++ b/tests/StatementVariationsTest.php @@ -17,12 +17,13 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Activity; use TinCan\RemoteLRS; use TinCan\Statement; use TinCan\Util; -class StatementVariationsTest extends \PHPUnit_Framework_TestCase { +class StatementVariationsTest extends TestCase { static protected $lrss; static public function setUpBeforeClass() { diff --git a/tests/SubStatementTest.php b/tests/SubStatementTest.php index 9d3ab4f..05dd279 100644 --- a/tests/SubStatementTest.php +++ b/tests/SubStatementTest.php @@ -17,6 +17,7 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Activity; use TinCan\Agent; use TinCan\Context; @@ -25,7 +26,7 @@ use TinCan\Util; use TinCan\Verb; -class SubStatementTest extends \PHPUnit_Framework_TestCase { +class SubStatementTest extends TestCase { use TestCompareWithSignatureTrait; public function testInstantiation() { diff --git a/tests/UtilTest.php b/tests/UtilTest.php index c3b8045..6f4f21c 100644 --- a/tests/UtilTest.php +++ b/tests/UtilTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Util; -class UtilTest extends \PHPUnit_Framework_TestCase { +class UtilTest extends TestCase { public function testGetUUID() { $result = Util::getUUID(); diff --git a/tests/VerbTest.php b/tests/VerbTest.php index e72a435..6c233e9 100644 --- a/tests/VerbTest.php +++ b/tests/VerbTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Verb; -class VerbTest extends \PHPUnit_Framework_TestCase { +class VerbTest extends TestCase { use TestCompareWithSignatureTrait; static private $DISPLAY; diff --git a/tests/VersionTest.php b/tests/VersionTest.php index aacba71..9792bc1 100644 --- a/tests/VersionTest.php +++ b/tests/VersionTest.php @@ -17,9 +17,10 @@ namespace TinCanTest; +use PHPUnit\Framework\TestCase; use TinCan\Version; -class VersionTest extends \PHPUnit_Framework_TestCase { +class VersionTest extends TestCase { public function testStaticFactoryReturnsInstance() { $this->assertInstanceOf("TinCan\Version", Version::v101(), "factory returns instance"); }