1
0
mirror of https://github.com/danog/postgres.git synced 2024-12-11 17:09:47 +01:00
postgres/test/ConnectionPoolTest.php
Aaron Piotrowski fac9041cac
Update and fix code styles
Changed to match code styles used in other Amp packages.
2017-06-20 22:59:42 -05:00

38 lines
1.0 KiB
PHP

<?php
namespace Amp\Postgres\Test;
use Amp\Postgres\ConnectionPool;
use Amp\Promise;
use Amp\Success;
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;
}
/**
* @expectedException \Error
* @expectedExceptionMessage Pool must contain at least one connection
*/
public function testInvalidMaxConnections() {
$pool = new ConnectionPool('connection string', 0);
}
}