Example #1
0
 public function testRunMaxSeconds()
 {
     $client = new Client();
     $client->connect();
     $s = microtime(true);
     $client->run(1.0);
     $e = microtime(true);
     $this->assertLessThan(2.0, $e - $s);
 }
Example #2
0
 /**
  * @return array
  */
 public function run()
 {
     $this->results = [];
     foreach ($this->tests as $test) {
         $resultId = $this->client->run($test->test_id);
         $this->output($test->name . ' ');
         for ($i = 0; $i <= 20; $i++) {
             $result = $this->client->result($test->test_id, $resultId);
             if ($result->status === 'ready') {
                 $this->results[] = $result;
                 break;
             }
             $this->output('.');
             sleep(10);
         }
         $this->output(PHP_EOL);
     }
     return $this->results;
 }
Example #3
0
 public function testClose()
 {
     $c = new Client();
     $c->connect();
     $promise = $c->channel()->close();
     $this->assertInstanceOf("React\\Promise\\PromiseInterface", $promise);
     $promise->then(function () use($c) {
         $c->stop();
     });
     $c->run();
 }
Example #4
0
 public function testRun()
 {
     $client = new Client('test');
     $this->setExpectedException('Puppy\\Route\\RouteException', 'No route found for uri "/"');
     $client->run('/');
 }
Example #5
0
     * @param str $log 日志内容
     * @return
     */
    protected function addLog($log)
    {
        $log = date("Y-m-d H:i:s") . " {$log} \n";
        file_put_contents($this->logFilePath, $log, FILE_APPEND | LOCK_EX);
        echo date("Y-m-d H:i:s") . " {$log} \n";
    }
    protected function get_files_by_ext($path, $ext)
    {
        $files = array();
        if (is_dir($path)) {
            $handle = opendir($path);
            while ($file = readdir($handle)) {
                if ($file[0] == '.') {
                    continue;
                }
                if (is_file($path . $file) && preg_match('/\\.' . $ext . '$/', $file)) {
                    $files[] = $file;
                }
            }
            closedir($handle);
            sort($files);
        }
        return $files;
    }
}
$obj = new Client();
$obj->run();
Example #6
0
            $payloadLengthBin = str_split(sprintf('%016b', $payloadLength), 8);
            $frameHead[1] = $masked === true ? 254 : 126;
            $frameHead[2] = bindec($payloadLengthBin[0]);
            $frameHead[3] = bindec($payloadLengthBin[1]);
        } else {
            $frameHead[1] = $masked === true ? $payloadLength + 128 : $payloadLength;
        }
        // convert frame-head to string:
        foreach (array_keys($frameHead) as $i) {
            $frameHead[$i] = chr($frameHead[$i]);
        }
        if ($masked === true) {
            // generate a random mask:
            $mask = array();
            for ($i = 0; $i < 4; $i++) {
                $mask[$i] = chr(rand(0, 255));
            }
            $frameHead = array_merge($frameHead, $mask);
        }
        $frame = implode('', $frameHead);
        // append payload to frame:
        for ($i = 0; $i < $payloadLength; $i++) {
            $frame .= $masked === true ? $payload[$i] ^ $mask[$i % 4] : $payload[$i];
        }
        return $frame;
    }
}
$settings = array('host' => '0.0.0.0', 'port' => 10001, 'local' => 'http://liamka.me');
$Client = new Client($settings);
$Client->run();
Example #7
0
 public function testRun()
 {
     $client = new Client();
     $res = $client->run();
     $this->assertTrue($res);
 }