Example #1
1
 private function startDynamoJar()
 {
     $javaCmd = "java -Djava.library.path={$this->libPath} " . "-jar {$this->jarPath} -sharedDb -inMemory -port {$this->port}";
     $this->process = new BackgroundProcess($javaCmd);
     $this->process->run();
     if (!$this->process->isRunning()) {
         throw new \RuntimeException("Unable to start local dynamodb");
     }
 }
 public function testStuff()
 {
     $server = new BackgroundProcess("node tests/node/server.js");
     $serverLog = tempnam('/tmp', 'process');
     $client = new BackgroundProcess("node tests/node/client.js");
     $clientLog = tempnam('/tmp', 'process');
     $redisCli = new BackgroundProcess("redis-cli MONITOR");
     $redisLog = tempnam('/tmp', 'process');
     $redisCli->run($redisLog);
     sleep(1);
     $server->run($serverLog);
     sleep(2);
     $client->run($clientLog);
     sleep(2);
     $emitter = new \Will1471\SocketIoEmitter\Emitter(new \Will1471\SocketIoEmitter\PredisAdapter(new \Predis\Client()), new \Will1471\SocketIoEmitter\MsgpackAdapter());
     $emitter->to('room1')->emit('event1', ['foo' => 'bar']);
     $emitter->to('room2')->to('room3')->emit('event2', ['a' => '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890']);
     sleep(2);
     $client->stop();
     $server->stop();
     $redisCli->stop();
     var_dump(file_get_contents($serverLog));
     var_dump(file_get_contents($clientLog));
     var_dump(file_get_contents($redisLog));
     unlink($serverLog);
     unlink($clientLog);
     unlink($redisLog);
 }
Example #3
0
 /**
  * Test Subscription command.
  *
  * @return void
  */
 public function testSubscription()
 {
     $callback = function ($message) {
         $this->assertNotNull($message);
         $this->assertEquals($message, 'bar');
     };
     $this->c->subscribe('foo', $callback);
     $this->assertGreaterThan(0, $this->c->subscriptionsCount());
     $subscriptions = $this->c->getSubscriptions();
     $this->assertInternalType('array', $subscriptions);
     $this->c->publish('foo', 'bar');
     $this->assertEquals(1, $this->c->pubsCount());
     $process = new BackgroundProcess('/usr/bin/php ./tests/Util/ClientServerStub.php ');
     $process->run();
     // time_nanosleep(1, 0);
     $this->c->wait(1);
 }
 public function getPid()
 {
     return trim(preg_replace('/\\s+/', '', parent::getPid()));
     // The original object failed to chomp() the pid info ("99999\n"). This override fixes that.
 }
 public function stop()
 {
     if ($this->process && $this->process->isRunning()) {
         $this->process->stop();
     }
 }
Example #6
-1
 public function testFitsRuns()
 {
     $this->assertFileExists($this->path_to_fits);
     $this->assertFileExists($this->path_to_dummy_file);
     $cmd = $this->path_to_fits . " -i " . $this->path_to_dummy_file . " -xc -o " . $this->path_to_fits_output;
     $process = new BackgroundProcess($cmd);
     $process->run();
     sleep(10);
     $this->assertFileExists($this->path_to_fits_output);
 }