public function testIsTest()
 {
     // arrange
     $env = 'frontend-test';
     // act
     $result = is_test($env);
     // assert
     $this->assertEquals(true, $result);
 }
Example #2
0
/**
 * runs all defined tests
 * if tests directory contains coverage folder, it will generate coverage results there
 */
function run_tests()
{
    global $argv;
    // read test directory and run all tests
    $path = dirname(__FILE__) . '/tests';
    $dir = dir($path);
    $lime_output = new lime_output();
    $coverage = $coveragePath = '';
    $tests = array();
    while (($entry = $dir->read()) !== false) {
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        if (is_dir("{$path}/{$entry}")) {
            if ($entry == 'coverage') {
                $coveragePath = $path . '/' . $entry;
            }
            continue;
        }
        if (is_test($entry)) {
            $tests[getTestNameByPath("{$path}/{$entry}")] = "{$path}/{$entry}";
        }
    }
    // run concrete test
    if (($testName = $argv[1]) && can_param_be_test($testName)) {
        $testName .= 'Test';
        if (!array_key_exists($testName, $tests)) {
            $lime_output->error("cannot find test " . $argv[1] . ' in ' . $path);
            return;
        }
        if ($coveragePath) {
            $coveragePathConcrete = $coveragePath . '/' . $testName;
            LBoxUtil::createDirByPath($coveragePathConcrete);
            $coverage = '--coverage-html ' . $coveragePathConcrete . ' ';
            //$coverage			.=	' --coverage-clover '. $coveragePathConcrete . '/clover.xml ';
        }
        $path = $tests[$testName];
        $call = "phpunit {$coverage} {$path}";
        //$lime_output->info($call);
        $out = getCallReturn($call);
        if (preg_match('/OK \\((\\d+) test(s?)\\, (\\d+) assertion(s?)\\)/', $out, $matchAll)) {
            $lime_output->green_bar($testName);
        } else {
            $lime_output->red_bar($testName);
        }
        echo $out;
        if (strlen($coverage) > 0) {
            if (!doesContainErrorNotification($out)) {
                $lime_output->info("coverage results in {$coveragePath}");
            }
        }
        return;
    }
    // run all loaded tests
    if (count($tests) < 1) {
        $lime_output->comment('no test found in ' . $path);
        return;
    }
    $assertionsCountAtomic = 0;
    $testsCountAtomic = 0;
    foreach ($tests as $name => $path) {
        if ($coveragePath) {
            $coveragePathConcrete = $coveragePath . '/' . $name;
            LBoxUtil::createDirByPath($coveragePathConcrete);
            $coverage = '--coverage-html ' . $coveragePathConcrete . ' ';
            //$coverage			.=	' --coverage-clover '. $coveragePathConcrete . '/clover.xml ';
        }
        $call = "phpunit {$coverage} {$path}";
        //$lime_output->info($call);
        $out = getCallReturn($call);
        $space = '';
        if (preg_match('/OK \\((\\d+) test(s?)\\, (\\d+) assertion(s?)\\)/', $out, $matchAll)) {
            $i = 1;
            foreach ($matchAll as $k => $v) {
                if (is_numeric($v)) {
                    $match[$i] = $v;
                    $i++;
                }
            }
            $assertionsCountAtomic += $match[2];
            $testsCountAtomic += $match[1];
            $outPartName = $name . ' (' . $match[1] . ' tests, ' . $match[2] . ' assertions)';
            for ($i = 0; $i < 68 - strlen($outPartName); $i++) {
                $space .= ' ';
            }
            $lime_output->green_bar($outPartName . $space . 'OK ');
        } else {
            for ($i = 0; $i < 64 - strlen($name); $i++) {
                $space .= ' ';
            }
            $lime_output->red_bar($name . $space . 'FAILED ');
            echo $out;
        }
    }
    $lime_output->echoln("{$testsCountAtomic} tests, {$assertionsCountAtomic} assertions done", array('fg' => 'green'));
    if (strlen($coverage) > 0) {
        if (!doesContainErrorNotification($out)) {
            $lime_output->info("coverage results in {$coveragePath}");
        }
    }
    $dir->close();
}
function cw_payment_cc_is_solo($num)
{
    $rules = array("633450,633453,16,0", "633454,633457,16,0", "633458,633460,16,0", "633461,633461,18,1", "633462,633472,16,0", "633473,633473,18,1", "633474,633475,16,0", "633476,633476,19,1", "633477,633477,16,0", "633478,633478,18,1", "633479,633480,16,0", "633481,633481,19,1", "633482,633489,16,0", "633490,633493,16,1", "633494,633494,18,1", "633495,633497,16,2", "633498,633498,19,1", "633499,633499,18,1", "676700,676700,16,0", "676701,676701,19,1", "676702,676702,16,0", "676703,676703,18,1", "676704,676704,16,0", "676705,676705,19,1", "676706,676707,16,2", "676708,676711,16,0", "676712,676715,16,0", "676716,676717,16,0", "676718,676718,19,1", "676719,676739,16,0", "676740,676740,18,1", "676741,676749,16,0", "676750,676762,19,1", "676763,676769,16,0", "676770,676770,19,1", "676771,676773,16,0", "676774,676774,18,1", "676775,676778,16,0", "676779,676779,18,1", "676780,676781,16,0", "676782,676782,18,1", "676783,676794,16,0", "676795,676795,18,1", "676796,676797,16,0", "676798,676798,19,1", "676799,676799,16,0");
    return is_test($num, $rules);
}