Skip to content

Commit

Permalink
fix syntax error for php 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Ne-Lexa committed Dec 30, 2019
1 parent f377b88 commit 28bddad
Showing 1 changed file with 10 additions and 32 deletions.
42 changes: 10 additions & 32 deletions tests/ZipStreamOpenTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

/** @noinspection PhpUsageOfSilenceOperatorInspection */

namespace PhpZip\Tests;

use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -49,34 +51,24 @@ public function testOpenStream($resource, $exceptionClass = null, $exceptionMess
}

/**
* @return array|\Generator
* @return array
*/
public function provideStreams()
{
return [
'file' => yield [fopen(__DIR__ . '/resources/apk.zip', 'rb'), null, null],
'directory' => yield [
fopen(__DIR__, 'rb'),
[@fopen(__DIR__ . '/resources/apk.zip', 'rb'), null, null],
[
@fopen(__DIR__, 'rb'),
InvalidArgumentException::class,
'Directory stream not supported',
],
'temp' => yield [$this->getTempResource('php://temp'), null, null],
'memory' => yield [$this->getTempResource('php://memory'), null, null],
'bz' => yield [
$this->getBzResource(),
InvalidArgumentException::class,
'The stream wrapper type "Unknown" is not supported.',
],
'url' => yield [
fopen('https://github.com/Ne-Lexa/php-zip/archive/master.zip', 'rb'),
[$this->getTempResource('php://temp'), null, null],
[$this->getTempResource('php://memory'), null, null],
[
@fopen('https://github.com/Ne-Lexa/php-zip/archive/master.zip', 'rb'),
InvalidArgumentException::class,
'The stream wrapper type "http" is not supported.',
],
'ftp' => yield [
fopen('ftp://ftp.ripe.net/pub/stats/ripencc/delegated-ripencc-latest.md5', 'rb'),
InvalidArgumentException::class,
'The stream wrapper type "ftp" is not supported.',
],
];
}

Expand All @@ -95,18 +87,4 @@ private function getTempResource($filename)

return $stream;
}

/**
* @return resource|null
*/
private function getBzResource()
{
if (!\extension_loaded('bz2')) {
return null;
}
$stream = bzopen('php://temp', 'w');
bzwrite($stream, 'some input here');

return $stream;
}
}

0 comments on commit 28bddad

Please sign in to comment.