mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-03 16:44:07 +02:00
fixup tests
This commit is contained in:
parent
b8bea69ea6
commit
1c6d18170e
7 changed files with 25 additions and 20 deletions
|
|
@ -1,52 +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 SeekableWrapper extends \PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* @param resource $source
|
||||
* @return resource
|
||||
*/
|
||||
protected function wrapSource($source) {
|
||||
return \Icewind\Streams\SeekableWrapper::wrap($source);
|
||||
}
|
||||
|
||||
protected function getSource() {
|
||||
$source = fopen('php://temp', 'w+');
|
||||
fwrite($source, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.');
|
||||
fseek($source, 0);
|
||||
return $source;
|
||||
}
|
||||
|
||||
public function testCantWrapDir() {
|
||||
$source = opendir(__DIR__);
|
||||
$this->assertFalse(@$this->wrapSource($source));
|
||||
}
|
||||
|
||||
public function testSourceNotSeeked() {
|
||||
$source = $this->getSource();
|
||||
$wrapped = $this->wrapSource($source);
|
||||
fseek($wrapped, 6);
|
||||
$this->assertSame(6, ftell($source));
|
||||
$this->assertSame(6, ftell($wrapped));
|
||||
$this->assertSame('ipsum', fread($wrapped, '5'));
|
||||
fseek($wrapped, 6);
|
||||
$this->assertSame(6, ftell($wrapped));
|
||||
$this->assertGreaterThan(6, ftell($source));
|
||||
}
|
||||
|
||||
public function testSeekRelative() {
|
||||
$source = $this->getSource();
|
||||
$wrapped = $this->wrapSource($source);
|
||||
fseek($wrapped, 6);
|
||||
fseek($wrapped, 6, SEEK_CUR);
|
||||
$this->assertSame(12, ftell($source));
|
||||
$this->assertSame(12, ftell($wrapped));
|
||||
$this->assertSame('dolor', fread($wrapped, '5'));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue