mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-03 08:34:09 +02:00
adjust tests to new phpunit
This commit is contained in:
parent
eaf1768cd9
commit
a0abe86651
9 changed files with 97 additions and 23 deletions
65
.github/workflows/ci.yaml
vendored
Normal file
65
.github/workflows/ci.yaml
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
on: [push, pull_request]
|
||||
|
||||
name: CI
|
||||
|
||||
jobs:
|
||||
php-cs-fixer:
|
||||
name: PHP-CS-Fixer
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
- name: PHP-CS-Fixer
|
||||
uses: OskarStark/php-cs-fixer-ga@2.16.7
|
||||
with:
|
||||
args: --diff --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection
|
||||
|
||||
phpstan:
|
||||
name: PHPStan Static Analysis
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
- name: Composer
|
||||
run: composer install
|
||||
- env:
|
||||
BACKEND: smbclient
|
||||
run: php ./vendor/bin/phpstan analyse --level 2 src
|
||||
|
||||
phpunit:
|
||||
runs-on: ubuntu-20.04
|
||||
name: Unit tests
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
backend:
|
||||
- smbclient
|
||||
- libsmbclient
|
||||
|
||||
services:
|
||||
samba:
|
||||
image: dperson/samba
|
||||
env:
|
||||
USER: "test;test"
|
||||
SHARE: "test;/tmp;yes;no;yes;all;none"
|
||||
ports:
|
||||
- 139:139
|
||||
- 445:445
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
- name: Composer
|
||||
run: composer install
|
||||
- name: PHPUnit Tests
|
||||
run: php ./vendor/bin/phpunit tests
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@ vendor
|
|||
composer.lock
|
||||
build
|
||||
example.php
|
||||
*.cache
|
||||
|
|
|
|||
15
.php_cs.dist
Normal file
15
.php_cs.dist
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->exclude('vendor')
|
||||
->in(__DIR__)
|
||||
;
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'braces' => ['position_after_functions_and_oop_constructs' => 'same'],
|
||||
'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => false],
|
||||
])
|
||||
->setIndent("\t")
|
||||
->setFinder($finder)
|
||||
;
|
||||
|
|
@ -9,11 +9,12 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.6"
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "v2.1.0",
|
||||
"phpunit/phpunit": "^5.7"
|
||||
"phpunit/phpunit": "^9",
|
||||
"friendsofphp/php-cs-fixer": "^2",
|
||||
"phpstan/phpstan": "^0.12"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@ class CallbackWrapperTest extends WrapperTest {
|
|||
return \Icewind\Streams\CallbackWrapper::wrap($source, $read, $write, $close, $readDir, $preClose);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \BadMethodCallException
|
||||
*/
|
||||
public function testWrapInvalidSource() {
|
||||
$this->expectException(\BadMethodCallException::class);
|
||||
$this->wrapSource('foo');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@
|
|||
|
||||
namespace Icewind\Streams\Tests;
|
||||
|
||||
class HashWrapperTest extends \PHPUnit_Framework_TestCase {
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HashWrapperTest extends TestCase {
|
||||
const DATA = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,10 +17,8 @@ class NullWrapperTest extends WrapperTest {
|
|||
return \Icewind\Streams\NullWrapper::wrap($source);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \BadMethodCallException
|
||||
*/
|
||||
public function testNoContext() {
|
||||
$this->expectException(\BadMethodCallException::class);
|
||||
stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
|
||||
$context = stream_context_create(array());
|
||||
try {
|
||||
|
|
@ -32,10 +30,8 @@ class NullWrapperTest extends WrapperTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \BadMethodCallException
|
||||
*/
|
||||
public function testNoSource() {
|
||||
$this->expectException(\BadMethodCallException::class);
|
||||
stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
|
||||
$context = stream_context_create(array(
|
||||
'null' => array(
|
||||
|
|
@ -50,10 +46,8 @@ class NullWrapperTest extends WrapperTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \BadMethodCallException
|
||||
*/
|
||||
public function testWrapInvalidSource() {
|
||||
$this->expectException(\BadMethodCallException::class);
|
||||
$this->wrapSource('foo');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
|
||||
namespace Icewind\Streams\Tests;
|
||||
|
||||
abstract class WrapperTest extends \PHPUnit_Framework_TestCase {
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class WrapperTest extends TestCase {
|
||||
/**
|
||||
* @param resource $source
|
||||
* @return resource
|
||||
|
|
@ -93,6 +95,7 @@ abstract class WrapperTest extends \PHPUnit_Framework_TestCase {
|
|||
if (!flock($wrapped, LOCK_EX)) {
|
||||
$this->fail('Unable to acquire lock');
|
||||
}
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function testStreamOptions() {
|
||||
|
|
@ -101,6 +104,7 @@ abstract class WrapperTest extends \PHPUnit_Framework_TestCase {
|
|||
stream_set_blocking($wrapped, 0);
|
||||
stream_set_timeout($wrapped, 1, 0);
|
||||
stream_set_write_buffer($wrapped, 0);
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function testReadDir() {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,4 @@
|
|||
<testsuite name='Stream'>
|
||||
<directory suffix='.php'>./</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist Stream="true">
|
||||
<directory suffix=".php">../src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue