-
-
Notifications
You must be signed in to change notification settings - Fork 319
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
Showing
5 changed files
with
155 additions
and
2 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
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,63 @@ | ||
--TEST-- | ||
Check for yar server __info (public visiblity) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("yar")) { | ||
print "skip"; | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
include "yar.inc"; | ||
|
||
yar_server_start(<<<'PHP' | ||
<?php | ||
error_reporting(-1); | ||
class Service_Provider { | ||
public function __info($markup) { | ||
return ""; | ||
} | ||
} | ||
$yar = new Yar_Server(new Service_Provider()); | ||
$yar->handle(); | ||
PHP | ||
); | ||
|
||
$host = YAR_API_HOSTNAME; | ||
$port = YAR_API_PORT; | ||
|
||
if (!$port) { | ||
$port = 80; | ||
} | ||
|
||
$fp = fsockopen($host, $port, $errno, $errstr, 0.5); | ||
if (!$fp) { | ||
die("connect failed"); | ||
} | ||
|
||
$uri = YAR_API_URI; | ||
|
||
if(fwrite($fp, <<<HEADER | ||
GET /{$uri} HTTP/1.1 | ||
Host: {$host} | ||
HEADER | ||
)) { | ||
while (!feof($fp)) { | ||
$line = trim(fgets($fp)); | ||
if (strpos($line, 'Service_Provider - Yar Server') != FALSE) { | ||
echo "okay"; | ||
break; | ||
} | ||
} | ||
} | ||
?> | ||
--CLEAN-- | ||
<?php | ||
include 'yar.inc'; | ||
yar_server_cleanup(); | ||
?> | ||
--EXPECT-- | ||
okay |
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,40 @@ | ||
--TEST-- | ||
Check for yar server __auth (public visiblity) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("yar")) { | ||
print "skip"; | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
include "yar.inc"; | ||
|
||
yar_server_start(<<<'PHP' | ||
<?php | ||
error_reporting(-1); | ||
class Service_Provider { | ||
public function __auth($provider, $token) { | ||
return false; | ||
} | ||
public function info() { | ||
return "okay"; | ||
} | ||
} | ||
$yar = new Yar_Server(new Service_Provider()); | ||
$yar->handle(); | ||
PHP | ||
); | ||
|
||
$client = new Yar_Client(YAR_API_ADDRESS); | ||
echo $client->info(); | ||
?> | ||
--CLEAN-- | ||
<?php | ||
include 'yar.inc'; | ||
yar_server_cleanup(); | ||
?> | ||
--EXPECT-- | ||
okay |
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,47 @@ | ||
--TEST-- | ||
Check for yar server __auth (concurrent call) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("yar")) { | ||
print "skip"; | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
include "yar.inc"; | ||
|
||
yar_server_start(<<<'PHP' | ||
<?php | ||
error_reporting(-1); | ||
class Service_Provider { | ||
protected function __auth($provider, $token) { | ||
return ($provider == "Yar" && $token == md5("yar")); | ||
} | ||
public function info() { | ||
return "okay"; | ||
} | ||
} | ||
$yar = new Yar_Server(new Service_Provider()); | ||
$yar->handle(); | ||
PHP | ||
); | ||
|
||
Yar_Concurrent_Client::call(YAR_API_ADDRESS, "info", array(), NULL, NULL, array(YAR_OPT_PROVIDER=>"Yar", YAR_OPT_TOKEN=>md5("yar"))); | ||
Yar_Concurrent_Client::call(YAR_API_ADDRESS, "info", array(), NULL, NULL, array(YAR_OPT_PROVIDER=>"Yar", YAR_OPT_TOKEN=>md5("yar"))); | ||
Yar_Concurrent_Client::call(YAR_API_ADDRESS, "info", array(), NULL, NULL, array(YAR_OPT_PROVIDER=>"Yar", YAR_OPT_TOKEN=>md5("yar"))); | ||
Yar_Concurrent_Client::call(YAR_API_ADDRESS, "info", array(), NULL, NULL, array(YAR_OPT_PROVIDER=>"Yar", YAR_OPT_TOKEN=>md5("yar"))); | ||
Yar_Concurrent_Client::call(YAR_API_ADDRESS, "info", array(), NULL, NULL, array(YAR_OPT_PROVIDER=>"Yar", YAR_OPT_TOKEN=>md5("yar"))); | ||
|
||
Yar_Concurrent_Client::loop(function($return, $callinfo) { | ||
echo $return; | ||
}); | ||
?> | ||
--CLEAN-- | ||
<?php | ||
include 'yar.inc'; | ||
yar_server_cleanup(); | ||
?> | ||
--EXPECT-- | ||
okayokayokayokayokay |
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