Skip to content

Commit

Permalink
split dummy classes in tests into their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Apr 8, 2020
1 parent f1d138e commit 77d750c
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 51 deletions.
20 changes: 0 additions & 20 deletions tests/DirectoryWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@

namespace Icewind\Streams\Tests;

class DirectoryWrapperNull extends \Icewind\Streams\DirectoryWrapper {
public static function wrap($source) {
return self::wrapSource($source);
}
}

class DirectoryWrapperDummy extends \Icewind\Streams\DirectoryWrapper {
public static function wrap($source) {
return self::wrapSource($source);
}

public function dir_readdir() {
$file = parent::dir_readdir();
if ($file !== false) {
$file .= '_';
}
return $file;
}
}

class DirectoryWrapper extends IteratorDirectory {

/**
Expand Down
36 changes: 36 additions & 0 deletions tests/DirectoryWrapperDummy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace Icewind\Streams\Tests;

class DirectoryWrapperDummy extends \Icewind\Streams\DirectoryWrapper {
public static function wrap($source) {
return self::wrapSource($source);
}

public function dir_readdir() {
$file = parent::dir_readdir();
if ($file !== false) {
$file .= '_';
}
return $file;
}
}
28 changes: 28 additions & 0 deletions tests/DirectoryWrapperNull.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace Icewind\Streams\Tests;

class DirectoryWrapperNull extends \Icewind\Streams\DirectoryWrapper {
public static function wrap($source) {
return self::wrapSource($source);
}
}
36 changes: 36 additions & 0 deletions tests/FailWrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace Icewind\Streams\Tests;

class FailWrapper extends \Icewind\Streams\NullWrapper {
public static function wrap($source) {
return self::wrapSource($source);
}

public function stream_read($count) {
return false;
}

public function stream_write($data) {
return false;
}
}
38 changes: 38 additions & 0 deletions tests/PartialWrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace Icewind\Streams\Tests;

class PartialWrapper extends \Icewind\Streams\NullWrapper {
public static function wrap($source) {
return self::wrapSource($source);
}

public function stream_read($count) {
$count = min($count, 2); // return as most 2 bytes
return parent::stream_read($count);
}

public function stream_write($data) {
$data = substr($data, 0, 2); //write as most 2 bytes
return parent::stream_write($data);
}
}
32 changes: 1 addition & 31 deletions tests/RetryWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,7 @@

namespace Icewind\Streams\Tests;

class PartialWrapper extends \Icewind\Streams\NullWrapper {
public static function wrap($source) {
return self::wrapSource($source);
}

public function stream_read($count) {
$count = min($count, 2); // return as most 2 bytes
return parent::stream_read($count);
}

public function stream_write($data) {
$data = substr($data, 0, 2); //write as most 2 bytes
return parent::stream_write($data);
}
}

class FailWrapper extends \Icewind\Streams\NullWrapper {
public static function wrap($source) {
return self::wrapSource($source);
}

public function stream_read($count) {
return false;
}

public function stream_write($data) {
return false;
}
}

class RetryWrapperTest extends WrapperTest {
class RetryWrapper extends WrapperTest {

/**
* @param resource $source
Expand Down

0 comments on commit 77d750c

Please sign in to comment.