Skip to content

Commit 4495a44

Browse files
committed
Updated some outdated pieces.
Seems like a couple things have changed since we last ran the tests 2 years ago. Updated phpunit version number because some class names changed, phpunit.xml needed to be changed, reference v1.0.3 of xAPI, and fixed some Exception language that seems to have changed.
1 parent abb63a0 commit 4495a44

6 files changed

Lines changed: 44 additions & 17 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"require-dev": {
3333
"phpdocumentor/phpdocumentor": "2.*",
34-
"phpunit/phpunit": "@stable"
34+
"phpunit/phpunit": "^4"
3535
},
3636
"autoload": {
3737
"psr-4": {

phpunit.xml.dist

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99
convertWarningsToExceptions="true"
1010
processIsolation="false"
1111
stopOnFailure="false"
12-
syntaxCheck="false"
1312
>
1413
<testsuites>
1514
<testsuite name="TinCanPHP Test Suite">
1615
<directory suffix="Test.php">tests</directory>
17-
<exclude>
18-
<directory>tests/config</directory>
19-
<directory>tests/files</directory>
20-
<directory>tests/keys</directory>
21-
</exclude>
16+
<exclude>tests/config</exclude>
17+
<exclude>tests/files</exclude>
18+
<exclude>tests/keys</exclude>
2219
</testsuite>
2320
</testsuites>
2421

src/RemoteLRS.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ protected function sendRequest($method, $resource) {
138138
//
139139
set_error_handler(
140140
function ($errno, $errstr, $errfile, $errline, array $errcontext) {
141+
// "!== false" is intentional. strpos() can return 0, which is falsey, but returning
142+
// 0 matches our "true" condition. Using strict equality to avoid that confusion.
143+
if ($errno == E_NOTICE && strpos($errstr, 'Array to string conversion') !== false) {
144+
// The way HHVM handles array comparison results in a Notice being raised in fopen(),
145+
// but that's expected here and won't affect functionality. We don't want to throw
146+
// those Notices as Errors. Checking if this is a Notice before looking at the
147+
// contents of the string to hopefully minimize any performance impact here.
148+
// See https://github.com/facebook/hhvm/issues/1561 for the "won't fix" from HHVM.
149+
150+
return true;
151+
}
152+
141153
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
142154
}
143155
);

src/Version.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ final class Version
3232
*
3333
* @var string
3434
*/
35+
const V103 = "1.0.3";
36+
const V102 = "1.0.2";
3537
const V101 = "1.0.1";
3638
const V100 = "1.0.0";
3739
const V095 = "0.95";
3840
/**#@- */
3941

4042
/** @var array string => bool */
4143
private static $supported = [
44+
self::V103 => true,
45+
self::V102 => true,
4246
self::V101 => true,
4347
self::V100 => true,
4448
self::V095 => false

tests/StatementTest.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -601,20 +601,34 @@ public function testHasAttachmentWithContent() {
601601
public function testSignNoArgs() {
602602
$obj = new Statement();
603603

604-
$this->setExpectedException(
605-
'PHPUnit_Framework_Error_Warning',
606-
(getenv('TRAVIS_PHP_VERSION') == "hhvm" ? 'sign() expects at least 2 parameters, 0 given' : 'Missing argument 1')
607-
);
604+
if (PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) {
605+
$this->setExpectedException(
606+
'ArgumentCountError'
607+
);
608+
}
609+
else {
610+
$this->setExpectedException(
611+
'PHPUnit_Framework_Error_Warning',
612+
(getenv('TRAVIS_PHP_VERSION') == "hhvm" ? 'sign() expects at least 2 parameters, 0 given' : 'Missing argument 1')
613+
);
614+
}
608615
$obj->sign();
609616
}
610617

611618
public function testSignOneArg() {
612619
$obj = new Statement();
613620

614-
$this->setExpectedException(
615-
'PHPUnit_Framework_Error_Warning',
616-
(getenv('TRAVIS_PHP_VERSION') == "hhvm" ? 'sign() expects at least 2 parameters, 1 given' : 'Missing argument 2')
617-
);
621+
if (PHP_MAJOR_VERSION >= 7 && PHP_MINOR_VERSION >= 1) {
622+
$this->setExpectedException(
623+
'ArgumentCountError'
624+
);
625+
}
626+
else {
627+
$this->setExpectedException(
628+
'PHPUnit_Framework_Error_Warning',
629+
(getenv('TRAVIS_PHP_VERSION') == "hhvm" ? 'sign() expects at least 2 parameters, 1 given' : 'Missing argument 2')
630+
);
631+
}
618632
$obj->sign('test');
619633
}
620634

tests/VersionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testIsSupportedReturnsBool() {
4242
}
4343

4444
public function testIsLatestReturnsBool() {
45-
$this->assertTrue(Version::v101()->isLatest(), "1.0.1 should be the latest version");
45+
$this->assertTrue(Version::v103()->isLatest(), "1.0.3 should be the latest version");
4646
$this->assertFalse(Version::v095()->isLatest(), "0.95 should not be the latest version");
4747
}
4848

@@ -52,7 +52,7 @@ public function testSupported() {
5252
}
5353

5454
public function testLatest() {
55-
$this->assertSame(Version::V101, Version::latest(), "match latest");
55+
$this->assertSame(Version::V103, Version::latest(), "match latest");
5656
}
5757

5858
public function testVersionFromString() {

0 commit comments

Comments
 (0)