1
0
mirror of https://github.com/danog/postgres.git synced 2025-01-08 14:08:29 +01:00
postgres/test/ConnectionPoolTest.php
2016-12-29 23:21:17 -06:00

30 lines
793 B
PHP

<?php
namespace Amp\Postgres\Test;
use Amp\Postgres\ConnectionPool;
use Amp\Success;
use Interop\Async\Promise;
class ConnectionPoolTest extends AbstractPoolTest {
/**
* @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): Promise {
static $count = 0;
return new Success($connections[$count++]);
}));
return $mock;
}
}