_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q246700
SimplePhpPageBuilder.acceptTag
validation
protected function acceptTag($tag) { if ($tag->getTagName() === 'a') { $this->page->addLink($tag); } elseif ($tag->getTagName() === 'base') { $this->page->setBase($tag->getAttribute('href')); } elseif ($tag->getTagName() === 'title') { $this->page->setTitle($tag); } elseif ($this->isFormElement($tag->getTagName())) { for ($i = 0; $i < count($this->open_forms); $i++) { $this->open_forms[$i]->addWidget($tag); } $this->last_widget = $tag; } }
php
{ "resource": "" }
q246701
SimplePhpPageBuilder.acceptLabelEnd
validation
protected function acceptLabelEnd() { if (isset($this->label)) { if (isset($this->last_widget)) { $this->last_widget->setLabel($this->label->getText()); unset($this->last_widget); } else { $this->left_over_labels[] = (clone $this->label); } unset($this->label); } }
php
{ "resource": "" }
q246702
SimplePhpPageBuilder.acceptPageEnd
validation
protected function acceptPageEnd() { while (count($this->open_forms)) { $this->complete_forms[] = array_pop($this->open_forms); } foreach ($this->left_over_labels as $label) { for ($i = 0, $count = count($this->complete_forms); $i < $count; $i++) { $this->complete_forms[$i]->attachLabelBySelector( new SelectById($label->getFor()), $label->getText()); } } $this->page->setForms($this->complete_forms); $this->page->setFrames($this->loading_frames); }
php
{ "resource": "" }
q246703
SimpleRealm.stretch
validation
public function stretch($url) { $this->root = $this->getCommonPath($this->root, $url->getPath()); }
php
{ "resource": "" }
q246704
SimpleRealm.getCommonPath
validation
protected function getCommonPath($first, $second) { $first = explode('/', $first); $second = explode('/', $second); for ($i = 0; $i < min(count($first), count($second)); $i++) { if ($first[$i] != $second[$i]) { return implode('/', array_slice($first, 0, $i)) . '/'; } } return implode('/', $first) . '/'; }
php
{ "resource": "" }
q246705
SimpleRealm.isWithin
validation
public function isWithin($url) { if ($this->isIn($this->root, $url->getBasePath())) { return true; } if ($this->isIn($this->root, $url->getBasePath() . $url->getPage() . '/')) { return true; } return false; }
php
{ "resource": "" }
q246706
SimpleAuthenticator.addRealm
validation
public function addRealm($url, $type, $realm) { $this->realms[$url->getHost()][$realm] = new SimpleRealm($type, $url); }
php
{ "resource": "" }
q246707
SimpleAuthenticator.setIdentityForRealm
validation
public function setIdentityForRealm($host, $realm, $username, $password) { if (isset($this->realms[$host][$realm])) { $this->realms[$host][$realm]->setIdentity($username, $password); } }
php
{ "resource": "" }
q246708
SimpleAuthenticator.findRealmFromUrl
validation
protected function findRealmFromUrl($url) { if (! isset($this->realms[$url->getHost()])) { return false; } foreach ($this->realms[$url->getHost()] as $name => $realm) { if ($realm->isWithin($url)) { return $realm; } } return false; }
php
{ "resource": "" }
q246709
SimpleAuthenticator.addHeaders
validation
public function addHeaders($request, $url) { if ($url->getUsername() && $url->getPassword()) { $username = $url->getUsername(); $password = $url->getPassword(); } elseif ($realm = $this->findRealmFromUrl($url)) { $username = $realm->getUsername(); $password = $realm->getPassword(); } else { return; } $this->addBasicHeaders($request, $username, $password); }
php
{ "resource": "" }
q246710
SimpleExpectation.overlayMessage
validation
public function overlayMessage($compare, $dumper) { $this->dumper = $dumper; return sprintf($this->message, $this->testMessage($compare)); }
php
{ "resource": "" }
q246711
PatternExpectation.describePatternMatch
validation
protected function describePatternMatch($pattern, $subject) { preg_match($pattern, $subject, $matches); $position = strpos($subject, $matches[0]); $dumper = $this->getDumper(); return "Pattern [$pattern] detected at character [$position] in [" . $dumper->describeValue($subject) . '] as [' . $matches[0] . '] in region [' . $dumper->clipString($subject, 100, $position) . ']'; }
php
{ "resource": "" }
q246712
MemberExpectation.getProperty
validation
private function getProperty($name, $object) { $reflection = new ReflectionObject($object); $property = $reflection->getProperty($name); if (method_exists($property, 'setAccessible')) { $property->setAccessible(true); } try { return $property->getValue($object); } catch (ReflectionException $e) { return $this->getPrivatePropertyNoMatterWhat($name, $object); } }
php
{ "resource": "" }
q246713
MemberExpectation.getPrivatePropertyNoMatterWhat
validation
private function getPrivatePropertyNoMatterWhat($name, $object) { foreach ((array) $object as $mangled_name => $value) { if ($this->unmangle($mangled_name) == $name) { return $value; } } }
php
{ "resource": "" }
q246714
SelectByLabelOrName.isMatch
validation
public function isMatch($widget) { if (method_exists($widget, 'isLabel')) { if ($widget->isLabel($this->label)) { return true; } } return ($widget->getName() == $this->label); }
php
{ "resource": "" }
q246715
SimpleForm.createAction
validation
protected function createAction($action, $page) { if (($action === '') || ($action === false)) { return $page->expandUrl($page->getUrl()); } return $page->expandUrl(new SimpleUrl($action)); }
php
{ "resource": "" }
q246716
SimpleForm.getAction
validation
public function getAction() { $url = $this->action; if ($this->default_target && ! $url->getTarget()) { $url->setTarget($this->default_target); } if ($this->getMethod() === 'get') { $url->clearRequest(); } return $url; }
php
{ "resource": "" }
q246717
SimpleForm.encode
validation
protected function encode() { $class = $this->encoding; $encoding = new $class(); for ($i = 0, $count = count($this->widgets); $i < $count; $i++) { $this->widgets[$i]->write($encoding); } return $encoding; }
php
{ "resource": "" }
q246718
SimpleForm.addWidget
validation
public function addWidget($tag) { if (strtolower($tag->getAttribute('type')) === 'submit') { $this->buttons[] = $tag; } elseif (strtolower($tag->getAttribute('type')) === 'image') { $this->images[] = $tag; } elseif ($tag->getName()) { $this->setWidget($tag); } }
php
{ "resource": "" }
q246719
SimpleForm.setWidget
validation
protected function setWidget($tag) { if (strtolower($tag->getAttribute('type')) === 'radio') { $this->addRadioButton($tag); } elseif (strtolower($tag->getAttribute('type')) === 'checkbox') { $this->addCheckbox($tag); } else { $this->widgets[] = $tag; } }
php
{ "resource": "" }
q246720
SimpleForm.addRadioButton
validation
protected function addRadioButton($tag) { if (! isset($this->radios[$tag->getName()])) { $this->widgets[] = new SimpleRadioGroup(); $this->radios[$tag->getName()] = count($this->widgets) - 1; } $this->widgets[$this->radios[$tag->getName()]]->addWidget($tag); }
php
{ "resource": "" }
q246721
SimpleForm.addCheckbox
validation
protected function addCheckbox($tag) { if (! isset($this->checkboxes[$tag->getName()])) { $this->widgets[] = $tag; $this->checkboxes[$tag->getName()] = count($this->widgets) - 1; } else { $index = $this->checkboxes[$tag->getName()]; if (! is_a($this->widgets[$index], 'SimpleCheckboxGroup')) { $previous = $this->widgets[$index]; $this->widgets[$index] = new SimpleCheckboxGroup(); $this->widgets[$index]->addWidget($previous); } $this->widgets[$index]->addWidget($tag); } }
php
{ "resource": "" }
q246722
SimpleForm.getValue
validation
public function getValue(SelectorInterface $selector) { for ($i = 0, $count = count($this->widgets); $i < $count; $i++) { if ($selector->isMatch($this->widgets[$i])) { return $this->widgets[$i]->getValue(); } } foreach ($this->buttons as $button) { if ($selector->isMatch($button)) { return $button->getValue(); } } return; }
php
{ "resource": "" }
q246723
SimpleForm.setField
validation
public function setField(SelectorInterface $selector, $value, $position=false) { $success = false; $_position = 0; for ($i = 0, $count = count($this->widgets); $i < $count; $i++) { if ($selector->isMatch($this->widgets[$i])) { $_position++; if ($position === false or $_position === (int) $position) { if ($this->widgets[$i]->setValue($value)) { $success = true; } } } } return $success; }
php
{ "resource": "" }
q246724
SimpleForm.attachLabelBySelector
validation
public function attachLabelBySelector(SelectorInterface $selector, $label) { for ($i = 0, $count = count($this->widgets); $i < $count; $i++) { if ($selector->isMatch($this->widgets[$i])) { if (method_exists($this->widgets[$i], 'setLabel')) { $this->widgets[$i]->setLabel($label); return; } } } }
php
{ "resource": "" }
q246725
SimpleForm.hasSubmit
validation
public function hasSubmit(SelectorInterface $selector) { foreach ($this->buttons as $button) { if ($selector->isMatch($button)) { return true; } } return false; }
php
{ "resource": "" }
q246726
SimpleForm.hasImage
validation
public function hasImage(SelectorInterface $selector) { foreach ($this->images as $image) { if ($selector->isMatch($image)) { return true; } } return false; }
php
{ "resource": "" }
q246727
SimpleForm.submitButton
validation
public function submitButton(SelectorInterface $selector, $additional = false) { $additional = $additional ? $additional : array(); foreach ($this->buttons as $button) { if ($selector->isMatch($button)) { $encoding = $this->encode(); $button->write($encoding); if ($additional) { $encoding->merge($additional); } return $encoding; } } return false; }
php
{ "resource": "" }
q246728
SimpleForm.submitImage
validation
public function submitImage(SelectorInterface $selector, $x, $y, $additional = false) { $additional = $additional ? $additional : array(); foreach ($this->images as $image) { if ($selector->isMatch($image)) { $encoding = $this->encode(); $image->write($encoding, $x, $y); if ($additional) { $encoding->merge($additional); } return $encoding; } } return false; }
php
{ "resource": "" }
q246729
SimpleForm.submit
validation
public function submit($additional = false) { $encoding = $this->encode(); if ($additional) { $encoding->merge($additional); } return $encoding; }
php
{ "resource": "" }
q246730
CoverageUtils.parseArguments
validation
public static function parseArguments($argv, $mutliValueMode = false) { $args = array(); $args['extraArguments'] = array(); array_shift($argv); // scriptname foreach ($argv as $arg) { if (preg_match('#^--([^=]+)=(.*)#', $arg, $reg)) { $args[$reg[1]] = $reg[2]; if ($mutliValueMode) { self::addItemAsArray($args, $reg[1], $reg[2]); } } elseif (preg_match('#^[-]{1,2}([^[:blank:]]+)#', $arg, $reg)) { $nonnull = ''; $args[$reg[1]] = $nonnull; if ($mutliValueMode) { self::addItemAsArray($args, $reg[1], $nonnull); } } else { $args['extraArguments'][] = $arg; } } return $args; }
php
{ "resource": "" }
q246731
CoverageUtils.addItemAsArray
validation
public static function addItemAsArray(&$array, $key, $item) { $array_key = $key . '[]'; if (array_key_exists($array_key, $array)) { $array[$array_key][] = $item; } else { $array[$array_key] = array($item); } }
php
{ "resource": "" }
q246732
ParametersExpectation.describeDifference
validation
protected function describeDifference($expected, $parameters) { if (count($expected) != count($parameters)) { return sprintf( 'Expected %s arguments of [%s], but got %s arguments of [%s]', count($expected), $this->renderArguments($expected), count($parameters), $this->renderArguments($parameters) ); } $messages = array(); for ($i = 0; $i < count($expected); $i++) { $comparison = $this->forceToExpectation($expected[$i]); if (! $comparison->test($parameters[$i])) { $messages[] = 'parameter ' . ($i + 1) . ' with [' . $comparison->overlayMessage($parameters[$i], $this->getDumper()) . ']'; } } return 'Parameter expectation differs at ' . implode(' and ', $messages); }
php
{ "resource": "" }
q246733
ParametersExpectation.renderArguments
validation
protected function renderArguments($args) { $descriptions = array(); if (is_array($args)) { foreach ($args as $arg) { $dumper = new SimpleDumper(); $descriptions[] = $dumper->describeValue($arg); } } return implode(', ', $descriptions); }
php
{ "resource": "" }
q246734
SimpleSignatureMap.add
validation
public function add($parameters, $action) { $place = count($this->map); $this->map[$place] = array(); $this->map[$place]['params'] = new ParametersExpectation($parameters); $this->map[$place]['content'] = $action; }
php
{ "resource": "" }
q246735
SimpleSignatureMap.findFirstAction
validation
public function findFirstAction($parameters) { $slot = $this->findFirstSlot($parameters); if (isset($slot) && isset($slot['content'])) { return $slot['content']; } return; }
php
{ "resource": "" }
q246736
SimpleSignatureMap.findFirstSlot
validation
public function findFirstSlot($parameters) { $count = count($this->map); for ($i = 0; $i < $count; $i++) { if ($this->map[$i]['params']->test($parameters)) { return $this->map[$i]; } } return; }
php
{ "resource": "" }
q246737
SimpleCallSchedule.register
validation
public function register($method, $args, $action) { $args = $this->replaceWildcards($args); $method = strtolower($method); if (! isset($this->always[$method])) { $this->always[$method] = new SimpleSignatureMap(); } $this->always[$method]->add($args, $action); }
php
{ "resource": "" }
q246738
SimpleCallSchedule.registerAt
validation
public function registerAt($step, $method, $args, $action) { $args = $this->replaceWildcards($args); $method = strtolower($method); if (! isset($this->at[$method])) { $this->at[$method] = array(); } if (! isset($this->at[$method][$step])) { $this->at[$method][$step] = new SimpleSignatureMap(); } $this->at[$method][$step]->add($args, $action); }
php
{ "resource": "" }
q246739
SimpleCallSchedule.expectArguments
validation
public function expectArguments($method, $args, $message) { $args = $this->replaceWildcards($args); $message .= Mock::getExpectationLine(); $this->expected_args[strtolower($method)] = new ParametersExpectation($args, $message); }
php
{ "resource": "" }
q246740
SimpleCallSchedule.respond
validation
public function respond($step, $method, $args) { $method = strtolower($method); if (isset($this->at[$method][$step])) { if ($this->at[$method][$step]->isMatch($args)) { $action = $this->at[$method][$step]->findFirstAction($args); if (isset($action)) { return $action->act(); } } } if (isset($this->always[$method])) { $action = $this->always[$method]->findFirstAction($args); if (isset($action)) { return $action->act(); } } return; }
php
{ "resource": "" }
q246741
SimpleCallSchedule.replaceWildcards
validation
protected function replaceWildcards($args) { if ($args === false) { return false; } for ($i = 0; $i < count($args); $i++) { if ($args[$i] === $this->wildcard) { $args[$i] = new AnythingExpectation(); } } return $args; }
php
{ "resource": "" }
q246742
SimpleMock.checkArgumentsIsArray
validation
protected function checkArgumentsIsArray($args, $task) { if (! is_array($args)) { $errormsg = sprintf('Cannot %s. Parameter %s is not an array.', $task, $args); trigger_error($errormsg, E_USER_ERROR); } }
php
{ "resource": "" }
q246743
SimpleMock.dieOnNoMethod
validation
protected function dieOnNoMethod($method, $task) { if ($this->is_strict && ! method_exists($this, $method)) { $errormsg = sprintf('Cannot %s. Method %s() not in class %s.', $task, $method, get_class($this)); trigger_error($errormsg, E_USER_ERROR); } }
php
{ "resource": "" }
q246744
SimpleMock.addCall
validation
protected function addCall($method, $args) { if (! isset($this->call_counts[$method])) { $this->call_counts[$method] = 0; } $this->call_counts[$method]++; }
php
{ "resource": "" }
q246745
SimpleMock.getCallCount
validation
public function getCallCount($method) { $this->dieOnNoMethod($method, 'get call count'); $method = strtolower($method); if (! isset($this->call_counts[$method])) { return 0; } return $this->call_counts[$method]; }
php
{ "resource": "" }
q246746
SimpleMock.returns
validation
public function returns($method, $value, $args = false) { $this->dieOnNoMethod($method, 'set return'); $this->actions->register($method, $args, new SimpleReturn($value)); }
php
{ "resource": "" }
q246747
SimpleMock.returnsAt
validation
public function returnsAt($timing, $method, $value, $args = false) { $this->dieOnNoMethod($method, 'set return value sequence'); $this->actions->registerAt($timing, $method, $args, new SimpleReturn($value)); }
php
{ "resource": "" }
q246748
SimpleMock.returnsByValue
validation
public function returnsByValue($method, $value, $args = false) { $this->dieOnNoMethod($method, 'set return value'); $this->actions->register($method, $args, new SimpleByValue($value)); }
php
{ "resource": "" }
q246749
SimpleMock.returnsByReference
validation
public function returnsByReference($method, &$reference, $args = false) { $this->dieOnNoMethod($method, 'set return reference'); $this->actions->register($method, $args, new SimpleByReference($reference)); }
php
{ "resource": "" }
q246750
SimpleMock.expect
validation
public function expect($method, $args, $message = '%s') { $this->dieOnNoMethod($method, 'set expected arguments'); $this->checkArgumentsIsArray($args, 'set expected arguments'); $this->expectations->expectArguments($method, $args, $message); $args = $this->replaceWildcards($args); $message .= Mock::getExpectationLine(); $this->expected_args[strtolower($method)] = new ParametersExpectation($args, $message); }
php
{ "resource": "" }
q246751
SimpleMock.expectAt
validation
public function expectAt($timing, $method, $args, $message = '%s') { $this->dieOnNoMethod($method, 'set expected arguments at time'); $this->checkArgumentsIsArray($args, 'set expected arguments at time'); $args = $this->replaceWildcards($args); if (! isset($this->expected_args_at[$timing])) { $this->expected_args_at[$timing] = array(); } $method = strtolower($method); $message .= Mock::getExpectationLine(); $this->expected_args_at[$timing][$method] = new ParametersExpectation($args, $message); }
php
{ "resource": "" }
q246752
SimpleMock.expectCallCount
validation
public function expectCallCount($method, $count, $message = '%s') { $this->dieOnNoMethod($method, 'set expected call count'); $message .= Mock::getExpectationLine(); $this->expected_counts[strtolower($method)] = new CallCountExpectation($method, $count, $message); }
php
{ "resource": "" }
q246753
SimpleMock.expectMaximumCallCount
validation
public function expectMaximumCallCount($method, $count, $message = '%s') { $this->dieOnNoMethod($method, 'set maximum call count'); $message .= Mock::getExpectationLine(); $this->max_counts[strtolower($method)] = new MaximumCallCountExpectation($method, $count, $message); }
php
{ "resource": "" }
q246754
SimpleMock.expectMinimumCallCount
validation
public function expectMinimumCallCount($method, $count, $message = '%s') { $this->dieOnNoMethod($method, 'set minimum call count'); $message .= Mock::getExpectationLine(); $this->expected_counts[strtolower($method)] = new MinimumCallCountExpectation($method, $count, $message); }
php
{ "resource": "" }
q246755
SimpleMock.expectOnce
validation
public function expectOnce($method, $args = false, $message = '%s') { $this->expectCallCount($method, 1, $message); if ($args !== false) { $this->expect($method, $args, $message); } }
php
{ "resource": "" }
q246756
SimpleMock.expectAtLeastOnce
validation
public function expectAtLeastOnce($method, $args = false, $message = '%s') { $this->expectMinimumCallCount($method, 1, $message); if ($args !== false) { $this->expect($method, $args, $message); } }
php
{ "resource": "" }
q246757
SimpleMock.errorOn
validation
public function errorOn($method, $error = 'A mock error', $args = false, $severity = E_USER_ERROR) { $this->dieOnNoMethod($method, 'error on'); $this->actions->register($method, $args, new SimpleErrorThrower($error, $severity)); }
php
{ "resource": "" }
q246758
SimpleMock.errorAt
validation
public function errorAt($timing, $method, $error = 'A mock error', $args = false, $severity = E_USER_ERROR) { $this->dieOnNoMethod($method, 'error at'); $this->actions->registerAt($timing, $method, $args, new SimpleErrorThrower($error, $severity)); }
php
{ "resource": "" }
q246759
SimpleMock.invoke
validation
public function invoke($method, $args) { $method = strtolower($method); $step = $this->getCallCount($method); $this->addCall($method, $args); $this->checkExpectations($method, $args, $step); $was = $this->disableEStrict(); try { $result = $this->emulateCall($method, $args, $step); } catch (Exception $e) { $this->restoreEStrict($was); throw $e; } $this->restoreEStrict($was); return $result; }
php
{ "resource": "" }
q246760
SimpleMock.emulateCall
validation
protected function emulateCall($method, $args, $step) { return $this->actions->respond($step, $method, $args); }
php
{ "resource": "" }
q246761
SimpleMock.checkExpectations
validation
protected function checkExpectations($method, $args, $timing) { $test = $this->getCurrentTestCase(); if (isset($this->max_counts[$method])) { if (! $this->max_counts[$method]->test($timing + 1)) { $test->assert($this->max_counts[$method], $timing + 1); } } if (isset($this->expected_args_at[$timing][$method])) { $test->assert( $this->expected_args_at[$timing][$method], $args, "Mock method [$method] at [$timing] -> %s"); } elseif (isset($this->expected_args[$method])) { $test->assert( $this->expected_args[$method], $args, "Mock method [$method] -> %s"); } }
php
{ "resource": "" }
q246762
Mock.generate
validation
public static function generate($class, $mock_class = false, $methods = false) { $generator = new MockGenerator($class, $mock_class); return $generator->generateSubclass($methods); }
php
{ "resource": "" }
q246763
MockGenerator.generate
validation
public function generate($methods) { if (! $this->reflection->classOrInterfaceExists()) { return false; } $mock_reflection = new SimpleReflection($this->mock_class); if ($mock_reflection->classExistsWithoutAutoload()) { return false; } $code = $this->createCodeForClass($methods ? $methods : array()); return eval("$code return \$code;"); }
php
{ "resource": "" }
q246764
MockGenerator.generateSubclass
validation
public function generateSubclass($methods) { if (! $this->reflection->classOrInterfaceExists()) { return false; } $mock_class = ""; if (!empty($this->namespace)) { $mock_class .= $this->namespace . '\\'; } $mock_class .= $this->mock_class; $mock_reflection = new SimpleReflection($mock_class); if ($mock_reflection->classExistsWithoutAutoload()) { return false; } if ($this->reflection->isInterface() || $this->reflection->hasFinal()) { $code = $this->createCodeForClass($methods ? $methods : array()); return eval("$code return \$code;"); } else { $code = $this->createCodeForSubclass($methods ? $methods : array()); return eval("$code return \$code;"); } }
php
{ "resource": "" }
q246765
MockGenerator.generatePartial
validation
public function generatePartial($methods) { if (! $this->reflection->classExists($this->class)) { return false; } $mock_reflection = new SimpleReflection($this->mock_class); if ($mock_reflection->classExistsWithoutAutoload()) { trigger_error('Partial mock class [' . $this->mock_class . '] already exists'); return false; } $code = $this->extendClassCode($methods); return eval("$code return \$code;"); }
php
{ "resource": "" }
q246766
MockGenerator.createCodeForClass
validation
protected function createCodeForClass($methods) { $implements = ''; $interfaces = $this->reflection->getInterfaces(); // exclude interfaces $interfaces = array_diff($interfaces, ['Traversable', 'Throwable']); if (count($interfaces) > 0) { $implements = 'implements ' . implode(', ', $interfaces); } $code = 'class ' . $this->mock_class . ' extends ' . $this->mock_base . ' ' . $implements . " {\n"; $code .= " function __construct() {\n"; $code .= " parent::__construct();\n"; $code .= " }\n"; $code .= $this->createCodeForConstructor(); $code .= $this->createCodeForMethods($methods); $code .= "}\n"; // TODO Reminder, uncomment to see the code of the generated Mock object. //if($this->mock_class === 'MockDummyInterface') { // var_dump($code); //} return $code; }
php
{ "resource": "" }
q246767
MockGenerator.createCodeForSubclass
validation
protected function createCodeForSubclass($methods) { $code = ""; if (!empty($this->namespace)) { $code .= 'namespace ' . $this->namespace . ";\n"; } $code .= 'class ' . $this->mock_class . ' extends ' . $this->class . " {\n"; $code .= " public \$mock;\n"; $code .= $this->addMethodList(array_merge($methods, $this->reflection->getMethods())); $code .= "\n"; $code .= " function __construct() {\n"; $code .= ' $this->mock = new \\' . $this->mock_base . "();\n"; $code .= " \$this->mock->disableExpectationNameChecks();\n"; $code .= " }\n"; $code .= $this->createCodeForConstructor(); $code .= $this->chainMockReturns(); $code .= $this->chainMockExpectations(); $code .= $this->chainThrowMethods(); $code .= $this->createCodeForOverridenMethods($this->reflection->getMethods()); $code .= $this->createCodeForNewMethod($methods); $code .= "}\n"; return $code; }
php
{ "resource": "" }
q246768
MockGenerator.extendClassCode
validation
protected function extendClassCode($methods) { $code = 'class ' . $this->mock_class . ' extends ' . $this->class . " {\n"; $code .= " protected \$mock;\n"; $code .= $this->addMethodList($methods); $code .= "\n"; $code .= " function __construct() {\n"; $code .= ' $this->mock = new ' . $this->mock_base . "();\n"; $code .= " \$this->mock->disableExpectationNameChecks();\n"; $code .= " }\n"; $code .= $this->createCodeForConstructor(); $code .= $this->chainMockReturns(); $code .= $this->chainMockExpectations(); $code .= $this->chainThrowMethods(); $code .= $this->createCodeForOverridenMethods($methods); $code .= "}\n"; return $code; }
php
{ "resource": "" }
q246769
MockGenerator.createCodeForMethods
validation
protected function createCodeForMethods($methods) { $code = ''; $methods = array_merge($methods, $this->reflection->getMethods()); foreach ($methods as $method) { if ($this->isConstructorOrDeconstructor($method)) { continue; } $mock_reflection = new SimpleReflection($this->mock_base); if (in_array($method, $mock_reflection->getMethods())) { continue; } $code .= ' ' . $this->reflection->getSignature($method); if($mock_reflection->isAbstract()) { // abstract function has no body. end the signature statement. $code .= ";\n"; } else { $code .= " {\n"; $code .= " return \$this->invoke(\"$method\", func_get_args());\n"; $code .= " }\n"; } } return $code; }
php
{ "resource": "" }
q246770
MockGenerator.chainMockReturns
validation
protected function chainMockReturns() { $code = " function returns(\$method, \$value, \$args = false) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->returns(\$method, \$value, \$args);\n"; $code .= " }\n"; $code .= " function returnsAt(\$timing, \$method, \$value, \$args = false) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->returnsAt(\$timing, \$method, \$value, \$args);\n"; $code .= " }\n"; $code .= " function returnsByValue(\$method, \$value, \$args = false) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->returns(\$method, \$value, \$args);\n"; $code .= " }\n"; $code .= " function returnsByValueAt(\$timing, \$method, \$value, \$args = false) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->returnsByValueAt(\$timing, \$method, \$value, \$args);\n"; $code .= " }\n"; $code .= " function returnsByReference(\$method, &\$ref, \$args = false) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->returnsByReference(\$method, \$ref, \$args);\n"; $code .= " }\n"; $code .= " function returnsByReferenceAt(\$timing, \$method, &\$ref, \$args = false) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->returnsByReferenceAt(\$timing, \$method, \$ref, \$args);\n"; $code .= " }\n"; return $code; }
php
{ "resource": "" }
q246771
MockGenerator.chainMockExpectations
validation
protected function chainMockExpectations() { $code = " function expect(\$method, \$args = false, \$msg = '%s') {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->expect(\$method, \$args, \$msg);\n"; $code .= " }\n"; $code .= " function expectAt(\$timing, \$method, \$args = false, \$msg = '%s') {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->expectAt(\$timing, \$method, \$args, \$msg);\n"; $code .= " }\n"; $code .= " function expectCallCount(\$method, \$count) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->expectCallCount(\$method, \$count, \$msg = '%s');\n"; $code .= " }\n"; $code .= " function expectMaximumCallCount(\$method, \$count, \$msg = '%s') {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->expectMaximumCallCount(\$method, \$count, \$msg = '%s');\n"; $code .= " }\n"; $code .= " function expectMinimumCallCount(\$method, \$count, \$msg = '%s') {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->expectMinimumCallCount(\$method, \$count, \$msg = '%s');\n"; $code .= " }\n"; $code .= " function expectNever(\$method) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->expectNever(\$method);\n"; $code .= " }\n"; $code .= " function expectOnce(\$method, \$args = false, \$msg = '%s') {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->expectOnce(\$method, \$args, \$msg);\n"; $code .= " }\n"; $code .= " function expectAtLeastOnce(\$method, \$args = false, \$msg = '%s') {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->expectAtLeastOnce(\$method, \$args, \$msg);\n"; $code .= " }\n"; return $code; }
php
{ "resource": "" }
q246772
MockGenerator.chainThrowMethods
validation
protected function chainThrowMethods() { $code = " function throwOn(\$method, \$exception = false, \$args = false) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->throwOn(\$method, \$exception, \$args);\n"; $code .= " }\n"; $code .= " function throwAt(\$timing, \$method, \$exception = false, \$args = false) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->throwAt(\$timing, \$method, \$exception, \$args);\n"; $code .= " }\n"; $code .= " function errorOn(\$method, \$error = 'A mock error', \$args = false, \$severity = E_USER_ERROR) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->errorOn(\$method, \$error, \$args, \$severity);\n"; $code .= " }\n"; $code .= " function errorAt(\$timing, \$method, \$error = 'A mock error', \$args = false, \$severity = E_USER_ERROR) {\n"; $code .= $this->bailOutIfNotMocked('$method'); $code .= " \$this->mock->errorAt(\$timing, \$method, \$error, \$args, \$severity);\n"; $code .= " }\n"; return $code; }
php
{ "resource": "" }
q246773
MockGenerator.createCodeForOverridenMethods
validation
protected function createCodeForOverridenMethods($methods) { $code = ''; foreach ($methods as $method) { if ($this->isConstructorOrDeconstructor($method)) { continue; } $code .= ' ' . $this->reflection->getSignature($method) . " {\n"; $code .= " return \$this->mock->invoke(\"$method\", func_get_args());\n"; $code .= " }\n"; } return $code; }
php
{ "resource": "" }
q246774
TreemapReporter.paintRectangleStart
validation
public function paintRectangleStart($node, $horiz, $vert) { $name = $node->getName(); $description = $node->getDescription(); $status = $node->getStatus(); echo "<div title=\"$name: $description\" class=\"$status\" style=\"width:{$horiz}%;height:{$vert}%\">"; }
php
{ "resource": "" }
q246775
TreemapReporter.paintFooter
validation
public function paintFooter($group) { $aspect = 1; $this->paintResultsHeader(); $this->paintRectangleStart($this->_reporter->getGraph(), 100, 100); $this->divideMapNodes($this->_reporter->getGraph(), $aspect); $this->paintRectangleEnd(); $this->paintResultsFooter(); }
php
{ "resource": "" }
q246776
TreemapReporter.divideMapNodes
validation
public function divideMapNodes($map, $aspect) { $aspect = !$aspect; $divisions = $map->getSize(); $total = $map->getTotalSize(); foreach ($map->getChildren() as $node) { if (!$node->isLeaf()) { $dist = $node->getTotalSize() / $total * 100; } else { $dist = 1 / $total * 100; } if ($aspect) { $horiz = $dist; $vert = 100; } else { $horiz = 100; $vert = $dist; } $this->paintRectangleStart($node, $horiz, $vert); $this->divideMapNodes($node, $aspect); $this->paintRectangleEnd(); } }
php
{ "resource": "" }
q246777
SimpleFrameset.addFrame
validation
public function addFrame($page, $name = false) { $this->frames[] = $page; if ($name) { $this->names[$name] = count($this->frames) - 1; } }
php
{ "resource": "" }
q246778
SimpleFrameset.setFrame
validation
public function setFrame($path, $page) { $name = array_shift($path); if (isset($this->names[$name])) { $index = $this->names[$name]; } else { $index = $name - 1; } if (count($path) === 0) { $this->frames[$index] = $page; return; } $this->frames[$index]->setFrame($path, $page); }
php
{ "resource": "" }
q246779
SimpleFrameset.getFrameFocus
validation
public function getFrameFocus() { if ($this->focus === false) { return array(); } return array_merge( array($this->getPublicNameFromIndex($this->focus)), $this->frames[$this->focus]->getFrameFocus()); }
php
{ "resource": "" }
q246780
SimpleFrameset.getPublicNameFromIndex
validation
protected function getPublicNameFromIndex($subject) { foreach ($this->names as $name => $index) { if ($subject == $index) { return $name; } } return $subject + 1; }
php
{ "resource": "" }
q246781
SimpleFrameset.setFrameFocusByIndex
validation
public function setFrameFocusByIndex($choice) { if (is_integer($this->focus)) { if ($this->frames[$this->focus]->hasFrames()) { return $this->frames[$this->focus]->setFrameFocusByIndex($choice); } } if (($choice < 1) || ($choice > count($this->frames))) { return false; } $this->focus = $choice - 1; return true; }
php
{ "resource": "" }
q246782
SimpleFrameset.setFrameFocus
validation
public function setFrameFocus($name) { if (is_integer($this->focus)) { if ($this->frames[$this->focus]->hasFrames()) { return $this->frames[$this->focus]->setFrameFocus($name); } } if (in_array($name, array_keys($this->names))) { $this->focus = $this->names[$name]; return true; } return false; }
php
{ "resource": "" }
q246783
SimpleFrameset.clearNestedFramesFocus
validation
protected function clearNestedFramesFocus() { for ($i = 0; $i < count($this->frames); $i++) { $this->frames[$i]->clearFrameFocus(); } }
php
{ "resource": "" }
q246784
SimpleFrameset.getFrames
validation
public function getFrames() { $report = array(); for ($i = 0; $i < count($this->frames); $i++) { $report[$this->getPublicNameFromIndex($i)] = $this->frames[$i]->getFrames(); } return $report; }
php
{ "resource": "" }
q246785
SimpleFrameset.getRaw
validation
public function getRaw() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getRaw(); } $raw = ''; for ($i = 0; $i < count($this->frames); $i++) { $raw .= $this->frames[$i]->getRaw(); } return $raw; }
php
{ "resource": "" }
q246786
SimpleFrameset.getText
validation
public function getText() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getText(); } $raw = ''; for ($i = 0; $i < count($this->frames); $i++) { $raw .= ' ' . $this->frames[$i]->getText(); } return trim($raw); }
php
{ "resource": "" }
q246787
SimpleFrameset.getTransportError
validation
public function getTransportError() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getTransportError(); } return $this->frameset->getTransportError(); }
php
{ "resource": "" }
q246788
SimpleFrameset.getMethod
validation
public function getMethod() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getMethod(); } return $this->frameset->getMethod(); }
php
{ "resource": "" }
q246789
SimpleFrameset.getUrl
validation
public function getUrl() { if (is_integer($this->focus)) { $url = $this->frames[$this->focus]->getUrl(); $url->setTarget($this->getPublicNameFromIndex($this->focus)); } else { $url = $this->frameset->getUrl(); } return $url; }
php
{ "resource": "" }
q246790
SimpleFrameset.getBaseUrl
validation
public function getBaseUrl() { if (is_integer($this->focus)) { $url = $this->frames[$this->focus]->getBaseUrl(); } else { $url = $this->frameset->getBaseUrl(); } return $url; }
php
{ "resource": "" }
q246791
SimpleFrameset.getRequestData
validation
public function getRequestData() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getRequestData(); } return $this->frameset->getRequestData(); }
php
{ "resource": "" }
q246792
SimpleFrameset.getMimeType
validation
public function getMimeType() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getMimeType(); } return $this->frameset->getMimeType(); }
php
{ "resource": "" }
q246793
SimpleFrameset.getResponseCode
validation
public function getResponseCode() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getResponseCode(); } return $this->frameset->getResponseCode(); }
php
{ "resource": "" }
q246794
SimpleFrameset.getRequest
validation
public function getRequest() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getRequest(); } return $this->frameset->getRequest(); }
php
{ "resource": "" }
q246795
SimpleFrameset.getHeaders
validation
public function getHeaders() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getHeaders(); } return $this->frameset->getHeaders(); }
php
{ "resource": "" }
q246796
SimpleFrameset.getUrls
validation
public function getUrls() { if (is_integer($this->focus)) { return $this->frames[$this->focus]->getUrls(); } $urls = array(); foreach ($this->frames as $frame) { $urls = array_merge($urls, $frame->getUrls()); } return array_values(array_unique($urls)); }
php
{ "resource": "" }
q246797
SimpleFrameset.getUrlById
validation
public function getUrlById($id) { foreach ($this->frames as $index => $frame) { if ($url = $frame->getUrlById($id)) { if (! $url->gettarget()) { $url->setTarget($this->getPublicNameFromIndex($index)); } return $url; } } return false; }
php
{ "resource": "" }
q246798
SimpleFrameset.tagUrlsWithFrame
validation
protected function tagUrlsWithFrame($urls, $frame) { $tagged = array(); foreach ($urls as $url) { if (! $url->getTarget()) { $url->setTarget($this->getPublicNameFromIndex($frame)); } $tagged[] = $url; } return $tagged; }
php
{ "resource": "" }
q246799
SimpleFrameset.findForm
validation
protected function findForm($method, $attribute) { if (is_integer($this->focus)) { return $this->findFormInFrame( $this->frames[$this->focus], $this->focus, $method, $attribute); } for ($i = 0; $i < count($this->frames); $i++) { $form = $this->findFormInFrame( $this->frames[$i], $i, $method, $attribute); if ($form) { return $form; } } return; }
php
{ "resource": "" }