Snippet Information
Version: 11 (see latest version)
Author: jeff
Language: php
Licensed under MIT
Other versions
Snippets included by
test_suite v.11
Snippets that include
test_suite v.11
None
"test_suite" v.11 (see latest version)
Description
Test a URL for a particular string to test uptime.
Run
| View code [+] |
Create a snippet based on this »
<h1>Kogbox Test Suite</h1>
<p>Test URLs for a particular string to confirm uptime.</p>
<?php
include_snippet(1,"curl_pure_function");
include_snippet(1,"spyc_yaml");
$test_yaml = "-
title: first_test
url: http://www.google.com
match: google.com
-
title: second_test
url: http://www.google.com
match: blabla.com";
function test_for_string($name,$match) {
//$target = getUrlText($_REQUEST['url']);
//$match = $_REQUEST['match'];
if (preg_match("/".$match."/", $target, $out)) {
$color = "green";
$status = "passed";
} else {
$color = "red";
$status = "failed";
}
echo "<p style='font-weight:bold;background:".$color."'>Test '".$name."': ".$status."</p>";
}
$tests = Spyc::YAMLLoad($test_yaml);
foreach ($tests as $test) {
test_for_string($test['name'],$test['url']);
}
?>

Comments (0) | View comments for all versions (2)
Log in if you have a Kogbox account.