Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/Adapter/MockupStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ public function stream_open($path, $mode, $options, &$opened_path)
$this->test = $url["host"];
$this->position = 0;

self::$tests[$url["host"]] = '';
static::$tests[$url["host"]] = '';
return true;
}

public function stream_read($count)
{
$ret = substr(self::$tests[$this->test], $this->position, $count);
$ret = substr(static::$tests[$this->test], $this->position, $count);
$this->position += strlen($ret);
return $ret;
}

public function stream_write($data)
{
$left = substr(self::$tests[$this->test], 0, $this->position);
$right = substr(self::$tests[$this->test], $this->position + strlen($data));
self::$tests[$this->test] = $left . $data . $right;
$left = substr(static::$tests[$this->test], 0, $this->position);
$right = substr(static::$tests[$this->test], $this->position + strlen($data));
static::$tests[$this->test] = $left . $data . $right;
$this->position += strlen($data);
return strlen($data);
}
Expand All @@ -57,14 +57,14 @@ public function stream_tell()

public function stream_eof()
{
return $this->position >= strlen(self::$tests[$this->test]);
return $this->position >= strlen(static::$tests[$this->test]);
}

public function stream_seek($offset, $whence)
{
switch ($whence) {
case SEEK_SET:
if ($offset < strlen(self::$tests[$this->test]) && $offset >= 0) {
if ($offset < strlen(static::$tests[$this->test]) && $offset >= 0) {
$this->position = $offset;
return true;
} else {
Expand All @@ -82,8 +82,8 @@ public function stream_seek($offset, $whence)
break;

case SEEK_END:
if (strlen(self::$tests[$this->test]) + $offset >= 0) {
$this->position = strlen(self::$tests[$this->test]) + $offset;
if (strlen(static::$tests[$this->test]) + $offset >= 0) {
$this->position = strlen(static::$tests[$this->test]) + $offset;
return true;
} else {
return false;
Expand All @@ -97,6 +97,6 @@ public function stream_seek($offset, $whence)

public function __destruct()
{
unset(self::$tests[$this->test]);
unset(static::$tests[$this->test]);
}
}

0 comments on commit e733e70

Please sign in to comment.