Beispiel #1
0
/**
 ** We keep our failed tests so that they can be rerun.
 **        This function does that retesting.
 */
function rerunPreviousTests()
{
    print "Retesting previously found problems.\n";
    $dir_contents = scandir(DIRECTORY);
    // sort file into the order a normal person would use.
    natsort($dir_contents);
    foreach ($dir_contents as $file) {
        // if file is not a test, then skip it.
        // Note we need to escape any periods or will be treated as "any character".
        $matches = array();
        if (!ereg("(.*)" . str_replace(".", "\\.", DATA_FILE) . "\$", $file, $matches)) {
            continue;
        }
        // reload the test.
        $full_path = DIRECTORY . "/" . $file;
        $test = unserialize(file_get_contents($full_path));
        // if this is not a valid test, then skip it.
        if (!$test instanceof pageTest) {
            print "\nSkipping invalid test - {$full_path}";
            continue;
        }
        // The date format is in Apache log format, which makes it easier to locate
        // which retest caused which error in the Apache logs (only happens usually if
        // apache segfaults).
        if (!QUIET) {
            print "[" . date("D M d H:i:s Y") . "] Retesting {$file} (" . get_class($test) . ")";
        }
        // run test
        $testname = $matches[1];
        $valid = runWikiTest($test, $testname, true);
        if (!$valid) {
            saveTest($test, $testname);
            if (QUIET) {
                print "\nTest: " . get_class($test) . " ; Testname: {$testname}\n------";
            } else {
                print "\n";
            }
        } else {
            if (!QUIET) {
                print "\r";
            }
            if (DELETE_PASSED_RETESTS) {
                $prefix = DIRECTORY . "/" . $testname;
                if (is_file($prefix . DATA_FILE)) {
                    unlink($prefix . DATA_FILE);
                }
                if (is_file($prefix . PHP_TEST)) {
                    unlink($prefix . PHP_TEST);
                }
                if (is_file($prefix . CURL_TEST)) {
                    unlink($prefix . CURL_TEST);
                }
                if (is_file($prefix . INFO_FILE)) {
                    unlink($prefix . INFO_FILE);
                }
            }
        }
    }
    print "\nDone retesting.\n";
}
Beispiel #2
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
include_once dirname(__DIR__) . '/vendor/autoload.php';
@($cat = new \Animals\Cat());
printf("Name is currently %s\n", $cat->getName());
$cat->setName("Garfield");
printf("Name has been changed to %s\n", $cat->getName());
$cat->speak();
echo PHP_EOL;
$cat->speak('brrrr');
echo PHP_EOL;
@($dog = new \Animals\Dog());
printf("Name is currently %s\n", $dog->getName());
$dog->setName("Odie");
printf("Name has been changed to %s\n", $dog->getName());
$dog->speak();
echo PHP_EOL;
include 'petShop.php';
saveTest();
savePetShop();
logStats();
logStats('we are done');