/** * see https://github.com/voryx/PgAsync/issues/10 */ public function testBoolParam() { $client = new Client(["user" => $this::getDbUser(), "database" => $this::getDbName()]); $args = [false, 1]; $upd = 'UPDATE test_bool_param SET b = $1 WHERE id = $2 RETURNING *'; $completes = false; $client->executeStatement($upd, $args)->subscribe(new \Rx\Observer\CallbackObserver(function ($row) { $this->assertEquals($row, ['id' => '1', 'b' => false]); }, function ($e) use($client) { $client->closeNow(); $this->cancelCurrentTimeoutTimer(); throw $e; }, function () use(&$completes, $client) { $completes = true; $client->closeNow(); $this->cancelCurrentTimeoutTimer(); })); $this->runLoopWithTimeout(2); $this->assertTrue($completes); }
public function testAutoDisconnect() { $client = new Client(["user" => $this->getDbUser(), "database" => $this::getDbName(), "auto_disconnect" => true], $this->getLoop()); $hello = null; $client->executeStatement("SELECT 'Hello' AS Hello")->subscribe(new CallbackObserver(function ($x) use(&$hello) { $this->assertNull($hello); $hello = $x; }, function ($e) { $this->fail("Got an error"); $this->cancelCurrentTimeoutTimer(); $this->stopLoop(); }, function () { // wait a bit for things to close down $this->getLoop()->addTimer(0.1, function () { $this->cancelCurrentTimeoutTimer(); }); })); $this->runLoopWithTimeout(2); $this->assertEquals(0, $client->getConnectionCount()); $this->assertEquals(['hello' => 'Hello'], $hello); }