Skip to content

Commit

Permalink
fixup! Bump doctrine/dbal from 2.12.0 to 3.0.0
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Jan 5, 2021
1 parent e96336e commit 8c54700
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 3rdparty
Submodule 3rdparty updated 112 files
26 changes: 15 additions & 11 deletions tests/lib/AppFramework/Db/MapperTestUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@

namespace Test\AppFramework\Db;

use OCP\DB\IPreparedStatement;
use OCP\DB\IResult;

/**
* Simple utility class for testing mappers
*/
abstract class MapperTestUtility extends \Test\TestCase {
protected $db;
private $query;
private $statement;
private $queryAt;
private $prepareAt;
private $fetchAt;
Expand All @@ -47,7 +50,7 @@ protected function setUp(): void {
->disableOriginalConstructor()
->getMock();

$this->query = $this->createMock('\PDOStatement');
$this->statement = $this->createMock(IPreparedStatement::class);
$this->queryAt = 0;
$this->prepareAt = 0;
$this->iterators = [];
Expand Down Expand Up @@ -94,34 +97,34 @@ protected function setMapperResult($sql, $arguments = [], $returnRows = [],
$this->db->expects($this->at($this->prepareAt))
->method('prepare')
->with($this->equalTo($sql))
->will(($this->returnValue($this->query)));
->will(($this->returnValue($this->statement)));
} elseif ($limit !== null && $offset === null) {
$this->db->expects($this->at($this->prepareAt))
->method('prepare')
->with($this->equalTo($sql), $this->equalTo($limit))
->will(($this->returnValue($this->query)));
->will(($this->returnValue($this->statement)));
} elseif ($limit === null && $offset !== null) {
$this->db->expects($this->at($this->prepareAt))
->method('prepare')
->with($this->equalTo($sql),
$this->equalTo(null),
$this->equalTo($offset))
->will(($this->returnValue($this->query)));
->will(($this->returnValue($this->statement)));
} else {
$this->db->expects($this->at($this->prepareAt))
->method('prepare')
->with($this->equalTo($sql),
$this->equalTo($limit),
$this->equalTo($offset))
->will(($this->returnValue($this->query)));
->will(($this->returnValue($this->statement)));
}

$this->iterators[] = new ArgumentIterator($returnRows);

$iterators = $this->iterators;
$fetchAt = $this->fetchAt;

$this->query->expects($this->any())
$this->statement->expects($this->any())
->method('fetch')
->willReturnCallback(
function () use ($iterators, $fetchAt) {
Expand All @@ -141,7 +144,7 @@ function () use ($iterators, $fetchAt) {
if ($this->isAssocArray($arguments)) {
foreach ($arguments as $key => $argument) {
$pdoConstant = $this->getPDOType($argument);
$this->query->expects($this->at($this->queryAt))
$this->statement->expects($this->at($this->queryAt))
->method('bindValue')
->with($this->equalTo($key),
$this->equalTo($argument),
Expand All @@ -152,7 +155,7 @@ function () use ($iterators, $fetchAt) {
$index = 1;
foreach ($arguments as $argument) {
$pdoConstant = $this->getPDOType($argument);
$this->query->expects($this->at($this->queryAt))
$this->statement->expects($this->at($this->queryAt))
->method('bindValue')
->with($this->equalTo($index),
$this->equalTo($argument),
Expand All @@ -162,9 +165,10 @@ function () use ($iterators, $fetchAt) {
}
}

$this->query->expects($this->at($this->queryAt))
$this->statement->expects($this->at($this->queryAt))
->method('execute')
->willReturnCallback(function ($sql, $p = null, $o = null, $s = null) {
return $this->createMock(IResult::class);
});
$this->queryAt++;

Expand All @@ -175,7 +179,7 @@ function () use ($iterators, $fetchAt) {
} else {
$closing = $this->any();
}
$this->query->expects($closing)->method('closeCursor');
$this->statement->expects($closing)->method('closeCursor');
$this->queryAt++;

$this->prepareAt++;
Expand Down

0 comments on commit 8c54700

Please sign in to comment.