Example #1
0
 public function testConnectionDisconnectAfterFailedQuery()
 {
     $conn = new Connection(["user" => $this->getDbUser(), "database" => $this::getDbName(), "auto_disconnect" => true], $this->getLoop());
     $hello = null;
     $conn->query("Some bad query")->subscribe(new CallbackObserver(function ($x) {
         echo "next\n";
         $this->fail('Should not get any items');
     }, function (\Exception $e) use(&$hello) {
         $hello = "Hello";
         $this->getLoop()->addTimer(0.1, function () {
             $this->stopLoop();
         });
     }, function () {
         echo "complete\n";
         $this->fail('Should not complete');
     }));
     $this->runLoopWithTimeout(2);
     $this->assertEquals('Hello', $hello);
     $this->assertEquals(Connection::CONNECTION_CLOSED, $conn->getConnectionStatus());
 }