Skip to content

Commit

Permalink
Fix tests and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Oct 15, 2020
1 parent 41f3283 commit 9d7f3b8
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 54 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Expand Up @@ -18,16 +18,16 @@ matrix:
CHECK_MBSTRING=1
- dist: precise
php: "5.6"
env: USE_PSALM=1
env: USE_PSALM=0
CHECK_MBSTRING=1
- php: "7.0"
env: USE_PSALM=1
env: USE_PSALM=0
CHECK_MBSTRING=1
- php: "7.1"
env: USE_PSALM=1
CHECK_MBSTRING=1
env: USE_PSALM=0
CHECK_MBSTRING=0
- php: "7.2"
env: USE_PSALM=1
env: USE_PSALM=0
CHECK_MBSTRING=0
- php: "7.3"
env: USE_PSALM=1
Expand All @@ -49,9 +49,9 @@ matrix:
- php: "master"

install:
- composer self-update
- composer install
- if [[ $USE_PSALM -eq 1 ]]; then composer require --dev "vimeo/psalm:^0|^1|^2"; fi
- travis_retry composer install
- if [[ $USE_PSALM -eq 1 ]]; then composer require --dev "phpunit/phpunit:>=4"; fi
- if [[ $USE_PSALM -eq 1 ]]; then composer require --dev "vimeo/psalm:^3"; fi

script:
- vendor/bin/phpunit
Expand Down
6 changes: 6 additions & 0 deletions other/phpunit-shim.php
@@ -0,0 +1,6 @@
<?php

class PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase
{

}
14 changes: 14 additions & 0 deletions phpunit-autoload.php
@@ -0,0 +1,14 @@
<?php

require_once __DIR__ . '/psalm-autoload.php';

/**
* This is necessary for PHPUnit on PHP >= 5.3
*
* Class PHPUnit_Framework_TestCase
*/
if (PHP_VERSION_ID >= 50300) {
if (!class_exists('PHPUnit_Framework_TestCase')) {
require_once __DIR__ . '/other/phpunit-shim.php';
}
}
40 changes: 11 additions & 29 deletions phpunit.xml.dist
@@ -1,31 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="true"
backupStaticAttributes="false"
bootstrap="lib/random.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
syntaxCheck="true"
>
<testsuites>
<testsuite name="Unit">
<directory>tests/unit</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="Random Compat Test Suite">
<directory suffix="Test.php">./tests/unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./lib</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" backupStaticAttributes="false" bootstrap="phpunit-autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./lib</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Random Compat Test Suite">
<directory suffix="Test.php">./tests/unit</directory>
</testsuite>
</testsuites>
</phpunit>
10 changes: 5 additions & 5 deletions psalm-autoload.php
@@ -1,9 +1,9 @@
<?php

require_once 'lib/byte_safe_strings.php';
require_once 'lib/cast_to_int.php';
require_once 'lib/error_polyfill.php';
require_once 'other/ide_stubs/libsodium.php';
require_once 'lib/random.php';
require_once __DIR__ . '/lib/byte_safe_strings.php';
require_once __DIR__ . '/lib/cast_to_int.php';
require_once __DIR__ . '/lib/error_polyfill.php';
require_once __DIR__ . '/other/ide_stubs/libsodium.php';
require_once __DIR__ . '/lib/random.php';

$int = random_int(0, 65536);
32 changes: 20 additions & 12 deletions psalm.xml
@@ -1,28 +1,36 @@
<?xml version="1.0"?>
<psalm
autoloader="psalm-autoload.php"
useDocblockTypes="true"
totallyTyped="true"
autoloader="psalm-autoload.php"
useDocblockTypes="true"
totallyTyped="true"
>
<projectFiles>
<directory name="lib" />
</projectFiles>
<issueHandlers>
<ReferenceConstraintViolation errorLevel="info" />
<!-- Type strictness surrounding /dev/urandom reads -->
<RedundantConditionGivenDocblockType errorLevel="info" />
<!-- We have to be explicit because PHP 5 lacks scalar types -->
<!-- We have to be explicit because PHP 5 lacks scalar types -->
<DocblockTypeContradiction errorLevel="info" />
<!-- We're strict about runtime checks -->
<DuplicateFunction errorLevel="info" />
<!-- We're a polyfill library! -->
<UnresolvableInclude errorLevel="info" />
<!-- Because we put the variants into their own subdirectory -->
<!-- Because we put the variants into their own subdirectory -->
<DuplicateClass errorLevel="info" />
<!-- Later versions of Psalm are only PHP 7 compatible, which
sees our redefinition of Error and TypeError as duplicate
class errors. -->
<!-- Later versions of Psalm are only PHP 7 compatible, which
sees our redefinition of Error and TypeError as duplicate
class errors. -->
<UndefinedDocblockClass errorLevel="info" />
<!-- COM is Windows only -->
<UndefinedConstant errorLevel="info" />
<!-- The Mcrypt constants aren't defined in PHP 7.2 -->
<!-- The Mcrypt constants aren't defined in PHP 7.2 -->
<MissingReturnType errorLevel="info" />
<!-- False positive with some versions of (Psalm, PHP) -->
<!-- False positive with some versions of (Psalm, PHP) -->
<InvalidReturnType errorLevel="info" />
<!-- The "last resort" function in lib/random.php -->
<!-- The "last resort" function in lib/random.php -->
<MixedInferredReturnType errorLevel="suppress" />
<!-- Only used in totallyTyped mode -->
<!-- Only used in totallyTyped mode -->
</issueHandlers>
</psalm>

0 comments on commit 9d7f3b8

Please sign in to comment.