mirror of
https://github.com/danog/postgres.git
synced 2024-12-11 17:09:47 +01:00
fac9041cac
Changed to match code styles used in other Amp packages.
38 lines
1.0 KiB
PHP
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);
|
|
}
|
|
}
|