From 6b21367ecd02c6aa844ad791a0d985b953aa2550 Mon Sep 17 00:00:00 2001 From: "Paragon Initiative Enterprises, LLC" Date: Sat, 1 Feb 2020 23:00:10 -0500 Subject: [PATCH] Fix Travis CI --- .travis.yml | 1 + composer.json | 3 +++ src/Halite.php | 2 ++ test/unit/StreamTest.php | 14 +++++++++----- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5bb131..e3d7b4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ dist: trusty php: - "7.2" - "7.3" + - "7.4" - "master" - "nightly" matrix: diff --git a/composer.json b/composer.json index 55983d8..e7beaa2 100644 --- a/composer.json +++ b/composer.json @@ -46,6 +46,9 @@ "phpunit/phpunit": "^8", "vimeo/psalm": "^3" }, + "scripts": { + "test": "phpunit && psalm" + }, "support": { "docs": "https://github.com/paragonie/halite/tree/master/doc" }, diff --git a/src/Halite.php b/src/Halite.php index f5fa60d..9bb37af 100644 --- a/src/Halite.php +++ b/src/Halite.php @@ -72,6 +72,8 @@ final private function __construct() * @param bool $decode * @return callable|null * @throws InvalidType + * @psalm-suppress InvalidReturnStatement + * @psalm-suppress InvalidReturnType */ public static function chooseEncoder($chosen, bool $decode = false) { diff --git a/test/unit/StreamTest.php b/test/unit/StreamTest.php index dfe54c6..9703e1e 100644 --- a/test/unit/StreamTest.php +++ b/test/unit/StreamTest.php @@ -20,7 +20,7 @@ final class StreamTest extends TestCase */ public function testFileHash() { - $filename = tempnam('/tmp', 'x'); + $filename = @tempnam('/tmp', 'x'); $buf = random_bytes(65537); file_put_contents($filename, $buf); @@ -46,13 +46,17 @@ public function testFileHash() */ public function testUnreadableFile() { - $filename = tempnam('/tmp', 'x'); + $filename = @tempnam('/tmp', 'x'); $buf = random_bytes(65537); file_put_contents($filename, $buf); chmod($filename, 0000); try { new ReadOnlyFile($filename); + if (DIRECTORY_SEPARATOR === '\\') { + $this->markTestSkipped('Windows permissions are weird.'); + return; + } $this->fail('File should not be readable'); } catch (CryptoException\FileAccessDenied $ex) { $this->assertSame('Could not open file for reading', $ex->getMessage()); @@ -90,7 +94,7 @@ public function testUnreadableFile() */ public function testResource() { - $filename = tempnam('/tmp', 'x'); + $filename = @tempnam('/tmp', 'x'); $buf = random_bytes(65537); file_put_contents($filename, $buf); @@ -142,7 +146,7 @@ public function testResource() */ public function testFileRead() { - $filename = tempnam('/tmp', 'x'); + $filename = @tempnam('/tmp', 'x'); $buf = random_bytes(65537); file_put_contents($filename, $buf); @@ -189,7 +193,7 @@ public function testFileRead() foreach ([255, 65537] as $size) { $buffer = random_bytes($size); - $fileWrite = tempnam('/tmp', 'x'); + $fileWrite = @tempnam('/tmp', 'x'); $mStream = new MutableFile($fileWrite); $mStream->writeBytes($buffer); $mStream->reset(0);