generate() abstract public method

abstract public generate ( )
コード例 #1
0
ファイル: Command.php プロジェクト: dalinhuang/shopexts
 /**
  * @access public
  * @static
  */
 public static function main()
 {
     $arguments = self::handleArguments();
     $runner = new PHPUnit_TextUI_TestRunner();
     $suite = $runner->getTest($arguments['test'], $arguments['testFile'], $arguments['syntaxCheck']);
     if ($suite->testAt(0) instanceof PHPUnit_Framework_Warning && strpos($suite->testAt(0)->getMessage(), 'No tests found in class') !== FALSE) {
         $skeleton = new PHPUnit_Util_Skeleton($arguments['test'], $arguments['testFile']);
         $result = $skeleton->generate(TRUE);
         if (!$result['incomplete']) {
             eval(str_replace(array('<?php', '?>'), '', $result['code']));
             $suite = new PHPUnit_Framework_TestSuite($arguments['test'] . 'Test');
         }
     }
     try {
         $result = $runner->doRun($suite, $arguments);
     } catch (Exception $e) {
         throw new RuntimeException('Could not create and run test suite: ' . $e->getMessage());
     }
     if ($result->wasSuccessful()) {
         exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
     } else {
         if ($result->errorCount() > 0) {
             exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
         } else {
             exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
         }
     }
 }
コード例 #2
0
ファイル: codegen.php プロジェクト: swat30/safeballot
        $smarty->assign('table', @$_REQUEST['table']);
        $smarty->assign('primary_key', $priKey);
        $php = $smarty->fetch('codegen.tpl');
        echo '<div style="background-color: #fff; border-left: 2px solid #000; padding-left: 10px; position: absolute; top: 5px; left: 500px;">';
        echo '<h1>Class Code <a href="#" onclick="new Effect.toggle(\'code\'); return false;">[+]</a></h1>';
        $testcode = str_replace(array('<?php', '?>'), '', $php);
        $testcode = str_replace('<', '&lt;', $testcode);
        $testcode = str_replace('>', '&gt;', $testcode);
        echo '<pre id="code">' . $testcode . "</pre>";
        $tmpfname = tempnam("/tmp", "FOO");
        $handle = fopen($tmpfname, "w");
        fwrite($handle, '<?php' . "\n\n" . $smarty->fetch('codegen.tpl') . "\n\n" . '?>');
        require_once 'PHPUnit/Util/Skeleton.php';
        $skeleton = new PHPUnit_Util_Skeleton($_REQUEST['class_name'], $tmpfname);
        echo '<h1>Test Code <a href="#" onclick="new Effect.Appear(\'test\'); return false;">[+]</a></h1>';
        $testcode = str_replace(array('<?php', '?>'), '', $skeleton->generate());
        $testcode = str_replace('<', '&lt;', $testcode);
        $testcode = str_replace('>', '&gt;', $testcode);
        echo '<pre id="test" style="display: none;">' . $testcode . "</pre>";
        echo '</div>';
        var_dump($_REQUEST);
    }
}
echo '</body>';
echo '</html>';
/*
$sql = 'describe address';
$r = Database::singleton()->query_fetch_all($sql);
var_dump($r);