1
0
mirror of https://github.com/danog/postgres.git synced 2025-01-07 13:40:25 +01:00
postgres/test/ConnectionPoolTest.php

30 lines
824 B
PHP
Raw Normal View History

2016-09-14 16:27:39 +02:00
<?php declare(strict_types = 1);
namespace Amp\Postgres\Test;
use Amp\Postgres\ConnectionPool;
use Amp\Success;
use Interop\Async\Awaitable;
2016-09-20 07:47:16 +02:00
class ConnectionPoolTest extends AbstractPoolTest {
2016-09-14 16:27:39 +02:00
/**
* @param array $connections
*
* @return \Amp\Postgres\Pool
*/
protected function createPool(array $connections) {
$mock = $this->getMockBuilder(ConnectionPool::class)
->setConstructorArgs(['connection string', \count($connections)])
->setMethods(['createConnection'])
->getMock();
$mock->method('createConnection')
->will($this->returnCallback(function () use ($connections): Awaitable {
static $count = 0;
return new Success($connections[$count++]);
}));
return $mock;
}
}