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

29 lines
779 B
PHP
Raw Normal View History

2016-12-30 06:21:17 +01:00
<?php
2016-09-14 16:27:39 +02:00
namespace Amp\Postgres\Test;
2017-05-17 18:14:12 +02:00
use Amp\{ Promise, Success };
2016-09-14 16:27:39 +02:00
use Amp\Postgres\ConnectionPool;
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')
2016-11-15 18:06:21 +01:00
->will($this->returnCallback(function () use ($connections): Promise {
2016-09-14 16:27:39 +02:00
static $count = 0;
return new Success($connections[$count++]);
}));
return $mock;
}
}