streams/tests/NullWrapperTest.php
Andy Scherzinger d95aa6fa7e
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-06-02 20:52:50 +02:00

52 lines
1.2 KiB
PHP

<?php
/**
* SPDX-FileCopyrightText: 2014 Robin Appelman <icewind@owncloud.com>
* SPDX-License-Identifier: MIT
*/
namespace Icewind\Streams\Tests;
class NullWrapperTest extends WrapperTest {
/**
* @param resource $source
* @return resource
*/
protected function wrapSource($source) {
return \Icewind\Streams\NullWrapper::wrap($source);
}
public function testNoContext() {
$this->expectException(\BadMethodCallException::class);
stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
$context = stream_context_create([]);
try {
fopen('null://', 'r+', false, $context);
stream_wrapper_unregister('null');
} catch (\Exception $e) {
stream_wrapper_unregister('null');
throw $e;
}
}
public function testNoSource() {
$this->expectException(\BadMethodCallException::class);
stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
$context = stream_context_create([
'null' => [
'source' => 'bar'
]
]);
try {
fopen('null://', 'r+', false, $context);
} catch (\Exception $e) {
stream_wrapper_unregister('null');
throw $e;
}
}
public function testWrapInvalidSource() {
$this->expectException(\BadMethodCallException::class);
$this->wrapSource('foo');
}
}