-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ecb548
commit e7097c2
Showing
12 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
## JavaScript API | ||
|
||
See documentation here [EN](https://comet-server.com/wiki/doku.php/en:comet:javascript_api#javascript_api) [RU](https://comet-server.com/wiki/doku.php/comet:javascript_api#javascript_api) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
## Calculate coverage | ||
|
||
Scripts for calculate coverage in tests |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Automatic tests | ||
|
||
Automatic tests for CometQL api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
// More info about CppComet http://comet-server.org/doku.php/en | ||
// More info about CometQL http://comet-server.org/doku.php/en:comet:cometql | ||
// More info about auth in CppComet http://comet-server.org/doku.php/en:comet:authentication | ||
|
||
header('Content-Type: text/html; charset=utf-8'); | ||
header("Access-Control-Allow-Origin: *"); | ||
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS') | ||
{ | ||
exit(); | ||
} | ||
|
||
ini_set('display_errors','on'); | ||
error_reporting (E_ALL); | ||
session_start(); | ||
|
||
include './utils/timetest.php'; | ||
include './utils/testClass.php'; | ||
|
||
$count = 100; | ||
if(isset($_GET['count'])) | ||
{ | ||
$count = $_GET['count']; | ||
if($count > 100) | ||
{ | ||
return "-1"; | ||
} | ||
} | ||
|
||
$test = preg_replace("#[^A-z0-9\_\-]#usi", "", $_GET['test']); | ||
if(!file_exists("./tests/".$test.".php")) | ||
{ | ||
return "-1"; | ||
} | ||
|
||
include "./tests/".$test.".php"; | ||
|
||
// We connect to the comet server with login and password for the access demo (you can get your data for connection after registration at comet-server.com) | ||
// Login 15 | ||
// Password lPXBFPqNg3f661JcegBY0N0dPXqUBdHXqj2cHf04PZgLHxT6z55e20ozojvMRvB8 | ||
// CometQL_v1 database | ||
$cppTest->init([ | ||
"host" => "app.comet-server.ru", | ||
"user" => "15", | ||
"password" => "lPXBFPqNg3f661JcegBY0N0dPXqUBdHXqj2cHf04PZgLHxT6z55e20ozojvMRvB8", | ||
"api_version" => "CometQL_v1" | ||
]); | ||
|
||
|
||
$cppTest->start(); | ||
timeTest::test('cpp', 'test'); | ||
for($i =0; $i<$count; $i++) | ||
{ | ||
$cppTest->test(); | ||
} | ||
$t = timeTest::test('cpp','test'); | ||
$t = $t[count($t) - 1]; | ||
|
||
$cppTest->stop(); | ||
|
||
echo json_encode([ | ||
'count' => $count, | ||
'test' => $test, | ||
'time' => $t['time'] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
class test_mysqli_connect extends testClass{ | ||
|
||
function test() | ||
{ | ||
$l = mysqli_connect($this->opt['host'], $this->opt['user'], $this->opt['password'], $this->opt['api_version']); | ||
echo mysqli_error($l)."\n"; | ||
mysqli_close($l); | ||
} | ||
} | ||
|
||
$cppTest = new test_mysqli_connect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
|
||
class users_auth_insert extends testClass{ | ||
|
||
public $count = 0; | ||
|
||
function test() | ||
{ | ||
$this->count++; | ||
$query = "INSERT INTO users_auth (id, hash )VALUES (".$this->count.", 'hash".$this->count."');"; | ||
mysqli_query($this->link, $query); | ||
} | ||
} | ||
|
||
$cppTest = new users_auth_insert(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
class testClass{ | ||
|
||
public $link; | ||
public $opt; | ||
|
||
function init($opt){ | ||
$this->opt = $opt; | ||
} | ||
|
||
function start() | ||
{ | ||
$this->link = mysqli_connect( | ||
$this->opt['host'], | ||
$this->opt['user'], | ||
$this->opt['password'], | ||
$this->opt['api_version']); | ||
if(!$this->link || mysqli_errno($this->link)) | ||
{ | ||
echo "Error:". mysqli_error($this->link); | ||
exit(); | ||
} | ||
} | ||
|
||
function test(){ | ||
|
||
} | ||
|
||
function stop() | ||
{ | ||
mysqli_close($this->link); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
class timeTest{ | ||
|
||
public static $timeTestArray = array(); | ||
public static function test($group, $name = '') | ||
{ | ||
if(!isset(self::$timeTestArray[$group])) | ||
{ | ||
self::$timeTestArray[$group] = array(); | ||
self::$timeTestArray[$group][] = array("now" =>microtime(true), "name" => $name, "delta" => 0, "time" => 0 ); | ||
return self::$timeTestArray[$group]; | ||
} | ||
|
||
self::$timeTestArray[$group][] = array( | ||
"now" =>microtime(true), | ||
"name" => $name, | ||
"time" => microtime(true) - self::$timeTestArray[$group][0]["now"], // Общее время на группу | ||
"delta" => microtime(true) - self::$timeTestArray[$group][count(self::$timeTestArray[$group])-1]["now"] // Время на последнеею операцию | ||
); | ||
return self::$timeTestArray[$group]; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.