Example #1
0
 function testVirtualConnection()
 {
     $complete = false;
     \Amp\reactor(\Amp\driver());
     \Amp\run(function () use(&$complete) {
         $db = new Pool("host=" . DB_HOST . ";user="******";pass="******";db=connectiontest");
         /* Multiple queries one after the other must be hold back and dispatched to new connections */
         for ($i = 0; $i < 5; $i++) {
             $pings[] = $db->ping();
         }
         (yield \Amp\all($pings));
         $complete = true;
     });
     $this->assertEquals(true, $complete, "Database commands did not complete.");
 }
Example #2
0
 protected function doStart(Console $console) : \Generator
 {
     // Shutdown the whole server in case we needed to stop during startup
     register_shutdown_function(function () use($console) {
         if (!$this->server) {
             // ensure a clean reactor for clean shutdown
             $reactor = \Amp\reactor();
             \Amp\reactor(\Amp\driver());
             \Amp\wait((new CommandClient((string) $console->getArg("config")))->stop());
             \Amp\reactor($reactor);
         }
     });
     $server = (yield from $this->bootstrapper->boot($this->logger, $console));
     (yield $server->start());
     $this->server = $server;
     \Amp\onReadable($this->ipcSock, function ($watcherId) {
         \Amp\cancel($watcherId);
         yield from $this->stop();
     });
 }
Example #3
0
 function testPreparedWithNegativeValue()
 {
     \Amp\reactor(\Amp\driver());
     \Amp\run(function () {
         $db = new Connection("host=" . DB_HOST . ";user="******";pass="******";db=connectiontest");
         $db->connect();
         $db->query("DROP TABLE tmp");
         // just in case it would exist...
         (yield $db->prepare("CREATE TABLE tmp SELECT ? AS a", [-1]));
         $result = (yield $db->prepare("SELECT a FROM tmp", []));
         $this->assertEquals((yield $result->fetchRow()), [-1]);
     });
 }