1
0
mirror of https://github.com/danog/postgres.git synced 2024-11-27 04:24:45 +01:00
postgres/test/ConnectionPoolTest.php
2017-05-17 18:14:12 +02:00

29 lines
779 B
PHP

<?php
namespace Amp\Postgres\Test;
use Amp\{ Promise, Success };
use Amp\Postgres\ConnectionPool;
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;
}
}