code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function __testObjectFilesFromGroupFile($groupFile, $isApp = true) {
$manager = CodeCoverageManager::getInstance();
$testManager =& new TestManager();
$path = TESTS;
if (!$isApp) {
$path = CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'tests';
}
if (!!$manager->pluginTest) {
$path = App::pluginPath($manager->pluginTest) . DS . 'tests';
}
$result = array();
if ($groupFile == 'all') {
$files = array_keys($testManager->getTestCaseList());
foreach ($files as $file) {
$file = str_replace(DS . 'tests' . DS . 'cases' . DS, DS, $file);
$file = str_replace('.test.php', '.php', $file);
$file = str_replace(DS . DS, DS, $file);
$result[] = $file;
}
} else {
$path .= DS . 'groups' . DS . $groupFile . $testManager->_groupExtension;
if (!file_exists($path)) {
trigger_error(__('This group file does not exist!', true));
return array();
}
$result = array();
$groupContent = file_get_contents($path);
$ds = '\s*\.\s*DS\s*\.\s*';
$pluginTest = 'APP\.\'plugins\'' . $ds . '\'' . $manager->pluginTest . '\'' . $ds . '\'tests\'' . $ds . '\'cases\'';
$pluginTest .= '|App::pluginPath\(\'' . $manager->pluginTest . '\'\)' . $ds . '\'tests\'' . $ds . '\'cases\'';
$pattern = '/\s*TestManager::addTestFile\(\s*\$this,\s*(' . $pluginTest . '|APP_TEST_CASES|CORE_TEST_CASES)' . $ds . '(.*?)\)/i';
preg_match_all($pattern, $groupContent, $matches);
foreach ($matches[2] as $file) {
$patterns = array(
'/\s*\.\s*DS\s*\.\s*/',
'/\s*APP_TEST_CASES\s*/',
'/\s*CORE_TEST_CASES\s*/',
);
$replacements = array(DS, '', '');
$file = preg_replace($patterns, $replacements, $file);
$file = str_replace("'", '', $file);
$result[] = $manager->__testObjectFileFromCaseFile($file, $isApp) . '.php';
}
}
return $result;
} | Returns an array of names of the test object files based on a given test group file name
@param array $files
@param string $isApp
@return array names of the test object files
@access private | __testObjectFilesFromGroupFile | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __getExecutableLines($content) {
if (is_array($content)) {
$manager =& CodeCoverageManager::getInstance();
$result = array();
foreach ($content as $file) {
$result[$file] = $manager->__getExecutableLines(file_get_contents($file));
}
return $result;
}
$content = h($content);
// arrays are 0-indexed, but we want 1-indexed stuff now as we are talking code lines mind you (**)
$content = "\n" . $content;
// // strip unwanted lines
$content = preg_replace_callback("/(@codeCoverageIgnoreStart.*?@codeCoverageIgnoreEnd)/is", array('CodeCoverageManager', '__replaceWithNewlines'), $content);
// strip php | ?\> tag only lines
$content = preg_replace('/[ |\t]*[<\?php|\?>]+[ |\t]*/', '', $content);
// strip lines that contain only braces and parenthesis
$content = preg_replace('/[ |\t]*[{|}|\(|\)]+[ |\t]*/', '', $content);
$result = explode("\n", $content);
// unset the zero line again to get the original line numbers, but starting at 1, see (**)
unset($result[0]);
return $result;
} | Parses a given code string into an array of lines and replaces some non-executable code lines with the needed
amount of new lines in order for the code line numbers to stay in sync
@param string $content
@return array array of lines
@access private | __getExecutableLines | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __replaceWithNewlines() {
$args = func_get_args();
$numLineBreaks = count(explode("\n", $args[0][0]));
return str_pad('', $numLineBreaks - 1, "\n");
} | Replaces a given arg with the number of newlines in it
@return string the number of newlines in a given arg
@access private | __replaceWithNewlines | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __paintHeader($lineCount, $coveredCount, $report) {
$manager =& CodeCoverageManager::getInstance();
$codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount);
return $report = '<h2>Code Coverage: ' . $codeCoverage . '%</h2>
<div class="code-coverage-results"><pre>' . $report . '</pre></div>';
} | Paints the headline for code coverage analysis
@param string $codeCoverage
@param string $report
@return void
@access private | __paintHeader | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __paintGroupResultHeader($report) {
return '<div class="code-coverage-results"><p class="note">Please keep in mind that the coverage can vary a little bit depending on how much the different tests in the group interfere. If for example, TEST A calls a line from TEST OBJECT B, the coverage for TEST OBJECT B will be a little greater than if you were running the corresponding test case for TEST OBJECT B alone.</p><pre>' . $report . '</pre></div>';
} | Displays a notification concerning group test results
@return void
@access public | __paintGroupResultHeader | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __paintGroupResultLine($file, $lineCount, $coveredCount) {
$manager =& CodeCoverageManager::getInstance();
$codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount);
$class = 'result-bad';
if ($codeCoverage > 50) {
$class = 'result-ok';
}
if ($codeCoverage > 80) {
$class = 'result-good';
}
return '<p>Code Coverage for ' . $file . ': <span class="' . $class . '">' . $codeCoverage . '%</span></p>';
} | Paints the headline for code coverage analysis
@param string $codeCoverage
@param string $report
@return void
@access private | __paintGroupResultLine | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __paintGroupResultLineCli($file, $lineCount, $coveredCount) {
$manager =& CodeCoverageManager::getInstance();
$codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount);
$class = 'bad';
if ($codeCoverage > 50) {
$class = 'ok';
}
if ($codeCoverage > 80) {
$class = 'good';
}
return "\n" . 'Code Coverage for ' . $file . ': ' . $codeCoverage . '% (' . $class . ')' . "\n";
} | Paints the headline for code coverage analysis
@param string $codeCoverage
@param string $report
@return void
@access private | __paintGroupResultLineCli | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __paintHeaderCli($lineCount, $coveredCount, $report) {
$manager =& CodeCoverageManager::getInstance();
$codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount);
$class = 'bad';
if ($codeCoverage > 50) {
$class = 'ok';
}
if ($codeCoverage > 80) {
$class = 'good';
}
return $report = "Code Coverage: $codeCoverage% ($class)\n";
} | Paints the headline for code coverage analysis in the CLI
@param string $codeCoverage
@param string $report
@return void
@access private | __paintHeaderCli | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __paintCodeline($class, $num, $line) {
$line = h($line);
if (trim($line) == '') {
$line = ' '; // Win IE fix
}
return '<div class="code-line ' . trim($class) . '"><span class="line-num">' . $num . '</span><span class="content">' . $line . '</span></div>';
} | Paints a code line for html output
@package default
@access private | __paintCodeline | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __calcCoverage($lineCount, $coveredCount) {
if ($coveredCount > $lineCount) {
trigger_error(__('Sorry, you cannot have more covered lines than total lines!', true));
}
return ($lineCount != 0)
? round(100 * $coveredCount / $lineCount, 2)
: '0.00';
} | Calculates the coverage percentage based on a line count and a covered line count
@param string $lineCount
@param string $coveredCount
@return void
@access private | __calcCoverage | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __getTestFilesPath($isApp = true) {
$manager = CodeCoverageManager::getInstance();
$path = ROOT . DS;
if ($isApp) {
$path .= APP_DIR . DS;
} elseif (!!$manager->pluginTest) {
$pluginPath = APP . 'plugins' . DS . $manager->pluginTest . DS;
$pluginPaths = App::path('plugins');
foreach ($pluginPaths as $tmpPath) {
$tmpPath = $tmpPath . $manager->pluginTest . DS;
if (file_exists($tmpPath)) {
$pluginPath = $tmpPath;
break;
}
}
$path = $pluginPath;
} else {
$path = TEST_CAKE_CORE_INCLUDE_PATH;
}
return $path;
} | Gets us the base path to look for the test files
@param string $isApp
@return void
@access public | __getTestFilesPath | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function __array_strpos($arr, $needle, $reverse = false) {
if (!is_array($arr) || empty($arr)) {
return false;
}
if ($reverse) {
$arr = array_reverse($arr, true);
}
foreach ($arr as $key => $val) {
if (strpos($val, $needle) !== false) {
return $key;
}
}
return false;
} | Finds the last element of an array that contains $needle in a strpos computation
@param array $arr
@param string $needle
@return void
@access private | __array_strpos | php | Datawalke/Coordino | cake/tests/lib/code_coverage_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/code_coverage_manager.php | MIT |
function TestManager() {
$this->_installSimpleTest();
if (isset($_GET['app'])) {
$this->appTest = true;
}
if (isset($_GET['plugin'])) {
$this->pluginTest = htmlentities($_GET['plugin']);
}
} | Constructor for the TestManager class
@return void
@access public | TestManager | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function _installSimpleTest() {
App::import('Vendor', array(
'simpletest' . DS . 'unit_tester',
'simpletest' . DS . 'mock_objects',
'simpletest' . DS . 'web_tester'
));
require_once(CAKE_TESTS_LIB . 'cake_web_test_case.php');
require_once(CAKE_TESTS_LIB . 'cake_test_case.php');
} | Includes the required simpletest files in order for the testsuite to run
@return void
@access public | _installSimpleTest | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function runAllTests(&$reporter, $testing = false) {
$testCases =& $this->_getTestFileList($this->_getTestsPath());
if ($this->appTest) {
$test =& new TestSuite(__('All App Tests', true));
} else if ($this->pluginTest) {
$test =& new TestSuite(sprintf(__('All %s Plugin Tests', true), Inflector::humanize($this->pluginTest)));
} else {
$test =& new TestSuite(__('All Core Tests', true));
}
if ($testing) {
return $testCases;
}
foreach ($testCases as $testCase) {
$test->addTestFile($testCase);
}
return $test->run($reporter);
} | Runs all tests in the Application depending on the current appTest setting
@param Object $reporter Reporter object for the tests being run.
@param boolean $testing Are tests supposed to be auto run. Set to true to return testcase list.
@return mixed
@access public | runAllTests | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function runTestCase($testCaseFile, &$reporter, $testing = false) {
$testCaseFileWithPath = $this->_getTestsPath() . DS . $testCaseFile;
if (!file_exists($testCaseFileWithPath) || strpos($testCaseFileWithPath, '..')) {
trigger_error(
sprintf(__("Test case %s cannot be found", true), htmlentities($testCaseFile)),
E_USER_ERROR
);
return false;
}
if ($testing) {
return true;
}
$test =& new TestSuite(sprintf(__('Individual test case: %s', true), $testCaseFile));
$test->addTestFile($testCaseFileWithPath);
return $test->run($reporter);
} | Runs a specific test case file
@param string $testCaseFile Filename of the test to be run.
@param Object $reporter Reporter instance to attach to the test case.
@param boolean $testing Set to true if testing, otherwise test case will be run.
@return mixed Result of test case being run.
@access public | runTestCase | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function runGroupTest($groupTestName, &$reporter) {
$filePath = $this->_getTestsPath('groups') . DS . strtolower($groupTestName) . $this->_groupExtension;
if (!file_exists($filePath) || strpos($filePath, '..')) {
trigger_error(sprintf(
__("Group test %s cannot be found at %s", true),
htmlentities($groupTestName),
htmlentities($filePath)
),
E_USER_ERROR
);
}
require_once $filePath;
$test =& new TestSuite(sprintf(__('%s group test', true), $groupTestName));
foreach ($this->_getGroupTestClassNames($filePath) as $groupTest) {
$testCase = new $groupTest();
$test->addTestCase($testCase);
if (isset($testCase->label)) {
$test->_label = $testCase->label;
}
}
return $test->run($reporter);
} | Runs a specific group test file
@param string $groupTestName GroupTest that you want to run.
@param Object $reporter Reporter instance to use with the group test being run.
@return mixed Results of group test being run.
@access public | runGroupTest | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function addTestCasesFromDirectory(&$groupTest, $directory = '.') {
$manager =& new TestManager();
$testCases =& $manager->_getTestFileList($directory);
foreach ($testCases as $testCase) {
$groupTest->addTestFile($testCase);
}
} | Adds all testcases in a given directory to a given GroupTest object
@param object $groupTest Instance of TestSuite/GroupTest that files are to be added to.
@param string $directory The directory to add tests from.
@return void
@access public
@static | addTestCasesFromDirectory | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function addTestFile(&$groupTest, $file) {
$manager =& new TestManager();
if (file_exists($file . $manager->_testExtension)) {
$file .= $manager->_testExtension;
} elseif (file_exists($file . $manager->_groupExtension)) {
$file .= $manager->_groupExtension;
}
$groupTest->addTestFile($file);
} | Adds a specific test file and thereby all of its test cases and group tests to a given group test file
@param object $groupTest Instance of TestSuite/GroupTest that a file should be added to.
@param string $file The file name, minus the suffix to add.
@return void
@access public
@static | addTestFile | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function &getTestCaseList() {
$manager =& new TestManager();
$return = $manager->_getTestCaseList($manager->_getTestsPath());
return $return;
} | Returns a list of test cases found in the current valid test case path
@access public
@static | getTestCaseList | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function &_getTestCaseList($directory = '.') {
$fileList =& $this->_getTestFileList($directory);
$testCases = array();
foreach ($fileList as $testCaseFile) {
$testCases[$testCaseFile] = str_replace($directory . DS, '', $testCaseFile);
}
return $testCases;
} | Builds the list of test cases from a given directory
@param string $directory Directory to get test case list from.
@access protected | _getTestCaseList | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function &_getTestFileList($directory = '.') {
$return = $this->_getRecursiveFileList($directory, array(&$this, '_isTestCaseFile'));
return $return;
} | Returns a list of test files from a given directory
@param string $directory Directory to get test case files from.
@access protected | _getTestFileList | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function &getGroupTestList() {
$manager =& new TestManager();
$return = $manager->_getTestGroupList($manager->_getTestsPath('groups'));
return $return;
} | Returns a list of group tests found in the current valid test case path
@access public
@static | getGroupTestList | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function &_getTestGroupFileList($directory = '.') {
$return = $this->_getRecursiveFileList($directory, array(&$this, '_isTestGroupFile'));
return $return;
} | Returns a list of group test files from a given directory
@param string $directory The directory to get group test files from.
@access protected | _getTestGroupFileList | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function &_getTestGroupList($directory = '.') {
$fileList =& $this->_getTestGroupFileList($directory);
$groupTests = array();
foreach ($fileList as $groupTestFile) {
$groupTests[$groupTestFile] = str_replace($this->_groupExtension, '', basename($groupTestFile));
}
sort($groupTests);
return $groupTests;
} | Returns a list of group test files from a given directory
@param string $directory The directory to get group tests from.
@access protected | _getTestGroupList | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function &_getGroupTestClassNames($groupTestFile) {
$file = implode("\n", file($groupTestFile));
preg_match("~lass\s+?(.*)\s+?extends TestSuite~", $file, $matches);
if (!empty($matches)) {
unset($matches[0]);
return $matches;
}
$matches = array();
return $matches;
} | Returns a list of class names from a group test file
@param string $groupTestFile The groupTest file to scan for TestSuite classnames.
@access protected | _getGroupTestClassNames | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function &_getRecursiveFileList($directory = '.', $fileTestFunction) {
$fileList = array();
if (!is_dir($directory)) {
return $fileList;
}
$files = glob($directory . DS . '*');
$files = $files ? $files : array();
foreach ($files as $file) {
if (is_dir($file)) {
$fileList = array_merge($fileList, $this->_getRecursiveFileList($file, $fileTestFunction));
} elseif ($fileTestFunction[0]->$fileTestFunction[1]($file)) {
$fileList[] = $file;
}
}
return $fileList;
} | Gets a recursive list of files from a given directory and matches then against
a given fileTestFunction, like isTestCaseFile()
@param string $directory The directory to scan for files.
@param mixed $fileTestFunction
@access protected | _getRecursiveFileList | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function _isTestCaseFile($file) {
return $this->_hasExpectedExtension($file, $this->_testExtension);
} | Tests if a file has the correct test case extension
@param string $file
@return boolean Whether $file is a test case.
@access protected | _isTestCaseFile | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function _isTestGroupFile($file) {
return $this->_hasExpectedExtension($file, $this->_groupExtension);
} | Tests if a file has the correct group test extension
@param string $file
@return boolean Whether $file is a group
@access protected | _isTestGroupFile | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function _hasExpectedExtension($file, $extension) {
return $extension == strtolower(substr($file, (0 - strlen($extension))));
} | Check if a file has a specific extension
@param string $file
@param string $extension
@return void
@access protected | _hasExpectedExtension | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function _getTestsPath($type = 'cases') {
if (!empty($this->appTest)) {
if ($type == 'cases') {
$result = APP_TEST_CASES;
} else if ($type == 'groups') {
$result = APP_TEST_GROUPS;
}
} else if (!empty($this->pluginTest)) {
$_pluginBasePath = APP . 'plugins' . DS . $this->pluginTest . DS . 'tests';
$pluginPath = App::pluginPath($this->pluginTest);
if (file_exists($pluginPath . DS . 'tests')) {
$_pluginBasePath = $pluginPath . DS . 'tests';
}
$result = $_pluginBasePath . DS . $type;
} else {
if ($type == 'cases') {
$result = CORE_TEST_CASES;
} else if ($type == 'groups') {
$result = CORE_TEST_GROUPS;
}
}
return $result;
} | Returns the given path to the test files depending on a given type of tests (cases, group, ..)
@param string $type either 'cases' or 'groups'
@return string The path tests are located on
@access protected | _getTestsPath | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function getExtension($type = 'test') {
if ($type == 'test' || $type == 'case') {
return $this->_testExtension;
}
return $this->_groupExtension;
} | Get the extension for either 'group' or 'test' types.
@param string $type Type of test to get, either 'test' or 'group'
@return string Extension suffix for test.
@access public | getExtension | php | Datawalke/Coordino | cake/tests/lib/test_manager.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/test_manager.php | MIT |
function CakeBaseReporter($charset = 'utf-8', $params = array()) {
$this->SimpleReporter();
if (!$charset) {
$charset = 'utf-8';
}
$this->_characterSet = $charset;
$this->params = $params;
} | Does nothing yet. The first output will
be sent on the first test start.
### Params
- show_passes - Should passes be shown
- plugin - Plugin test being run?
- app - App test being run.
- case - The case being run
- codeCoverage - Whether the case/group being run is being code covered.
@param string $charset The character set to output with. Defaults to UTF-8
@param array $params Array of request parameters the reporter should use. See above.
@access public | CakeBaseReporter | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_base_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_base_reporter.php | MIT |
function paintGroupStart($test_name, $size) {
if (empty($this->_timeStart)) {
$this->_timeStart = $this->_getTime();
}
parent::paintGroupStart($test_name, $size);
} | Signals / Paints the beginning of a TestSuite executing.
Starts the timer for the TestSuite execution time.
@param string $test_name Name of the test that is being run.
@param integer $size
@return void | paintGroupStart | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_base_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_base_reporter.php | MIT |
function paintGroupEnd($test_name) {
$this->_timeEnd = $this->_getTime();
$this->_timeDuration = $this->_timeEnd - $this->_timeStart;
parent::paintGroupEnd($test_name);
} | Signals/Paints the end of a TestSuite. All test cases have run
and timers are stopped.
@param string $test_name Name of the test that is being run.
@return void | paintGroupEnd | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_base_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_base_reporter.php | MIT |
function paintMethodStart($method) {
parent::paintMethodStart($method);
if (!empty($this->params['codeCoverage'])) {
CodeCoverageManager::start();
}
} | Paints the beginning of a test method being run. This is used
to start/resume the code coverage tool.
@param string $method The method name being run.
@return void | paintMethodStart | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_base_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_base_reporter.php | MIT |
function paintMethodEnd($method) {
parent::paintMethodEnd($method);
if (!empty($this->params['codeCoverage'])) {
CodeCoverageManager::stop();
}
} | Paints the end of a test method being run. This is used
to pause the collection of code coverage if its being used.
@param string $method The name of the method being run.
@return void | paintMethodEnd | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_base_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_base_reporter.php | MIT |
function _getTime() {
list($usec, $sec) = explode(' ', microtime());
return ((float)$sec + (float)$usec);
} | Get the current time in microseconds. Similar to getMicrotime in basics.php
but in a separate function to reduce dependancies.
@return float Time in microseconds
@access protected | _getTime | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_base_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_base_reporter.php | MIT |
function testCaseList() {
$testList = TestManager::getTestCaseList();
return $testList;
} | Retrieves a list of test cases from the active Manager class,
displaying it in the correct format for the reporter subclass
@return mixed | testCaseList | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_base_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_base_reporter.php | MIT |
function groupTestList() {
$testList = TestManager::getGroupTestList();
return $testList;
} | Retrieves a list of group test cases from the active Manager class
displaying it in the correct format for the reporter subclass.
@return void | groupTestList | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_base_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_base_reporter.php | MIT |
function baseUrl() {
if (!empty($_SERVER['PHP_SELF'])) {
return $_SERVER['PHP_SELF'];
}
return '';
} | Get the baseUrl if one is available.
@return string The base url for the request. | baseUrl | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_base_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_base_reporter.php | MIT |
function CakeCLIReporter($charset = 'utf-8', $params = array()) {
$this->CakeBaseReporter($charset, $params);
} | Constructor
@param string $separator
@param array $params
@return void | CakeCLIReporter | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_cli_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_cli_reporter.php | MIT |
function paintFail($message) {
parent::paintFail($message);
$message .= $this->_getBreadcrumb();
fwrite(STDERR, 'FAIL' . $this->separator . $message);
} | Paint fail faildetail to STDERR.
@param string $message Message of the fail.
@return void
@access public | paintFail | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_cli_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_cli_reporter.php | MIT |
function paintError($message) {
parent::paintError($message);
$message .= $this->_getBreadcrumb();
fwrite(STDERR, 'ERROR' . $this->separator . $message);
} | Paint PHP errors to STDERR.
@param string $message Message of the Error
@return void
@access public | paintError | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_cli_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_cli_reporter.php | MIT |
function paintException($exception) {
parent::paintException($exception);
$message = sprintf('Unexpected exception of type [%s] with message [%s] in [%s] line [%s]',
get_class($exception),
$exception->getMessage(),
$exception->getFile(),
$exception->getLine()
);
$message .= $this->_getBreadcrumb();
fwrite(STDERR, 'EXCEPTION' . $this->separator . $message);
} | Paint exception faildetail to STDERR.
@param object $exception Exception instance
@return void
@access public | paintException | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_cli_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_cli_reporter.php | MIT |
function _getBreadcrumb() {
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
$out = "\n\tin " . implode("\n\tin ", array_reverse($breadcrumb));
$out .= "\n\n";
return $out;
} | Get the breadcrumb trail for the current test method/case
@return string The string for the breadcrumb | _getBreadcrumb | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_cli_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_cli_reporter.php | MIT |
function paintSkip($message) {
parent::paintSkip($message);
fwrite(STDOUT, 'SKIP' . $this->separator . $message . "\n\n");
} | Paint a test skip message
@param string $message The message of the skip
@return void | paintSkip | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_cli_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_cli_reporter.php | MIT |
function paintFooter($test_name) {
$buffer = $this->getTestCaseProgress() . '/' . $this->getTestCaseCount() . ' test cases complete: ';
if (0 < ($this->getFailCount() + $this->getExceptionCount())) {
$buffer .= $this->getPassCount() . " passes";
if (0 < $this->getFailCount()) {
$buffer .= ", " . $this->getFailCount() . " fails";
}
if (0 < $this->getExceptionCount()) {
$buffer .= ", " . $this->getExceptionCount() . " exceptions";
}
$buffer .= ".\n";
$buffer .= $this->_timeStats();
fwrite(STDOUT, $buffer);
} else {
fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n" . $this->_timeStats());
}
if (
isset($this->params['codeCoverage']) &&
$this->params['codeCoverage'] &&
class_exists('CodeCoverageManager')
) {
CodeCoverageManager::report();
}
} | Paint a footer with test case name, timestamp, counts of fails and exceptions. | paintFooter | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_cli_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_cli_reporter.php | MIT |
function _timeStats() {
$out = 'Time taken by tests (in seconds): ' . $this->_timeDuration . "\n";
if (function_exists('memory_get_peak_usage')) {
$out .= 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n";
}
return $out;
} | Get the time and memory stats for this test case/group
@return string String content to display
@access protected | _timeStats | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_cli_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_cli_reporter.php | MIT |
function CakeHtmlReporter($charset = 'utf-8', $params = array()) {
$params = array_map(array($this, '_htmlEntities'), $params);
$this->CakeBaseReporter($charset, $params);
} | Constructor
@param string $charset
@param string $params
@return void | CakeHtmlReporter | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintHeader($testName) {
$this->sendNoCacheHeaders();
$this->paintDocumentStart();
$this->paintTestMenu();
printf("<h2>%s</h2>\n", $this->_htmlEntities($testName));
echo "<ul class='tests'>\n";
} | Paints the top of the web page setting the
title to the name of the starting test.
@param string $test_name Name class of test.
@return void
@access public | paintHeader | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintDocumentStart() {
ob_start();
$baseDir = $this->params['baseDir'];
include CAKE_TESTS_LIB . 'templates' . DS . 'header.php';
} | Paints the document start content contained in header.php
@return void | paintDocumentStart | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintTestMenu() {
$groups = $this->baseUrl() . '?show=groups';
$cases = $this->baseUrl() . '?show=cases';
$plugins = App::objects('plugin', null, false);
sort($plugins);
include CAKE_TESTS_LIB . 'templates' . DS . 'menu.php';
} | Paints the menu on the left side of the test suite interface.
Contains all of the various plugin, core, and app buttons.
@return void | paintTestMenu | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function testCaseList() {
$testCases = parent::testCaseList();
$app = $this->params['app'];
$plugin = $this->params['plugin'];
$buffer = "<h3>Core Test Cases:</h3>\n<ul>";
$urlExtra = null;
if ($app) {
$buffer = "<h3>App Test Cases:</h3>\n<ul>";
$urlExtra = '&app=true';
} elseif ($plugin) {
$buffer = "<h3>" . Inflector::humanize($plugin) . " Test Cases:</h3>\n<ul>";
$urlExtra = '&plugin=' . $plugin;
}
if (1 > count($testCases)) {
$buffer .= "<strong>EMPTY</strong>";
}
foreach ($testCases as $testCaseFile => $testCase) {
$title = explode(strpos($testCase, '\\') ? '\\' : '/', str_replace('.test.php', '', $testCase));
$title[count($title) - 1] = Inflector::camelize($title[count($title) - 1]);
$title = implode(' / ', $title);
$buffer .= "<li><a href='" . $this->baseUrl() . "?case=" . urlencode($testCase) . $urlExtra ."'>" . $title . "</a></li>\n";
}
$buffer .= "</ul>\n";
echo $buffer;
} | Retrieves and paints the list of tests cases in an HTML format.
@return void | testCaseList | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function groupTestList() {
$groupTests = parent::groupTestList();
$app = $this->params['app'];
$plugin = $this->params['plugin'];
$buffer = "<h3>Core Test Groups:</h3>\n<ul>";
$urlExtra = null;
if ($app) {
$buffer = "<h3>App Test Groups:</h3>\n<ul>";
$urlExtra = '&app=true';
} else if ($plugin) {
$buffer = "<h3>" . Inflector::humanize($plugin) . " Test Groups:</h3>\n<ul>";
$urlExtra = '&plugin=' . $plugin;
}
$buffer .= "<li><a href='" . $this->baseURL() . "?group=all$urlExtra'>All tests</a></li>\n";
foreach ($groupTests as $groupTest) {
$buffer .= "<li><a href='" . $this->baseURL() . "?group={$groupTest}" . "{$urlExtra}'>" . $groupTest . "</a></li>\n";
}
$buffer .= "</ul>\n";
echo $buffer;
} | Retrieves and paints the list of group tests in an HTML format.
@return void | groupTestList | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function sendNoCacheHeaders() {
if (!headers_sent()) {
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
} | Send the headers necessary to ensure the page is
reloaded on every request. Otherwise you could be
scratching your head over out of date test data.
@return void
@access public | sendNoCacheHeaders | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintFooter($test_name) {
$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
echo "</ul>\n";
echo "<div style=\"";
echo "padding: 8px; margin: 1em 0; background-color: $colour; color: white;";
echo "\">";
echo $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
echo " test cases complete:\n";
echo "<strong>" . $this->getPassCount() . "</strong> passes, ";
echo "<strong>" . $this->getFailCount() . "</strong> fails and ";
echo "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
echo "</div>\n";
echo '<div style="padding:0 0 5px;">';
echo '<p><strong>Time taken by tests (in seconds):</strong> ' . $this->_timeDuration . '</p>';
if (function_exists('memory_get_peak_usage')) {
echo '<p><strong>Peak memory use: (in bytes):</strong> ' . number_format(memory_get_peak_usage()) . '</p>';
}
echo $this->_paintLinks();
echo '</div>';
if (
isset($this->params['codeCoverage']) &&
$this->params['codeCoverage'] &&
class_exists('CodeCoverageManager')
) {
CodeCoverageManager::report();
}
$this->paintDocumentEnd();
} | Paints the end of the test with a summary of
the passes and failures.
@param string $test_name Name class of test.
@return void
@access public | paintFooter | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function _paintLinks() {
$show = $query = array();
if (!empty($this->params['group'])) {
$show['show'] = 'groups';
} elseif (!empty($this->params['case'])) {
$show['show'] = 'cases';
}
if (!empty($this->params['app'])) {
$show['app'] = $query['app'] = 'true';
}
if (!empty($this->params['plugin'])) {
$show['plugin'] = $query['plugin'] = $this->params['plugin'];
}
if (!empty($this->params['case'])) {
$query['case'] = $this->params['case'];
} elseif (!empty($this->params['group'])) {
$query['group'] = $this->params['group'];
}
$show = $this->_queryString($show);
$query = $this->_queryString($query);
echo "<p><a href='" . $this->baseUrl() . $show . "'>Run more tests</a> | <a href='" . $this->baseUrl() . $query . "&show_passes=1'>Show Passes</a> | \n";
echo " <a href='" . $this->baseUrl() . $query . "&code_coverage=true'>Analyze Code Coverage</a></p>\n";
} | Renders the links that for accessing things in the test suite.
@return void | _paintLinks | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function _queryString($url) {
$out = '?';
$params = array();
foreach ($url as $key => $value) {
$params[] = "$key=$value";
}
$out .= implode('&', $params);
return $out;
} | Convert an array of parameters into a query string url
@param array $url Url hash to be converted
@return string Converted url query string | _queryString | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintDocumentEnd() {
$baseDir = $this->params['baseDir'];
include CAKE_TESTS_LIB . 'templates' . DS . 'footer.php';
ob_end_flush();
} | Paints the end of the document html.
@return void | paintDocumentEnd | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintFail($message) {
parent::paintFail($message);
echo "<li class='fail'>\n";
echo "<span>Failed</span>";
echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
echo "</li>\n";
} | Paints the test failure with a breadcrumbs
trail of the nesting test suites below the
top level test.
@param string $message Failure message displayed in
the context of the other tests.
@return void
@access public | paintFail | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintPass($message) {
parent::paintPass($message);
if (isset($this->params['show_passes']) && $this->params['show_passes']) {
echo "<li class='pass'>\n";
echo "<span>Passed</span> ";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
echo implode(" -> ", $breadcrumb);
echo "<br />" . $this->_htmlEntities($message) . "\n";
echo "</li>\n";
}
} | Paints the test pass with a breadcrumbs
trail of the nesting test suites below the
top level test.
@param string $message Pass message displayed in the context of the other tests.
@return void
@access public | paintPass | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintError($message) {
parent::paintError($message);
echo "<li class='error'>\n";
echo "<span>Error</span>";
echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
echo "</li>\n";
} | Paints a PHP error.
@param string $message Message is ignored.
@return void
@access public | paintError | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintException($exception) {
parent::paintException($exception);
echo "<li class='fail'>\n";
echo "<span>Exception</span>";
$message = 'Unexpected exception of type [' . get_class($exception) .
'] with message ['. $exception->getMessage() .
'] in ['. $exception->getFile() .
' line ' . $exception->getLine() . ']';
echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
echo "</li>\n";
} | Paints a PHP exception.
@param Exception $exception Exception to display.
@return void
@access public | paintException | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintSkip($message) {
parent::paintSkip($message);
echo "<li class='skipped'>\n";
echo "<span>Skipped</span> ";
echo $this->_htmlEntities($message);
echo "</li>\n";
} | Prints the message for skipping tests.
@param string $message Text of skip condition.
@return void
@access public | paintSkip | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintFormattedMessage($message) {
echo '<pre>' . $this->_htmlEntities($message) . '</pre>';
} | Paints formatted text such as dumped variables.
@param string $message Text to show.
@return void
@access public | paintFormattedMessage | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function _htmlEntities($message) {
return htmlentities($message, ENT_COMPAT, $this->_characterSet);
} | Character set adjusted entity conversion.
@param string $message Plain text or Unicode message.
@return string Browser readable message.
@access protected | _htmlEntities | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_html_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_html_reporter.php | MIT |
function paintDocumentStart() {
if (!SimpleReporter::inCli()) {
header('Content-type: text/plain');
}
} | Sets the text/plain header if the test is not a CLI test.
@return void | paintDocumentStart | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_text_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_text_reporter.php | MIT |
function paintFooter($test_name) {
if ($this->getFailCount() + $this->getExceptionCount() == 0) {
echo "OK\n";
} else {
echo "FAILURES!!!\n";
}
echo "Test cases run: " . $this->getTestCaseProgress() .
"/" . $this->getTestCaseCount() .
", Passes: " . $this->getPassCount() .
", Failures: " . $this->getFailCount() .
", Exceptions: " . $this->getExceptionCount() . "\n";
echo 'Time taken by tests (in seconds): ' . $this->_timeDuration . "\n";
if (function_exists('memory_get_peak_usage')) {
echo 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n";
}
if (
isset($this->params['codeCoverage']) &&
$this->params['codeCoverage'] &&
class_exists('CodeCoverageManager')
) {
CodeCoverageManager::report();
}
} | Paints the end of the test with a summary of
the passes and failures.
@param string $test_name Name class of test.
@return void
@access public | paintFooter | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_text_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_text_reporter.php | MIT |
function paintHeader($test_name) {
$this->paintDocumentStart();
echo "$test_name\n";
flush();
} | Paints the title only.
@param string $test_name Name class of test.
@return void
@access public | paintHeader | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_text_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_text_reporter.php | MIT |
function paintFail($message) {
parent::paintFail($message);
echo $this->getFailCount() . ") $message\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
echo "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
echo "\n";
} | Paints the test failure as a stack trace.
@param string $message Failure message displayed in
the context of the other tests.
@return void
@access public | paintFail | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_text_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_text_reporter.php | MIT |
function paintError($message) {
parent::paintError($message);
echo "Exception " . $this->getExceptionCount() . "!\n$message\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
echo "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
echo "\n";
} | Paints a PHP error.
@param string $message Message to be shown.
@return void
@access public | paintError | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_text_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_text_reporter.php | MIT |
function paintException($exception) {
parent::paintException($exception);
$message = 'Unexpected exception of type [' . get_class($exception) .
'] with message ['. $exception->getMessage() .
'] in ['. $exception->getFile() .
' line ' . $exception->getLine() . ']';
echo "Exception " . $this->getExceptionCount() . "!\n$message\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
echo "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
echo "\n";
} | Paints a PHP exception.
@param Exception $exception Exception to describe.
@return void
@access public | paintException | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_text_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_text_reporter.php | MIT |
function paintSkip($message) {
parent::paintSkip($message);
echo "Skip: $message\n";
} | Prints the message for skipping tests.
@param string $message Text of skip condition.
@return void
@access public | paintSkip | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_text_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_text_reporter.php | MIT |
function paintFormattedMessage($message) {
echo "$message\n";
flush();
} | Paints formatted text such as dumped variables.
@param string $message Text to show.
@return void
@access public | paintFormattedMessage | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_text_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_text_reporter.php | MIT |
function testCaseList() {
$testCases = parent::testCaseList();
$app = $this->params['app'];
$plugin = $this->params['plugin'];
$buffer = "Core Test Cases:\n";
$urlExtra = '';
if ($app) {
$buffer = "App Test Cases:\n";
$urlExtra = '&app=true';
} elseif ($plugin) {
$buffer = Inflector::humanize($plugin) . " Test Cases:\n";
$urlExtra = '&plugin=' . $plugin;
}
if (1 > count($testCases)) {
$buffer .= "EMPTY";
echo $buffer;
}
foreach ($testCases as $testCaseFile => $testCase) {
$buffer .= $_SERVER['SERVER_NAME'] . $this->baseUrl() ."?case=" . $testCase . "&output=text"."\n";
}
$buffer .= "\n";
echo $buffer;
} | Generate a test case list in plain text.
Creates as series of url's for tests that can be run.
One case per line.
@return void | testCaseList | php | Datawalke/Coordino | cake/tests/lib/reporter/cake_text_reporter.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/lib/reporter/cake_text_reporter.php | MIT |
function main() {
$this->out('This is the main method called from TestPlugin.ExampleShell');
} | main method
@access public
@return void | main | php | Datawalke/Coordino | cake/tests/test_app/plugins/test_plugin/vendors/shells/example.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/test_app/plugins/test_plugin/vendors/shells/example.php | MIT |
function main() {
$this->out('This is the main method called from TestPluginTwo.ExampleShell');
} | main method
@access public
@return void | main | php | Datawalke/Coordino | cake/tests/test_app/plugins/test_plugin_two/vendors/shells/example.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/test_app/plugins/test_plugin_two/vendors/shells/example.php | MIT |
function main() {
$this->out('This is the main method called from SampleShell');
} | main method
@access public
@return void | main | php | Datawalke/Coordino | cake/tests/test_app/vendors/shells/sample.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/test_app/vendors/shells/sample.php | MIT |
public function parse(int $type, $annotationObject): array
{
if ($type != self::TYPE_PROPERTY) {
return [];
}
ValidatorRegister::registerValidatorItem($this->className, $this->propertyName, $annotationObject);
return [];
} | @param int $type
@param object $annotationObject
@return array
@throws ReflectionException
@throws ValidatorException | parse | php | swoft-cloud/swoft | app/Annotation/Parser/AlphaDashParser.php | https://github.com/swoft-cloud/swoft/blob/master/app/Annotation/Parser/AlphaDashParser.php | Apache-2.0 |
public function getList(Client $client): array
{
// Get health service from consul
$services = $this->agent->services();
$services = [
];
return $services;
} | @param Client $client
@return array
@throws ClientException
@throws ServerException
@example
[
'host:port',
'host:port',
'host:port',
] | getList | php | swoft-cloud/swoft | app/Common/RpcProvider.php | https://github.com/swoft-cloud/swoft/blob/master/app/Common/RpcProvider.php | Apache-2.0 |
public function checkAccess(): void
{
\bean('httpRouter')->each(function (Route $route) {
$path = $route->getPath();
// Skip some routes
if ($route->getMethod() !== 'GET' || false !== \strpos($path, '{')) {
return;
}
$command = sprintf('curl -I 127.0.0.1:18306%s', $path);
Show::colored('> ' . $command);
\exec($command);
});
} | Mock request some api for test server
@CommandMapping("ca") | checkAccess | php | swoft-cloud/swoft | app/Console/Command/TestCommand.php | https://github.com/swoft-cloud/swoft/blob/master/app/Console/Command/TestCommand.php | Apache-2.0 |
public function handle(Throwable $except, Response $response): Response
{
$data = [
'code' => $except->getCode(),
'error' => sprintf('(%s) %s', get_class($except), $except->getMessage()),
'file' => sprintf('At %s line %d', $except->getFile(), $except->getLine()),
'trace' => $except->getTraceAsString(),
];
return $response->withData($data);
} | @param Throwable $except
@param Response $response
@return Response | handle | php | swoft-cloud/swoft | app/Exception/Handler/ApiExceptionHandler.php | https://github.com/swoft-cloud/swoft/blob/master/app/Exception/Handler/ApiExceptionHandler.php | Apache-2.0 |
public function handle(Throwable $e, Response $response): Response
{
// Log error message
Log::error($e->getMessage());
CLog::error('%s. (At %s line %d)', $e->getMessage(), $e->getFile(), $e->getLine());
// Debug is false
if (!APP_DEBUG) {
return $response->withStatus(500)->withContent($e->getMessage());
}
$data = [
'code' => $e->getCode(),
'error' => sprintf('(%s) %s', get_class($e), $e->getMessage()),
'file' => sprintf('At %s line %d', $e->getFile(), $e->getLine()),
'trace' => $e->getTraceAsString(),
];
// Debug is true
return $response->withData($data);
} | @param Throwable $e
@param Response $response
@return Response | handle | php | swoft-cloud/swoft | app/Exception/Handler/HttpExceptionHandler.php | https://github.com/swoft-cloud/swoft/blob/master/app/Exception/Handler/HttpExceptionHandler.php | Apache-2.0 |
public function handle(Throwable $e, Response $response): Response
{
// Debug is false
if (!APP_DEBUG) {
// just show error message
$error = Error::new($e->getCode(), $e->getMessage(), null);
} else {
$message = sprintf(' %s At %s line %d', $e->getMessage(), $e->getFile(), $e->getLine());
$error = Error::new($e->getCode(), $message, null);
}
Debug::log('Rpc server error(%s)', $e->getMessage());
$response->setError($error);
// Debug is true
return $response;
} | @param Throwable $e
@param Response $response
@return Response | handle | php | swoft-cloud/swoft | app/Exception/Handler/RpcExceptionHandler.php | https://github.com/swoft-cloud/swoft/blob/master/app/Exception/Handler/RpcExceptionHandler.php | Apache-2.0 |
public function handle(Throwable $e, Response $response): Response
{
// Debug is false
if (!APP_DEBUG) {
return $response->withStatus(500)->withContent(sprintf(
'%s At %s line %d',
$e->getMessage(),
$e->getFile(),
$e->getLine()
));
}
$data = [
'code' => $e->getCode(),
'error' => sprintf('(%s) %s', get_class($e), $e->getMessage()),
'file' => sprintf('At %s line %d', $e->getFile(), $e->getLine()),
'trace' => $e->getTraceAsString(),
];
// Debug is true
return $response->withData($data);
} | @param Throwable $e
@param Response $response
@return Response | handle | php | swoft-cloud/swoft | app/Exception/Handler/WsHandshakeExceptionHandler.php | https://github.com/swoft-cloud/swoft/blob/master/app/Exception/Handler/WsHandshakeExceptionHandler.php | Apache-2.0 |
public function del(): array
{
return ['del' => Cache::delete('ckey')];
} | @RequestMapping("del")
@return array
@throws InvalidArgumentException | del | php | swoft-cloud/swoft | app/Http/Controller/CacheController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/CacheController.php | Apache-2.0 |
public function get(Request $request): array
{
return $request->getCookieParams();
} | @RequestMapping()
@param Request $request
@return array | get | php | swoft-cloud/swoft | app/Http/Controller/CookieController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/CookieController.php | Apache-2.0 |
public function find(Response $response): Response
{
$id = $this->getId();
$user = User::find($id);
return $response->withData($user);
} | @RequestMapping(route="find")
@param Response $response
@return Response
@throws Throwable | find | php | swoft-cloud/swoft | app/Http/Controller/DbModelController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbModelController.php | Apache-2.0 |
public function save(): array
{
$user = new User();
$user->setAge(random_int(1, 100));
$user->setUserDesc('desc');
$user->save();
$count = Count::new();
$count->setUserId($user->getId());
$count->save();
return $user->toArray();
} | @RequestMapping(route="save")
@return array
@throws Exception | save | php | swoft-cloud/swoft | app/Http/Controller/DbModelController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbModelController.php | Apache-2.0 |
public function update(): array
{
$id = $this->getId();
User::updateOrInsert(['id' => $id], ['name' => 'swoft', 'userDesc' => 'swoft']);
$user = User::find($id);
return $user->toArray();
} | @RequestMapping(route="update")
@return array
@throws Throwable | update | php | swoft-cloud/swoft | app/Http/Controller/DbModelController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbModelController.php | Apache-2.0 |
public function delete(): array
{
$id = $this->getId();
$result = User::find($id)->delete();
return [$result];
} | @RequestMapping(route="delete")
@return array
@throws Throwable | delete | php | swoft-cloud/swoft | app/Http/Controller/DbModelController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbModelController.php | Apache-2.0 |
public function ts()
{
$id = $this->getId();
DB::beginTransaction();
$user = User::find($id);
sgo(function () use ($id) {
DB::beginTransaction();
User::find($id);
});
return json_encode($user->toArray());
} | @RequestMapping(route="ts")
@return false|string
@throws Throwable | ts | php | swoft-cloud/swoft | app/Http/Controller/DbTransactionController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbTransactionController.php | Apache-2.0 |
public function cm()
{
$id = $this->getId();
DB::beginTransaction();
$user = User::find($id);
DB::commit();
sgo(function () use ($id) {
DB::beginTransaction();
User::find($id);
DB::commit();
});
return json_encode($user->toArray());
} | @RequestMapping(route="cm")
@return false|string
@throws Throwable | cm | php | swoft-cloud/swoft | app/Http/Controller/DbTransactionController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbTransactionController.php | Apache-2.0 |
public function rl()
{
$id = $this->getId();
DB::beginTransaction();
$user = User::find($id);
DB::rollBack();
sgo(function () use ($id) {
DB::beginTransaction();
User::find($id);
DB::rollBack();
});
return json_encode($user->toArray());
} | @RequestMapping(route="rl")
@return false|string
@throws Throwable | rl | php | swoft-cloud/swoft | app/Http/Controller/DbTransactionController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbTransactionController.php | Apache-2.0 |
public function ts2()
{
$id = $this->getId();
DB::connection()->beginTransaction();
$user = User::find($id);
sgo(function () use ($id) {
DB::connection()->beginTransaction();
User::find($id);
});
return json_encode($user->toArray());
} | @RequestMapping(route="ts2")
@return false|string
@throws Throwable | ts2 | php | swoft-cloud/swoft | app/Http/Controller/DbTransactionController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbTransactionController.php | Apache-2.0 |
public function cm2()
{
$id = $this->getId();
DB::connection()->beginTransaction();
$user = User::find($id);
DB::connection()->commit();
sgo(function () use ($id) {
DB::connection()->beginTransaction();
User::find($id);
DB::connection()->commit();
});
return json_encode($user->toArray());
} | @RequestMapping(route="cm2")
@return false|string
@throws Throwable | cm2 | php | swoft-cloud/swoft | app/Http/Controller/DbTransactionController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbTransactionController.php | Apache-2.0 |
public function rl2()
{
$id = $this->getId();
DB::connection()->beginTransaction();
$user = User::find($id);
DB::connection()->rollBack();
sgo(function () use ($id) {
DB::connection()->beginTransaction();
User::find($id);
DB::connection()->rollBack();
});
return json_encode($user->toArray());
} | @RequestMapping(route="rl2")
@return false|string
@throws Throwable | rl2 | php | swoft-cloud/swoft | app/Http/Controller/DbTransactionController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbTransactionController.php | Apache-2.0 |
public function multiPool()
{
DB::beginTransaction();
// db3.pool
$user = new User3();
$user->setAge(random_int(1, 100));
$user->setUserDesc('desc');
$user->save();
$uid3 = $user->getId();
//db.pool
$uid = $this->getId();
$count = new Count();
$count->setUserId(random_int(1, 100));
$count->setAttributes('attr');
$count->setCreateTime(time());
$count->save();
$cid = $count->getId();
DB::rollBack();
$u3 = User3::find($uid3)->toArray();
$u = User::find($uid);
$c = Count::find($cid);
return [$u3, $u, $c];
} | @RequestMapping()
@return array
@throws DbException
@throws Throwable | multiPool | php | swoft-cloud/swoft | app/Http/Controller/DbTransactionController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/DbTransactionController.php | Apache-2.0 |
public function hello(string $name): Response
{
return context()->getResponse()->withContent('Hello' . ($name === '' ? '' : ", {$name}"));
} | @RequestMapping("/hello[/{name}]")
@param string $name
@return Response | hello | php | swoft-cloud/swoft | app/Http/Controller/HomeController.php | https://github.com/swoft-cloud/swoft/blob/master/app/Http/Controller/HomeController.php | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.