_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q246800 | SimpleFrameset.findFormInFrame | validation | protected function findFormInFrame($page, $index, $method, $attribute)
{
$form = $this->frames[$index]->$method($attribute);
if (isset($form)) {
$form->setDefaultTarget($this->getPublicNameFromIndex($index));
}
return $form;
} | php | {
"resource": ""
} |
q246801 | SimpleBrowserHistory.recordEntry | validation | public function recordEntry($url, $parameters)
{
$this->dropFuture();
array_push(
$this->sequence,
array('url' => $url, 'parameters' => $parameters));
$this->position++;
} | php | {
"resource": ""
} |
q246802 | SimpleBrowser.getParser | validation | protected function getParser()
{
if ($this->parser) {
return $this->parser;
}
foreach (SimpleTest::getParsers() as $parser) {
if ($parser->can()) {
return $parser;
}
}
} | php | {
"resource": ""
} |
q246803 | SimpleBrowser.parse | validation | protected function parse($response, $depth = 0)
{
$page = $this->buildPage($response);
if ($this->ignore_frames || ! $page->hasFrames() || ($depth > $this->maximum_nested_frames)) {
return $page;
}
$frameset = new SimpleFrameset($page);
foreach ($page->getFrameset() as $key => $url) {
$frame = $this->fetch($url, new SimpleGetEncoding(), $depth + 1);
$frameset->addFrame($frame, $key);
}
return $frameset;
} | php | {
"resource": ""
} |
q246804 | SimpleBrowser.load | validation | protected function load($url, $parameters)
{
$frame = $url->getTarget();
if (! $frame || ! $this->page->hasFrames() || (strtolower($frame) == '_top')) {
return $this->loadPage($url, $parameters);
}
return $this->loadFrame(array($frame), $url, $parameters);
} | php | {
"resource": ""
} |
q246805 | SimpleBrowser.loadFrame | validation | protected function loadFrame($frames, $url, $parameters)
{
$page = $this->fetch($url, $parameters);
$this->page->setFrame($frames, $page);
return $page->getRaw();
} | php | {
"resource": ""
} |
q246806 | SimpleBrowser.head | validation | public function head($url, $parameters = false)
{
if (! is_object($url)) {
$url = new SimpleUrl($url);
}
if ($this->getUrl()) {
$url = $url->makeAbsolute($this->getUrl());
}
$response = $this->user_agent->fetchResponse($url, new SimpleHeadEncoding($parameters));
$this->page = new SimplePage($response);
return ! $response->isError();
} | php | {
"resource": ""
} |
q246807 | SimpleBrowser.get | validation | public function get($url, $parameters = false)
{
if (! is_object($url)) {
$url = new SimpleUrl($url);
}
if ($this->getUrl()) {
$url = $url->makeAbsolute($this->getUrl());
}
return $this->load($url, new SimpleGetEncoding($parameters));
} | php | {
"resource": ""
} |
q246808 | SimpleBrowser.post | validation | public function post($url, $parameters = false, $content_type = false)
{
if (! is_object($url)) {
$url = new SimpleUrl($url);
}
if ($this->getUrl()) {
$url = $url->makeAbsolute($this->getUrl());
}
return $this->load($url, new SimplePostEncoding($parameters, $content_type));
} | php | {
"resource": ""
} |
q246809 | SimpleBrowser.put | validation | public function put($url, $parameters = false, $content_type = false)
{
if (! is_object($url)) {
$url = new SimpleUrl($url);
}
return $this->load($url, new SimplePutEncoding($parameters, $content_type));
} | php | {
"resource": ""
} |
q246810 | SimpleBrowser.delete | validation | public function delete($url, $parameters = false)
{
if (! is_object($url)) {
$url = new SimpleUrl($url);
}
return $this->load($url, new SimpleDeleteEncoding($parameters));
} | php | {
"resource": ""
} |
q246811 | SimpleBrowser.retry | validation | public function retry()
{
$frames = $this->page->getFrameFocus();
if (count($frames) > 0) {
$this->loadFrame(
$frames,
$this->page->getUrl(),
$this->page->getRequestData());
return $this->page->getRaw();
}
if ($url = $this->history->getUrl()) {
$this->page = $this->fetch($url, $this->history->getParameters());
return $this->page->getRaw();
}
return false;
} | php | {
"resource": ""
} |
q246812 | SimpleBrowser.back | validation | public function back()
{
if (! $this->history->back()) {
return false;
}
$content = $this->retry();
if (! $content) {
$this->history->forward();
}
return $content;
} | php | {
"resource": ""
} |
q246813 | SimpleBrowser.authenticate | validation | public function authenticate($username, $password)
{
if (! $this->page->getRealm()) {
return false;
}
$url = $this->page->getUrl();
if (! $url) {
return false;
}
$this->user_agent->setIdentity(
$url->getHost(),
$this->page->getRealm(),
$username,
$password);
return $this->retry();
} | php | {
"resource": ""
} |
q246814 | SimpleBrowser.setField | validation | public function setField($label, $value, $position=false)
{
return $this->page->setField(new SelectByLabelOrName($label), $value, $position);
} | php | {
"resource": ""
} |
q246815 | SimpleBrowser.clickSubmit | validation | public function clickSubmit($label = 'Submit', $additional = false)
{
if (! ($form = $this->page->getFormBySubmit(new SelectByLabel($label)))) {
return false;
}
$success = $this->load(
$form->getAction(),
$form->submitButton(new SelectByLabel($label), $additional));
return ($success ? $this->getContent() : $success);
} | php | {
"resource": ""
} |
q246816 | SimpleBrowser.clickSubmitByName | validation | public function clickSubmitByName($name, $additional = false)
{
if (! ($form = $this->page->getFormBySubmit(new SelectByName($name)))) {
return false;
}
$success = $this->load(
$form->getAction(),
$form->submitButton(new SelectByName($name), $additional));
return ($success ? $this->getContent() : $success);
} | php | {
"resource": ""
} |
q246817 | SimpleBrowser.clickSubmitById | validation | public function clickSubmitById($id, $additional = false)
{
if (! ($form = $this->page->getFormBySubmit(new SelectById($id)))) {
return false;
}
$success = $this->load(
$form->getAction(),
$form->submitButton(new SelectById($id), $additional));
return ($success ? $this->getContent() : $success);
} | php | {
"resource": ""
} |
q246818 | SimpleBrowser.clickImage | validation | public function clickImage($label, $x = 1, $y = 1, $additional = false)
{
if (! ($form = $this->page->getFormByImage(new SelectByLabel($label)))) {
return false;
}
$success = $this->load(
$form->getAction(),
$form->submitImage(new SelectByLabel($label), $x, $y, $additional));
return ($success ? $this->getContent() : $success);
} | php | {
"resource": ""
} |
q246819 | SimpleBrowser.clickImageByName | validation | public function clickImageByName($name, $x = 1, $y = 1, $additional = false)
{
if (! ($form = $this->page->getFormByImage(new SelectByName($name)))) {
return false;
}
$success = $this->load(
$form->getAction(),
$form->submitImage(new SelectByName($name), $x, $y, $additional));
return ($success ? $this->getContent() : $success);
} | php | {
"resource": ""
} |
q246820 | SimpleBrowser.clickImageById | validation | public function clickImageById($id, $x = 1, $y = 1, $additional = false)
{
if (! ($form = $this->page->getFormByImage(new SelectById($id)))) {
return false;
}
$success = $this->load(
$form->getAction(),
$form->submitImage(new SelectById($id), $x, $y, $additional));
return ($success ? $this->getContent() : $success);
} | php | {
"resource": ""
} |
q246821 | SimpleBrowser.submitFormById | validation | public function submitFormById($id, $additional = false)
{
if (! ($form = $this->page->getFormById($id))) {
return false;
}
$success = $this->load(
$form->getAction(),
$form->submit($additional));
return ($success ? $this->getContent() : $success);
} | php | {
"resource": ""
} |
q246822 | SimpleBrowser.getLink | validation | public function getLink($label, $index = 0)
{
$urls = $this->page->getUrlsByLabel($label);
if (count($urls) == 0) {
return false;
}
if (count($urls) < $index + 1) {
return false;
}
return $urls[$index];
} | php | {
"resource": ""
} |
q246823 | SimpleBrowser.clickLink | validation | public function clickLink($label, $index = 0)
{
$url = $this->getLink($label, $index);
if ($url === false) {
return false;
}
$this->load($url, new SimpleGetEncoding());
return (bool) $this->getContent();
} | php | {
"resource": ""
} |
q246824 | SimpleBrowser.clickLinkById | validation | public function clickLinkById($id)
{
if (! ($url = $this->getLinkById($id))) {
return false;
}
$this->load($url, new SimpleGetEncoding());
return $this->getContent();
} | php | {
"resource": ""
} |
q246825 | SimpleBrowser.click | validation | public function click($label)
{
$raw = $this->clickSubmit($label);
if (! $raw) {
$raw = $this->clickLink($label);
}
if (! $raw) {
$raw = $this->clickImage($label);
}
return $raw;
} | php | {
"resource": ""
} |
q246826 | SimpleBrowser.isClickable | validation | public function isClickable($label)
{
return $this->isSubmit($label) || ($this->getLink($label) !== false) || $this->isImage($label);
} | php | {
"resource": ""
} |
q246827 | SimpleUserAgent.restart | validation | public function restart($date = false)
{
$this->cookie_jar->restartSession($date);
$this->authenticator->restartSession();
$this->http_referer = null;
} | php | {
"resource": ""
} |
q246828 | SimpleUserAgent.getCookies | validation | public function getCookies()
{
$lstCookies = $this->cookie_jar->getCookies();
$aCookies = [];
foreach($lstCookies as $oCookies) {
$aCookies[] = [
'name'=>$oCookies->getName(),
'value'=>$oCookies->getValue(),
'host'=>$oCookies->getHost(),
'path'=>$oCookies->getPath(),
'expiry'=>$oCookies->getExpiry(),
];
}
return $aCookies;
} | php | {
"resource": ""
} |
q246829 | SimpleUserAgent.setCookies | validation | public function setCookies(array $lstCookies)
{
foreach($lstCookies as $aCookies) {
$this->cookie_jar->setCookie(
$aCookies['name'],
$aCookies['value'],
$aCookies['host'],
$aCookies['path'],
$aCookies['expiry']
);
}
} | php | {
"resource": ""
} |
q246830 | SimpleUserAgent.getBaseCookieValue | validation | public function getBaseCookieValue($name, $base)
{
if (! $base) {
return;
}
return $this->getCookieValue($base->getHost(), $base->getPath(), $name);
} | php | {
"resource": ""
} |
q246831 | SimpleUserAgent.setIdentity | validation | public function setIdentity($host, $realm, $username, $password)
{
$this->authenticator->setIdentityForRealm($host, $realm, $username, $password);
} | php | {
"resource": ""
} |
q246832 | SimpleUserAgent.fetchResponse | validation | public function fetchResponse($url, $encoding)
{
if (!in_array($encoding->getMethod(), array('POST', 'PUT'))) {
$url->addRequestParameters($encoding);
$encoding->clear();
}
$response = $this->fetchWhileRedirected($url, $encoding);
if ($headers = $response->getHeaders()) {
if ($headers->isChallenge()) {
$this->authenticator->addRealm(
$url,
$headers->getAuthentication(),
$headers->getRealm());
}
}
return $response;
} | php | {
"resource": ""
} |
q246833 | SimpleUserAgent.fetchWhileRedirected | validation | protected function fetchWhileRedirected($url, $encoding)
{
$redirects = 0;
do {
$response = $this->fetch($url, $encoding);
if ($response->isError()) {
return $response;
}
$headers = $response->getHeaders();
if ($this->cookies_enabled) {
$headers->writeCookiesToJar($this->cookie_jar, $url);
}
if (! $headers->isRedirect()) {
break;
}
$location = new SimpleUrl($headers->getLocation());
$url = $location->makeAbsolute($url);
$encoding = new SimpleGetEncoding();
} while (! $this->isTooManyRedirects(++$redirects));
return $response;
} | php | {
"resource": ""
} |
q246834 | SimpleUserAgent.fetch | validation | protected function fetch($url, $encoding)
{
$request = $this->createRequest($url, $encoding);
return $request->fetch($this->connection_timeout);
} | php | {
"resource": ""
} |
q246835 | SimpleUserAgent.createRequest | validation | protected function createRequest($url, $encoding)
{
$request = $this->createHttpRequest($url, $encoding);
$this->addAdditionalHeaders($request);
if ($this->cookies_enabled) {
$request->readCookiesFromJar($this->cookie_jar, $url);
}
$this->authenticator->addHeaders($request, $url);
// Add referer header, if not set explicitly
if($this->http_referer) {
$headers = $request->getHeaders();
if(is_array($headers)) {
$custom_referer = false;
foreach ($headers as $header) {
if (preg_match('~^referer:~i', $header)) {
$custom_referer = true;
break;
}
}
if (! $custom_referer) {
$request->addHeaderLine('Referer: ' . $this->http_referer);
}
}
}
return $request;
} | php | {
"resource": ""
} |
q246836 | SimpleUserAgent.createRoute | validation | protected function createRoute($url)
{
if ($this->proxy) {
return new SimpleProxyRoute(
$url,
$this->proxy,
$this->proxy_username,
$this->proxy_password);
}
return new SimpleRoute($url);
} | php | {
"resource": ""
} |
q246837 | SimpleErrorTrappingInvoker.invoke | validation | public function invoke($method)
{
$queue = $this->createErrorQueue();
set_error_handler('SimpleTestErrorHandler');
parent::invoke($method);
restore_error_handler();
$queue->tally();
} | php | {
"resource": ""
} |
q246838 | SimpleErrorTrappingInvoker.createErrorQueue | validation | protected function createErrorQueue()
{
$context = SimpleTest::getContext();
$test = $this->getTestCase();
$queue = $context->get('SimpleErrorQueue');
$queue->setTestCase($test);
return $queue;
} | php | {
"resource": ""
} |
q246839 | SimpleErrorQueue.add | validation | public function add($severity, $content, $filename, $line)
{
$content = str_replace('%', '%%', $content);
$this->testLatestError($severity, $content, $filename, $line);
} | php | {
"resource": ""
} |
q246840 | SimpleErrorQueue.tally | validation | public function tally()
{
while (list($severity, $message, $file, $line) = $this->extract()) {
$severity = $this->getSeverityAsString($severity);
$this->test->error($severity, $message, $file, $line);
}
while (list($expected, $message) = $this->extractExpectation()) {
$this->test->assert($expected, false, '%s -> Expected error not caught');
}
} | php | {
"resource": ""
} |
q246841 | SimpleErrorQueue.getSeverityAsString | validation | public static function getSeverityAsString($severity)
{
static $map = array(
E_ERROR => 'E_ERROR',
E_WARNING => 'E_WARNING',
E_PARSE => 'E_PARSE',
E_NOTICE => 'E_NOTICE',
E_CORE_ERROR => 'E_CORE_ERROR',
E_CORE_WARNING => 'E_CORE_WARNING',
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
E_USER_ERROR => 'E_USER_ERROR',
E_USER_WARNING => 'E_USER_WARNING',
E_USER_NOTICE => 'E_USER_NOTICE',
E_STRICT => 'E_STRICT',
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', # PHP 5.2
E_DEPRECATED => 'E_DEPRECATED', # PHP 5.3
E_USER_DEPRECATED => 'E_USER_DEPRECATED', # PHP 5.3
E_ALL => 'E_ALL'
);
return $map[$severity];
} | php | {
"resource": ""
} |
q246842 | EclipseReporter.paintPass | validation | public function paintPass($message)
{
if (! $this->pass) {
$this->message = self::escapeVal($message);
}
$this->pass = true;
} | php | {
"resource": ""
} |
q246843 | EclipseReporter.paintFail | validation | public function paintFail($message)
{
//only get the first failure or error
if (! $this->fail && ! $this->error) {
$this->fail = true;
$this->message = self::escapeVal($message);
$this->listener->write(
'{status:"fail",message:"' . $this->message . '",group:"' . $this->group .
'",case:"' . $this->case . '",method:"' . $this->method . '"}'
);
}
} | php | {
"resource": ""
} |
q246844 | EclipseReporter.paintException | validation | public function paintException($exception)
{
if (! $this->fail && ! $this->error) {
$this->error = true;
$message = 'Unexpected exception of type[' . get_class($exception) .
'] with message [' . $exception->getMessage() . '] in [' .
$exception->getFile() . ' line ' . $exception->getLine() . ']';
$this->message = self::escapeVal($message);
$this->listener->write(
'{status:"error",message:"' . $this->message . '",group:"' . $this->group .
'",case:"' . $this->case . '",method:"' . $this->method. '"}'
);
}
} | php | {
"resource": ""
} |
q246845 | EclipseReporter.paintMethodStart | validation | public function paintMethodStart($method)
{
$this->pass = false;
$this->fail = false;
$this->error = false;
$this->method = self::escapeVal($method);
} | php | {
"resource": ""
} |
q246846 | EclipseReporter.paintMethodEnd | validation | public function paintMethodEnd($method)
{
if ($this->fail || $this->error || ! $this->pass) {
} else {
$this->listener->write(
'{status:"pass",message:"' . $this->message . '",group:"' .
$this->group . '",case:"' . $this->case . '",method:"' .
$this->method . '"}');
}
} | php | {
"resource": ""
} |
q246847 | EclipseReporter.paintGroupStart | validation | public function paintGroupStart($group, $size)
{
$this->group = self::escapeVal($group);
if ($this->cc) {
if (extension_loaded('xdebug')) {
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
}
}
} | php | {
"resource": ""
} |
q246848 | EclipseReporter.paintGroupEnd | validation | public function paintGroupEnd($group)
{
$this->group = '';
$cc = '';
if ($this->cc) {
if (extension_loaded('xdebug')) {
$arrfiles = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
$thisdir = dirname(__FILE__);
$thisdirlen = strlen($thisdir);
foreach ($arrfiles as $index=>$file) {
if (substr($index, 0, $thisdirlen)===$thisdir) {
continue;
}
$lcnt = 0;
$ccnt = 0;
foreach ($file as $line) {
if ($line == -2) {
continue;
}
$lcnt++;
if ($line==1) {
$ccnt++;
}
}
if ($lcnt > 0) {
$cc .= round(($ccnt/$lcnt) * 100, 2) . '%';
} else {
$cc .= '0.00%';
}
$cc.= "\t" . $index . "\n";
}
}
}
$this->listener->write(
'{status:"coverage",message:"' . self::escapeVal($cc) . '"}'
);
} | php | {
"resource": ""
} |
q246849 | EclipseInvoker.after | validation | public function after($method)
{
$this->invoker->after($method);
$output = ob_get_contents();
ob_end_clean();
if ($output !== '') {
$result = $this->listener->write(
'{status:"info",message:"' . EclipseReporter::escapeVal($output) . '"}'
);
}
} | php | {
"resource": ""
} |
q246850 | TreemapRecorder.paintGroupStart | validation | public function paintGroupStart($message, $size)
{
parent::paintGroupStart($message, $size);
$node = new TreemapNode('Group', $message);
$this->_stack->push($node);
} | php | {
"resource": ""
} |
q246851 | TreemapRecorder.paintCaseStart | validation | public function paintCaseStart($message)
{
parent::paintCaseStart($message);
$node = new TreemapNode('TestCase', $message);
$this->_stack->push($node);
} | php | {
"resource": ""
} |
q246852 | TreemapRecorder.paintMethodStart | validation | public function paintMethodStart($message)
{
parent::paintMethodStart($message);
$node = new TreemapNode('Method', $message);
$this->_stack->push($node);
} | php | {
"resource": ""
} |
q246853 | TreemapRecorder.paintPass | validation | public function paintPass($message)
{
parent::paintPass($message);
$node = new TreemapNode('Assertion', $message, true);
$current = $this->_stack->peek();
if ($current) {
$current->putChild($node);
} else {
echo 'no current node';
}
} | php | {
"resource": ""
} |
q246854 | TreemapRecorder.paintFail | validation | public function paintFail($message)
{
parent::paintFail($message);
$node = new TreemapNode('Assertion', $message, false);
$current = $this->_stack->peek();
$current->putChild($node);
$current->fail();
} | php | {
"resource": ""
} |
q246855 | TreemapRecorder.paintMethodEnd | validation | public function paintMethodEnd($message)
{
parent::paintCaseEnd($message);
$node = $this->_stack->pop();
$current = $this->_stack->peek();
if ($node->isFailed()) {
$current->fail();
}
$current->putChild($node);
} | php | {
"resource": ""
} |
q246856 | TreemapRecorder.paintGroupEnd | validation | public function paintGroupEnd($message)
{
$node = $this->_stack->pop();
$current = $this->_stack->peek();
if ($current) {
if ($node->isFailed()) {
$current->fail();
}
$current->putChild($node);
} else {
$this->_graph = $node;
}
parent::paintGroupEnd($message);
} | php | {
"resource": ""
} |
q246857 | TreemapNode.compareChildren | validation | public function compareChildren($a, $b)
{
if ($this->_children[$a]->getTotalSize() > $this->_children[$b]->getTotalSize()) {
$node_a = $this->_children[$a];
$node_b = $this->_children[$b];
$this->_children[$a] = $node_b;
$this->_children[$b] = $node_a;
}
} | php | {
"resource": ""
} |
q246858 | TreemapNode.getTotalSize | validation | public function getTotalSize()
{
if (!isset($this->_size)) {
$size = $this->getSize();
if (!$this->isLeaf()) {
foreach ($this->getChildren() as $child) {
$size += $child->getTotalSize();
}
}
$this->_size = $size;
}
return $this->_size;
} | php | {
"resource": ""
} |
q246859 | WebUnitReporter.paintHeader | validation | public function paintHeader($test_name)
{
$this->sendNoCacheHeaders();
echo sprintf(
SIMPLETEST_WEBUNIT_HEAD, $test_name, $this->path . 'js/', $this->path . 'js/', $this->path . 'css/', $this->_getCss(), $test_name, $this->path . 'img/'
);
flush();
} | php | {
"resource": ""
} |
q246860 | WebUnitReporter.paintFail | validation | public function paintFail($message)
{
parent::paintFail($message);
$msg = '<span class="fail">Fail</span>: ';
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
$msg .= implode('->', $breadcrumb);
$msg .= '->' . htmlentities($message) . '<br />';
echo "add_fail('$msg');\n";
} | php | {
"resource": ""
} |
q246861 | SimpleUrl.chompCoordinates | validation | protected function chompCoordinates(&$url)
{
if (preg_match('/(.*)\?(\d+),(\d+)$/', $url, $matches)) {
$url = $matches[1];
return array((integer) $matches[2], (integer) $matches[3]);
}
return array(false, false);
} | php | {
"resource": ""
} |
q246862 | SimpleUrl.chompScheme | validation | protected function chompScheme(&$url)
{
if (preg_match('#^([^/:]*):(//)(.*)#', $url, $matches)) {
$url = $matches[2] . $matches[3];
return $matches[1];
}
return false;
} | php | {
"resource": ""
} |
q246863 | SimpleUrl.chompPath | validation | protected function chompPath(&$url)
{
if (preg_match('/(.*?)(\?|#|$)(.*)/', $url, $matches)) {
$url = $matches[2] . $matches[3];
return ($matches[1] ? $matches[1] : '');
}
return '';
} | php | {
"resource": ""
} |
q246864 | SimpleUrl.parseRequest | validation | protected function parseRequest($raw)
{
$this->raw = $raw;
$request = new SimpleGetEncoding();
foreach (explode('&', $raw) as $pair) {
if (preg_match('/(.*?)=(.*)/', $pair, $matches)) {
$request->add(urldecode($matches[1]), urldecode($matches[2]));
} elseif ($pair) {
$request->add(urldecode($pair), '');
}
}
return $request;
} | php | {
"resource": ""
} |
q246865 | SimpleUrl.setCoordinates | validation | public function setCoordinates($x = false, $y = false)
{
if (($x === false) || ($y === false)) {
$this->x = $this->y = false;
return;
}
$this->x = (integer) $x;
$this->y = (integer) $y;
} | php | {
"resource": ""
} |
q246866 | SimpleUrl.getEncodedRequest | validation | public function getEncodedRequest()
{
if ($this->raw) {
$encoded = $this->raw;
} else {
$encoded = $this->request->asUrlRequest();
}
if ($encoded) {
return '?' . preg_replace('/^\?/', '', $encoded);
}
return '';
} | php | {
"resource": ""
} |
q246867 | SimpleUrl.addRequestParameter | validation | public function addRequestParameter($key, $value)
{
$this->raw = false;
$this->request->add($key, $value);
} | php | {
"resource": ""
} |
q246868 | SimpleUrl.asString | validation | public function asString()
{
$path = $this->path;
$scheme = $identity = $host = $port = $encoded = $fragment = '';
if ($this->username && $this->password) {
$identity = $this->username . ':' . $this->password . '@';
}
if ($this->getHost()) {
$scheme = $this->getScheme() ? $this->getScheme() : 'http';
$scheme .= '://';
$host = $this->getHost();
} elseif ($this->getScheme() === 'file') {
// Safest way; otherwise, file URLs on Windows have an extra
// leading slash. It might be possible to convert file://
// URIs to local file paths, but that requires more research.
$scheme = 'file://';
}
if ($this->getPort() && $this->getPort() != 80) {
$port = ':' . $this->getPort();
}
if (substr($this->path, 0, 1) == '/') {
$path = $this->normalisePath($this->path);
}
$encoded = $this->getEncodedRequest();
$fragment = $this->getFragment() ? '#' . $this->getFragment() : '';
$coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
return "$scheme$identity$host$port$path$encoded$fragment$coords";
} | php | {
"resource": ""
} |
q246869 | SimpleUrl.makeAbsolute | validation | public function makeAbsolute($base)
{
if (! is_object($base)) {
$base = new self($base);
}
if ($this->getHost()) {
$scheme = $this->getScheme();
$host = $this->getHost();
$port = $this->getPort() ? ':' . $this->getPort() : '';
$identity = $this->getIdentity() ? $this->getIdentity() . '@' : '';
if (! $identity) {
$identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
}
} else {
$scheme = $base->getScheme();
$host = $base->getHost();
$port = $base->getPort() ? ':' . $base->getPort() : '';
$identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
}
$path = $this->normalisePath($this->extractAbsolutePath($base));
$encoded = $this->getEncodedRequest();
$fragment = $this->getFragment() ? '#' . $this->getFragment() : '';
$coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
return new self("$scheme://$identity$host$port$path$encoded$fragment$coords");
} | php | {
"resource": ""
} |
q246870 | SimpleUrl.extractAbsolutePath | validation | protected function extractAbsolutePath($base)
{
if ($this->getHost()) {
return $this->path;
}
if (! $this->isRelativePath($this->path)) {
return $this->path;
}
if ($this->path) {
return $base->getBasePath() . $this->path;
}
return $base->getPath();
} | php | {
"resource": ""
} |
q246871 | SimpleUrl.getIdentity | validation | public function getIdentity()
{
if ($this->username && $this->password) {
return $this->username . ':' . $this->password;
}
return false;
} | php | {
"resource": ""
} |
q246872 | ColorTextReporter.paintFooter | validation | public function paintFooter($test_name)
{
ob_start();
parent::paintFooter($test_name);
$output = trim(ob_get_clean());
if ($output) {
if (($this->getFailCount() + $this->getExceptionCount()) == 0) {
$color = $this->_passColor;
} else {
$color = $this->_failColor;
}
$this->_setColor($color);
echo $output;
$this->_resetColor();
}
} | php | {
"resource": ""
} |
q246873 | SimpleCollector.removeTrailingSlash | validation | protected function removeTrailingSlash($path)
{
if (substr($path, -1) == DIRECTORY_SEPARATOR) {
return substr($path, 0, -1);
} elseif (substr($path, -1) == '/') {
return substr($path, 0, -1);
} else {
return $path;
}
} | php | {
"resource": ""
} |
q246874 | SimpleCollector.collect | validation | public function collect(&$test, $path)
{
$path = $this->removeTrailingSlash($path);
if ($handle = opendir($path)) {
while (($entry = readdir($handle)) !== false) {
if ($this->isHidden($entry)) {
continue;
}
$this->handle($test, $path . DIRECTORY_SEPARATOR . $entry);
}
closedir($handle);
}
} | php | {
"resource": ""
} |
q246875 | SimplePatternCollector.handle | validation | protected function handle(&$test, $filename)
{
if (preg_match($this->pattern, $filename)) {
parent::handle($test, $filename);
}
} | php | {
"resource": ""
} |
q246876 | HtmlReporter.paintException | validation | public function paintException($exception)
{
parent::paintException($exception);
print '<span class="fail">Exception</span>: ';
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
print implode(' -> ', $breadcrumb);
$message = 'Unexpected exception of type [' . get_class($exception) .
'] with message [' . $exception->getMessage() .
'] in [' . $exception->getFile() .
' line ' . $exception->getLine() . ']';
print ' -> <strong>' . $this->htmlEntities($message) . "</strong><br />\n";
} | php | {
"resource": ""
} |
q246877 | TextReporter.paintFail | validation | public function paintFail($message)
{
parent::paintFail($message);
print $this->getFailCount() . ") $message\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
print "\n";
} | php | {
"resource": ""
} |
q246878 | TextReporter.paintError | validation | public function paintError($message)
{
parent::paintError($message);
print 'Exception ' . $this->getExceptionCount() . "!\n$message\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
print "\n";
} | php | {
"resource": ""
} |
q246879 | SelectiveReporter.shouldInvoke | validation | public function shouldInvoke($test_case, $method)
{
if ($this->shouldRunTest($test_case, $method)) {
return $this->reporter->shouldInvoke($test_case, $method);
}
return false;
} | php | {
"resource": ""
} |
q246880 | SimpleReporter.paintGroupStart | validation | public function paintGroupStart($test_name, $size)
{
if (! isset($this->size)) {
$this->size = $size;
}
if (count($this->test_stack) == 0) {
$this->paintHeader($test_name);
}
$this->test_stack[] = $test_name;
} | php | {
"resource": ""
} |
q246881 | SimpleReporter.paintGroupEnd | validation | public function paintGroupEnd($test_name)
{
array_pop($this->test_stack);
if (count($this->test_stack) == 0) {
$this->paintFooter($test_name);
}
} | php | {
"resource": ""
} |
q246882 | SimpleReporter.paintCaseStart | validation | public function paintCaseStart($test_name)
{
if (! isset($this->size)) {
$this->size = 1;
}
if (count($this->test_stack) == 0) {
$this->paintHeader($test_name);
}
$this->test_stack[] = $test_name;
} | php | {
"resource": ""
} |
q246883 | SimpleReporter.paintCaseEnd | validation | public function paintCaseEnd($test_name)
{
$this->progress++;
array_pop($this->test_stack);
if (count($this->test_stack) == 0) {
$this->paintFooter($test_name);
}
} | php | {
"resource": ""
} |
q246884 | MultipleReporter.makeDry | validation | public function makeDry($is_dry = true)
{
$numberOfReporters = count($this->reporters);
for ($i = 0; $i < $numberOfReporters; $i++) {
$this->reporters[$i]->makeDry($is_dry);
}
} | php | {
"resource": ""
} |
q246885 | MultipleReporter.getStatus | validation | public function getStatus()
{
$numberOfReporters = count($this->reporters);
for ($i = 0; $i < $numberOfReporters; $i++) {
if (! $this->reporters[$i]->getStatus()) {
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q246886 | MultipleReporter.shouldInvoke | validation | public function shouldInvoke($test_case_name, $method)
{
$numberOfReporters = count($this->reporters);
for ($i = 0; $i < $numberOfReporters; $i++) {
if (! $this->reporters[$i]->shouldInvoke($test_case_name, $method)) {
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q246887 | MultipleReporter.createInvoker | validation | public function createInvoker($invoker)
{
$numberOfReporters = count($this->reporters);
for ($i = 0; $i < $numberOfReporters; $i++) {
$invoker = $this->reporters[$i]->createInvoker($invoker);
}
return $invoker;
} | php | {
"resource": ""
} |
q246888 | MultipleReporter.paintCaseEnd | validation | public function paintCaseEnd($test_name)
{
$numberOfReporters = count($this->reporters);
for ($i = 0; $i < $numberOfReporters; $i++) {
$this->reporters[$i]->paintCaseEnd($test_name);
}
} | php | {
"resource": ""
} |
q246889 | MultipleReporter.paintMethodEnd | validation | public function paintMethodEnd($test_name)
{
$numberOfReporters = count($this->reporters);
for ($i = 0; $i < $numberOfReporters; $i++) {
$this->reporters[$i]->paintMethodEnd($test_name);
}
} | php | {
"resource": ""
} |
q246890 | SimpleArguments.assign | validation | public function assign($key, $value)
{
if ($this->$key === false) {
$this->all[$key] = $value;
} elseif (! is_array($this->$key)) {
$this->all[$key] = array($this->$key, $value);
} else {
$this->all[$key][] = $value;
}
} | php | {
"resource": ""
} |
q246891 | SimpleArguments.parseArgument | validation | private function parseArgument(&$arguments)
{
$argument = array_shift($arguments);
if (preg_match('/^-(\w)=(.+)$/', $argument, $matches)) {
return array($matches[1], $matches[2]);
} elseif (preg_match('/^-(\w)$/', $argument, $matches)) {
return array($matches[1], $this->nextNonFlagElseTrue($arguments));
} elseif (preg_match('/^--(\w+)=(.+)$/', $argument, $matches)) {
return array($matches[1], $matches[2]);
} elseif (preg_match('/^--(\w+)$/', $argument, $matches)) {
return array($matches[1], $this->nextNonFlagElseTrue($arguments));
}
} | php | {
"resource": ""
} |
q246892 | SimpleHelp.explainFlag | validation | public function explainFlag($flags, $explanation)
{
$flags = is_array($flags) ? $flags : array($flags);
$this->flag_sets[] = $flags;
$this->explanations[] = $explanation;
} | php | {
"resource": ""
} |
q246893 | SimpleHelp.render | validation | public function render()
{
$tab_stop = $this->longestFlag($this->flag_sets) + 4;
$text = $this->overview . "\n";
$numberOfFlags = count($this->flag_sets);
for ($i = 0; $i < $numberOfFlags; $i++) {
$text .= $this->renderFlagSet($this->flag_sets[$i], $this->explanations[$i], $tab_stop);
}
return $this->noDuplicateNewLines($text);
} | php | {
"resource": ""
} |
q246894 | SimpleHelp.longestFlag | validation | private function longestFlag($flag_sets)
{
$longest = 0;
foreach ($flag_sets as $flags) {
foreach ($flags as $flag) {
$longest = max($longest, strlen($this->renderFlag($flag)));
}
}
return $longest;
} | php | {
"resource": ""
} |
q246895 | SimpleHelp.renderFlagSet | validation | private function renderFlagSet($flags, $explanation, $tab_stop)
{
$flag = array_shift($flags);
$text = str_pad($this->renderFlag($flag), $tab_stop, ' ') . $explanation . "\n";
foreach ($flags as $flag) {
$text .= ' ' . $this->renderFlag($flag) . "\n";
}
return $text;
} | php | {
"resource": ""
} |
q246896 | SimpleTidyPageBuilder.parse | validation | public function parse($response)
{
$this->page = new SimplePage($response);
$tidied = tidy_parse_string($input = $this->insertGuards($response->getContent()),
array('output-xml' => false, 'wrap' => '0', 'indent' => 'no'),
'latin1');
$this->walkTree($tidied->html());
$this->attachLabels($this->widgets_by_id, $this->labels);
$this->page->setForms($this->forms);
$page = $this->page;
$this->free();
return $page;
} | php | {
"resource": ""
} |
q246897 | SimpleTidyPageBuilder.walkChildren | validation | private function walkChildren($node)
{
if ($node->hasChildren()) {
foreach ($node->child as $child) {
$this->walkTree($child);
}
}
} | php | {
"resource": ""
} |
q246898 | SimpleTidyPageBuilder.createEmptyForm | validation | private function createEmptyForm($node)
{
return new SimpleForm($this->tags()->createTag($node->name, (array) $node->attribute), $this->page);
} | php | {
"resource": ""
} |
q246899 | SimpleTidyPageBuilder.addWidgetToForm | validation | private function addWidgetToForm($node, $form, $enclosing_label)
{
$widget = $this->tags()->createTag($node->name, $this->attributes($node));
if (! $widget) {
return;
}
$widget->setLabel($enclosing_label)
->addContent($this->innerHtml($node));
if ($node->name == 'select') {
$widget->addTags($this->collectSelectOptions($node));
}
$form->addWidget($widget);
$this->indexWidgetById($widget);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.