summaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/icewind/streams/tests
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/3rdparty/icewind/streams/tests')
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/CallbackWrapper.php72
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/IteratorDirectory.php130
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/NullWrapper.php59
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/Wrapper.php105
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/bootstrap.php9
-rw-r--r--apps/files_external/3rdparty/icewind/streams/tests/phpunit.xml6
6 files changed, 0 insertions, 381 deletions
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/CallbackWrapper.php b/apps/files_external/3rdparty/icewind/streams/tests/CallbackWrapper.php
deleted file mode 100644
index 229b629dcd9..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/CallbackWrapper.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\Streams\Tests;
-
-class CallbackWrapper extends Wrapper {
-
- /**
- * @param resource $source
- * @param callable $read
- * @param callable $write
- * @param callable $close
- * @return resource
- */
- protected function wrapSource($source, $read = null, $write = null, $close = null) {
- return \Icewind\Streams\CallbackWrapper::wrap($source, $read, $write, $close);
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testWrapInvalidSource() {
- $this->wrapSource('foo');
- }
-
- public function testReadCallback() {
- $called = false;
- $callBack = function () use (&$called) {
- $called = true;
- };
-
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
-
- $wrapped = $this->wrapSource($source, $callBack);
- $this->assertEquals('foo', fread($wrapped, 3));
- $this->assertTrue($called);
- }
-
- public function testWriteCallback() {
- $lastData = '';
- $callBack = function ($data) use (&$lastData) {
- $lastData = $data;
- };
-
- $source = fopen('php://temp', 'r+');
-
- $wrapped = $this->wrapSource($source, null, $callBack);
- fwrite($wrapped, 'foobar');
- $this->assertEquals('foobar', $lastData);
- }
-
- public function testCloseCallback() {
- $called = false;
- $callBack = function () use (&$called) {
- $called = true;
- };
-
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
-
- $wrapped = $this->wrapSource($source, null, null, $callBack);
- fclose($wrapped);
- $this->assertTrue($called);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/IteratorDirectory.php b/apps/files_external/3rdparty/icewind/streams/tests/IteratorDirectory.php
deleted file mode 100644
index 0d990468368..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/IteratorDirectory.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\Streams\Tests;
-
-class IteratorDirectory extends \PHPUnit_Framework_TestCase {
-
- /**
- * @param \Iterator | array $source
- * @return resource
- */
- protected function wrapSource($source) {
- return \Icewind\Streams\IteratorDirectory::wrap($source);
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testNoContext() {
- $context = stream_context_create(array());
- stream_wrapper_register('iterator', '\Icewind\Streams\IteratorDirectory');
- try {
- opendir('iterator://', $context);
- stream_wrapper_unregister('iterator');
- } catch (\Exception $e) {
- stream_wrapper_unregister('iterator');
- throw $e;
- }
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testInvalidSource() {
- $context = stream_context_create(array(
- 'dir' => array(
- 'array' => 2
- )
- ));
- stream_wrapper_register('iterator', '\Icewind\Streams\IteratorDirectory');
- try {
- opendir('iterator://', $context);
- stream_wrapper_unregister('iterator');
- } catch (\Exception $e) {
- stream_wrapper_unregister('iterator');
- throw $e;
- }
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testWrapInvalidSource() {
- $this->wrapSource(2);
- }
-
- public function fileListProvider() {
- $longList = array_fill(0, 500, 'foo');
- return array(
- array(
- array(
- 'foo',
- 'bar',
- 'qwerty'
- )
- ),
- array(
- array(
- 'with spaces',
- 'under_scores',
- '日本語',
- 'character %$_',
- '.',
- '0',
- 'double "quotes"',
- "single 'quotes'"
- )
- ),
- array(
- array(
- 'single item'
- )
- ),
- array(
- $longList
- ),
- array(
- array()
- )
- );
- }
-
- protected function basicTest($fileList, $dh) {
- $result = array();
-
- while (($file = readdir($dh)) !== false) {
- $result[] = $file;
- }
-
- $this->assertEquals($fileList, $result);
-
- rewinddir($dh);
- if (count($fileList)) {
- $this->assertEquals($fileList[0], readdir($dh));
- } else {
- $this->assertFalse(readdir($dh));
- }
- }
-
- /**
- * @dataProvider fileListProvider
- */
- public function testBasicIterator($fileList) {
- $iterator = new \ArrayIterator($fileList);
- $dh = $this->wrapSource($iterator);
- $this->basicTest($fileList, $dh);
- }
-
- /**
- * @dataProvider fileListProvider
- */
- public function testBasicArray($fileList) {
- $dh = $this->wrapSource($fileList);
- $this->basicTest($fileList, $dh);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/NullWrapper.php b/apps/files_external/3rdparty/icewind/streams/tests/NullWrapper.php
deleted file mode 100644
index ba42b4dfea1..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/NullWrapper.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\Streams\Tests;
-
-class NullWrapper extends Wrapper {
-
- /**
- * @param resource $source
- * @return resource
- */
- protected function wrapSource($source) {
- return \Icewind\Streams\NullWrapper::wrap($source);
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testNoContext() {
- stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
- $context = stream_context_create(array());
- try {
- fopen('null://', 'r+', false, $context);
- stream_wrapper_unregister('null');
- } catch (\Exception $e) {
- stream_wrapper_unregister('null');
- throw $e;
- }
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testNoSource() {
- stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
- $context = stream_context_create(array(
- 'null' => array(
- 'source' => 'bar'
- )
- ));
- try {
- fopen('null://', 'r+', false, $context);
- } catch (\Exception $e) {
- stream_wrapper_unregister('null');
- throw $e;
- }
- }
-
- /**
- * @expectedException \BadMethodCallException
- */
- public function testWrapInvalidSource() {
- $this->wrapSource('foo');
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/Wrapper.php b/apps/files_external/3rdparty/icewind/streams/tests/Wrapper.php
deleted file mode 100644
index 6bb644dd611..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/Wrapper.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\Streams\Tests;
-
-abstract class Wrapper extends \PHPUnit_Framework_TestCase {
- /**
- * @param resource $source
- * @return resource
- */
- abstract protected function wrapSource($source);
-
- public function testRead() {
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
-
- $wrapped = $this->wrapSource($source);
- $this->assertEquals('foo', fread($wrapped, 3));
- $this->assertEquals('bar', fread($wrapped, 3));
- $this->assertEquals('', fread($wrapped, 3));
- }
-
- public function testWrite() {
- $source = fopen('php://temp', 'r+');
- rewind($source);
-
- $wrapped = $this->wrapSource($source);
-
- $this->assertEquals(6, fwrite($wrapped, 'foobar'));
- rewind($source);
- $this->assertEquals('foobar', stream_get_contents($source));
- }
-
- public function testClose() {
- $source = fopen('php://temp', 'r+');
- rewind($source);
-
- $wrapped = $this->wrapSource($source);
-
- fclose($wrapped);
- $this->assertFalse(is_resource($source));
- }
-
- public function testSeekTell() {
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
-
- $wrapped = $this->wrapSource($source);
-
- $this->assertEquals(0, ftell($wrapped));
-
- fseek($wrapped, 2);
- $this->assertEquals(2, ftell($source));
- $this->assertEquals(2, ftell($wrapped));
-
- fseek($wrapped, 2, SEEK_CUR);
- $this->assertEquals(4, ftell($source));
- $this->assertEquals(4, ftell($wrapped));
-
- fseek($wrapped, -1, SEEK_END);
- $this->assertEquals(5, ftell($source));
- $this->assertEquals(5, ftell($wrapped));
- }
-
- public function testStat() {
- $source = fopen(__FILE__, 'r+');
- $wrapped = $this->wrapSource($source);
- $this->assertEquals(stat(__FILE__), fstat($wrapped));
- }
-
- public function testTruncate() {
- if (version_compare(phpversion(), '5.4.0', '<')) {
- $this->markTestSkipped('php <5.4 doesn\'t support truncate for stream wrappers');
- }
- $source = fopen('php://temp', 'r+');
- fwrite($source, 'foobar');
- rewind($source);
- $wrapped = $this->wrapSource($source);
-
- ftruncate($wrapped, 2);
- $this->assertEquals('fo', fread($wrapped, 10));
- }
-
- public function testLock() {
- $source = tmpfile();
- $wrapped = $this->wrapSource($source);
- if (!flock($wrapped, LOCK_EX)) {
- $this->fail('Unable to acquire lock');
- }
- }
-
- public function testStreamOptions() {
- $source = fopen('php://temp', 'r+');
- $wrapped = $this->wrapSource($source);
- stream_set_blocking($wrapped, 0);
- stream_set_timeout($wrapped, 1, 0);
- stream_set_write_buffer($wrapped, 0);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/bootstrap.php b/apps/files_external/3rdparty/icewind/streams/tests/bootstrap.php
deleted file mode 100644
index 2c17fd57feb..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/bootstrap.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-date_default_timezone_set('UTC');
-require_once __DIR__ . '/../vendor/autoload.php';
diff --git a/apps/files_external/3rdparty/icewind/streams/tests/phpunit.xml b/apps/files_external/3rdparty/icewind/streams/tests/phpunit.xml
deleted file mode 100644
index e3d96352c43..00000000000
--- a/apps/files_external/3rdparty/icewind/streams/tests/phpunit.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<phpunit bootstrap="bootstrap.php">
- <testsuite name='Stream'>
- <directory suffix='.php'>./</directory>
- </testsuite>
-</phpunit>