-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
81 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Amp\Sql\Common\Test\Stub; | ||
|
||
use Amp\Sql\Common\PooledResult; | ||
use Amp\Sql\Result; | ||
|
||
final class StubPooledResult extends PooledResult | ||
{ | ||
public function __construct(Result $result, ?\Closure $release = null, private readonly ?Result $next = null) | ||
{ | ||
parent::__construct($result, $release ?? fn () => null); | ||
} | ||
|
||
public function getNextResult(): ?Result | ||
{ | ||
return $this->next; | ||
} | ||
|
||
protected static function newInstanceFrom(Result $result, \Closure $release): Result | ||
{ | ||
return new self($result, $release); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Amp\Sql\Common\Test\Stub; | ||
|
||
use Amp\Sql\Result; | ||
|
||
final class StubResult implements Result, \IteratorAggregate | ||
{ | ||
private readonly array $rows; | ||
|
||
private int $current = 0; | ||
|
||
public function __construct(array $rows, private readonly ?Result $next = null) | ||
{ | ||
$this->rows = array_values($rows); | ||
} | ||
|
||
public function getIterator(): \Iterator | ||
{ | ||
yield from $this->rows; | ||
} | ||
|
||
public function fetchRow(): ?array | ||
{ | ||
return $this->rows[$this->current++] ?? null; | ||
} | ||
|
||
public function getNextResult(): ?Result | ||
{ | ||
return $this->next; | ||
} | ||
|
||
public function getRowCount(): ?int | ||
{ | ||
return count($this->rows); | ||
} | ||
|
||
public function getColumnCount(): ?int | ||
{ | ||
return null; | ||
} | ||
} |