repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
teepluss/laravel-theme
src/Theme.php
Theme.evaluateConfig
protected function evaluateConfig($config) { if (! isset($config['themes'][$this->theme])) { return $config; } // Config inside a public theme. $minorConfig = $config['themes'][$this->theme]; // Before event is special case, It's combination. if (isset($minorConfig['events']['before'])) { $minorConfig['events']['appendBefore'] = $minorConfig['events']['before']; unset($minorConfig['events']['before']); } // Merge two config into one. $config = array_replace_recursive($config, $minorConfig); // Reset theme config. $config['themes'][$this->theme] = array(); return $config; }
php
protected function evaluateConfig($config) { if (! isset($config['themes'][$this->theme])) { return $config; } // Config inside a public theme. $minorConfig = $config['themes'][$this->theme]; // Before event is special case, It's combination. if (isset($minorConfig['events']['before'])) { $minorConfig['events']['appendBefore'] = $minorConfig['events']['before']; unset($minorConfig['events']['before']); } // Merge two config into one. $config = array_replace_recursive($config, $minorConfig); // Reset theme config. $config['themes'][$this->theme] = array(); return $config; }
[ "protected", "function", "evaluateConfig", "(", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'themes'", "]", "[", "$", "this", "->", "theme", "]", ")", ")", "{", "return", "$", "config", ";", "}", "// Config inside a publ...
Evaluate config. Config minor is at public folder [theme]/config.php, thet can be override package config. @param mixed $config @return mixed
[ "Evaluate", "config", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L320-L342
train
teepluss/laravel-theme
src/Theme.php
Theme.addPathLocation
protected function addPathLocation($location) { // First path is in the selected theme. $hints[] = public_path($location); // This is nice feature to use inherit from another. if ($this->getConfig('inherit')) { // Inherit from theme name. $inherit = $this->getConfig('inherit'); // Inherit theme path. $inheritPath = public_path($this->path($inherit)); if ($this->files->isDirectory($inheritPath)) { array_push($hints, $inheritPath); } } // Add namespace with hinting paths. $this->view->addNamespace($this->getThemeNamespace(), $hints); }
php
protected function addPathLocation($location) { // First path is in the selected theme. $hints[] = public_path($location); // This is nice feature to use inherit from another. if ($this->getConfig('inherit')) { // Inherit from theme name. $inherit = $this->getConfig('inherit'); // Inherit theme path. $inheritPath = public_path($this->path($inherit)); if ($this->files->isDirectory($inheritPath)) { array_push($hints, $inheritPath); } } // Add namespace with hinting paths. $this->view->addNamespace($this->getThemeNamespace(), $hints); }
[ "protected", "function", "addPathLocation", "(", "$", "location", ")", "{", "// First path is in the selected theme.", "$", "hints", "[", "]", "=", "public_path", "(", "$", "location", ")", ";", "// This is nice feature to use inherit from another.", "if", "(", "$", "...
Add location path to look up. @param string $location
[ "Add", "location", "path", "to", "look", "up", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L349-L369
train
teepluss/laravel-theme
src/Theme.php
Theme.fire
public function fire($event, $args) { $onEvent = $this->getConfig('events.'.$event); if ($onEvent instanceof Closure) { $onEvent($args); } }
php
public function fire($event, $args) { $onEvent = $this->getConfig('events.'.$event); if ($onEvent instanceof Closure) { $onEvent($args); } }
[ "public", "function", "fire", "(", "$", "event", ",", "$", "args", ")", "{", "$", "onEvent", "=", "$", "this", "->", "getConfig", "(", "'events.'", ".", "$", "event", ")", ";", "if", "(", "$", "onEvent", "instanceof", "Closure", ")", "{", "$", "onE...
Fire event to config listener. @param string $event @param mixed $args @return void
[ "Fire", "event", "to", "config", "listener", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L378-L385
train
teepluss/laravel-theme
src/Theme.php
Theme.theme
public function theme($theme = null) { // If theme name is not set, so use default from config. if ($theme != false) { $this->theme = $theme; } // Is theme ready? if (! $this->exists($theme)) { throw new UnknownThemeException("Theme [$theme] not found."); } // Add location to look up view. $this->addPathLocation($this->path()); // Fire event before set up a theme. $this->fire('before', $this); // Before from a public theme config. $this->fire('appendBefore', $this); // Add asset path to asset container. $this->asset->addPath($this->path().'/'.$this->getConfig('containerDir.asset')); return $this; }
php
public function theme($theme = null) { // If theme name is not set, so use default from config. if ($theme != false) { $this->theme = $theme; } // Is theme ready? if (! $this->exists($theme)) { throw new UnknownThemeException("Theme [$theme] not found."); } // Add location to look up view. $this->addPathLocation($this->path()); // Fire event before set up a theme. $this->fire('before', $this); // Before from a public theme config. $this->fire('appendBefore', $this); // Add asset path to asset container. $this->asset->addPath($this->path().'/'.$this->getConfig('containerDir.asset')); return $this; }
[ "public", "function", "theme", "(", "$", "theme", "=", "null", ")", "{", "// If theme name is not set, so use default from config.", "if", "(", "$", "theme", "!=", "false", ")", "{", "$", "this", "->", "theme", "=", "$", "theme", ";", "}", "// Is theme ready?"...
Set up a theme name. @param string $theme @throws UnknownThemeException @return Theme
[ "Set", "up", "a", "theme", "name", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L394-L419
train
teepluss/laravel-theme
src/Theme.php
Theme.appendOrPrepend
protected function appendOrPrepend($region, $value, $type = 'append') { // If region not found, create a new region. if (isset($this->regions[$region])) { switch ($type) { case 'prepend' : $this->regions[$region] = $value.$this->regions[$region]; break; case 'append' : $this->regions[$region] .= $value; break; } } else { $this->set($region, $value); } return $this; }
php
protected function appendOrPrepend($region, $value, $type = 'append') { // If region not found, create a new region. if (isset($this->regions[$region])) { switch ($type) { case 'prepend' : $this->regions[$region] = $value.$this->regions[$region]; break; case 'append' : $this->regions[$region] .= $value; break; } } else { $this->set($region, $value); } return $this; }
[ "protected", "function", "appendOrPrepend", "(", "$", "region", ",", "$", "value", ",", "$", "type", "=", "'append'", ")", "{", "// If region not found, create a new region.", "if", "(", "isset", "(", "$", "this", "->", "regions", "[", "$", "region", "]", ")...
Append or prepend existing region. @param string $region @param string $value @param string $type @return Theme
[ "Append", "or", "prepend", "existing", "region", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L516-L533
train
teepluss/laravel-theme
src/Theme.php
Theme.bind
public function bind($variable, $callback = null) { $name = 'bind.'.$variable; // If callback pass, so put in a queue. if (! empty($callback)) { // Preparing callback in to queues. $this->events->listen($name, function() use ($callback, $variable) { return ($callback instanceof Closure) ? $callback() : $callback; }); } // Passing variable to closure. $_events =& $this->events; $_bindings =& $this->bindings; // Buffer processes to save request. return array_get($this->bindings, $name, function() use (&$_events, &$_bindings, $name) { $response = current($_events->fire($name)); array_set($_bindings, $name, $response); return $response; }); }
php
public function bind($variable, $callback = null) { $name = 'bind.'.$variable; // If callback pass, so put in a queue. if (! empty($callback)) { // Preparing callback in to queues. $this->events->listen($name, function() use ($callback, $variable) { return ($callback instanceof Closure) ? $callback() : $callback; }); } // Passing variable to closure. $_events =& $this->events; $_bindings =& $this->bindings; // Buffer processes to save request. return array_get($this->bindings, $name, function() use (&$_events, &$_bindings, $name) { $response = current($_events->fire($name)); array_set($_bindings, $name, $response); return $response; }); }
[ "public", "function", "bind", "(", "$", "variable", ",", "$", "callback", "=", "null", ")", "{", "$", "name", "=", "'bind.'", ".", "$", "variable", ";", "// If callback pass, so put in a queue.", "if", "(", "!", "empty", "(", "$", "callback", ")", ")", "...
Binding data to view. @param string $variable @param mixed $callback @return mixed
[ "Binding", "data", "to", "view", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L542-L564
train
teepluss/laravel-theme
src/Theme.php
Theme.partialWithLayout
public function partialWithLayout($view, $args = array()) { $view = $this->getLayoutName().'.'.$view; return $this->partial($view, $args); }
php
public function partialWithLayout($view, $args = array()) { $view = $this->getLayoutName().'.'.$view; return $this->partial($view, $args); }
[ "public", "function", "partialWithLayout", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "view", "=", "$", "this", "->", "getLayoutName", "(", ")", ".", "'.'", ".", "$", "view", ";", "return", "$", "this", "->", "partia...
The same as "partial", but having prefix layout. @param string $view @param array $args @throws UnknownPartialFileException @return mixed
[ "The", "same", "as", "partial", "but", "having", "prefix", "layout", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L614-L619
train
teepluss/laravel-theme
src/Theme.php
Theme.loadPartial
public function loadPartial($view, $partialDir, $args) { $path = $partialDir.'.'.$view; if (! $this->view->exists($path)) { throw new UnknownPartialFileException("Partial view [$view] not found."); } $partial = $this->view->make($path, $args)->render(); $this->regions[$view] = $partial; return $this->regions[$view]; }
php
public function loadPartial($view, $partialDir, $args) { $path = $partialDir.'.'.$view; if (! $this->view->exists($path)) { throw new UnknownPartialFileException("Partial view [$view] not found."); } $partial = $this->view->make($path, $args)->render(); $this->regions[$view] = $partial; return $this->regions[$view]; }
[ "public", "function", "loadPartial", "(", "$", "view", ",", "$", "partialDir", ",", "$", "args", ")", "{", "$", "path", "=", "$", "partialDir", ".", "'.'", ".", "$", "view", ";", "if", "(", "!", "$", "this", "->", "view", "->", "exists", "(", "$"...
Load a partial @param string $view @param string $partialDir @param array $args @throws UnknownPartialFileException @return mixed
[ "Load", "a", "partial" ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L630-L642
train
teepluss/laravel-theme
src/Theme.php
Theme.widget
public function widget($className, $attributes = array()) { static $widgets = array(); // If the class name is not lead with upper case add prefix "Widget". if (! preg_match('|^[A-Z]|', $className)) { $className = ucfirst($className); } $widgetNamespace = $this->getConfig('namespaces.widget'); $className = $widgetNamespace.'\\'.$className; if (! $instance = array_get($widgets, $className)) { $reflector = new ReflectionClass($className); if (! $reflector->isInstantiable()) { throw new UnknownWidgetClassException("Widget target [$className] is not instantiable."); } $instance = $reflector->newInstance($this, $this->config, $this->view); array_set($widgets, $className, $instance); } $instance->setAttributes($attributes); $instance->beginWidget(); $instance->endWidget(); return $instance; }
php
public function widget($className, $attributes = array()) { static $widgets = array(); // If the class name is not lead with upper case add prefix "Widget". if (! preg_match('|^[A-Z]|', $className)) { $className = ucfirst($className); } $widgetNamespace = $this->getConfig('namespaces.widget'); $className = $widgetNamespace.'\\'.$className; if (! $instance = array_get($widgets, $className)) { $reflector = new ReflectionClass($className); if (! $reflector->isInstantiable()) { throw new UnknownWidgetClassException("Widget target [$className] is not instantiable."); } $instance = $reflector->newInstance($this, $this->config, $this->view); array_set($widgets, $className, $instance); } $instance->setAttributes($attributes); $instance->beginWidget(); $instance->endWidget(); return $instance; }
[ "public", "function", "widget", "(", "$", "className", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "static", "$", "widgets", "=", "array", "(", ")", ";", "// If the class name is not lead with upper case add prefix \"Widget\".", "if", "(", "!", "pr...
Widget instance. @param string $className @param array $attributes @throws UnknownWidgetClassException @return Teepluss\Theme\Widget
[ "Widget", "instance", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L673-L702
train
teepluss/laravel-theme
src/Theme.php
Theme.blader
public function blader($str, $data = array(), $phpCompile = true) { if ($phpCompile == false) { $patterns = array('|<\?|', '|<\?php|', '|<\%|', '|\?>|', '|\%>|'); $replacements = array('&lt;?', '&lt;php', '&lt;%', '?&gt;', '%&gt;'); $str = preg_replace($patterns, $replacements, $str); } // Get blade compiler. $parsed = $this->getCompiler('blade')->compileString($str); ob_start() and extract($data, EXTR_SKIP); try { eval('?>'.$parsed); } catch (\Exception $e) { ob_end_clean(); throw $e; } $str = ob_get_contents(); ob_end_clean(); return $str; }
php
public function blader($str, $data = array(), $phpCompile = true) { if ($phpCompile == false) { $patterns = array('|<\?|', '|<\?php|', '|<\%|', '|\?>|', '|\%>|'); $replacements = array('&lt;?', '&lt;php', '&lt;%', '?&gt;', '%&gt;'); $str = preg_replace($patterns, $replacements, $str); } // Get blade compiler. $parsed = $this->getCompiler('blade')->compileString($str); ob_start() and extract($data, EXTR_SKIP); try { eval('?>'.$parsed); } catch (\Exception $e) { ob_end_clean(); throw $e; } $str = ob_get_contents(); ob_end_clean(); return $str; }
[ "public", "function", "blader", "(", "$", "str", ",", "$", "data", "=", "array", "(", ")", ",", "$", "phpCompile", "=", "true", ")", "{", "if", "(", "$", "phpCompile", "==", "false", ")", "{", "$", "patterns", "=", "array", "(", "'|<\\?|'", ",", ...
Parses and compiles strings by using blade template system. @param string $str @param array $data @param boolean $phpCompile @throws \Exception @return string
[ "Parses", "and", "compiles", "strings", "by", "using", "blade", "template", "system", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L756-L780
train
teepluss/laravel-theme
src/Theme.php
Theme.of
public function of($view, $args = array(), $type = null) { // Layout. $layout = ucfirst($this->layout); // Fire event global assets. $this->fire('asset', $this->asset); // Fire event before render theme. $this->fire('beforeRenderTheme', $this); // Fire event before render layout. $this->fire('beforeRenderLayout.'.$this->layout, $this); // Keeping arguments. $this->arguments = $args; // Compile string blade, string twig, or from file path. switch ($type) { case 'blade' : $content = $this->bladerWithOutServerScript($view, $args); break; case 'twig' : $content = $this->twigy($view, $args); break; default : $content = $this->view->make($view, $args)->render(); break; } // View path of content. $this->content = $view; // Set up a content regional. $this->regions['content'] = $content; return $this; }
php
public function of($view, $args = array(), $type = null) { // Layout. $layout = ucfirst($this->layout); // Fire event global assets. $this->fire('asset', $this->asset); // Fire event before render theme. $this->fire('beforeRenderTheme', $this); // Fire event before render layout. $this->fire('beforeRenderLayout.'.$this->layout, $this); // Keeping arguments. $this->arguments = $args; // Compile string blade, string twig, or from file path. switch ($type) { case 'blade' : $content = $this->bladerWithOutServerScript($view, $args); break; case 'twig' : $content = $this->twigy($view, $args); break; default : $content = $this->view->make($view, $args)->render(); break; } // View path of content. $this->content = $view; // Set up a content regional. $this->regions['content'] = $content; return $this; }
[ "public", "function", "of", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ",", "$", "type", "=", "null", ")", "{", "// Layout.", "$", "layout", "=", "ucfirst", "(", "$", "this", "->", "layout", ")", ";", "// Fire event global assets.", ...
Set up a content to template. @param string $view @param array $args @param string $type @return Theme
[ "Set", "up", "a", "content", "to", "template", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L883-L920
train
teepluss/laravel-theme
src/Theme.php
Theme.ofWithLayout
public function ofWithLayout($view, $args = array(), $type = null) { $view = $this->getLayoutName().'.'.$view; return $this->of($view, $args, $type); }
php
public function ofWithLayout($view, $args = array(), $type = null) { $view = $this->getLayoutName().'.'.$view; return $this->of($view, $args, $type); }
[ "public", "function", "ofWithLayout", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ",", "$", "type", "=", "null", ")", "{", "$", "view", "=", "$", "this", "->", "getLayoutName", "(", ")", ".", "'.'", ".", "$", "view", ";", "return"...
The same as "of", but having prefix layout. @param string $view @param array $args @param string $type @return Theme
[ "The", "same", "as", "of", "but", "having", "prefix", "layout", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L930-L935
train
teepluss/laravel-theme
src/Theme.php
Theme.scope
public function scope($view, $args = array(), $type = null) { $viewDir = $this->getConfig('containerDir.view'); // Add namespace to find in a theme path. $path = $this->getThemeNamespace($viewDir.'.'.$view); return $this->of($path, $args, $type); }
php
public function scope($view, $args = array(), $type = null) { $viewDir = $this->getConfig('containerDir.view'); // Add namespace to find in a theme path. $path = $this->getThemeNamespace($viewDir.'.'.$view); return $this->of($path, $args, $type); }
[ "public", "function", "scope", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ",", "$", "type", "=", "null", ")", "{", "$", "viewDir", "=", "$", "this", "->", "getConfig", "(", "'containerDir.view'", ")", ";", "// Add namespace to find in a ...
Container view. Using a container module view inside a theme, this is useful when you separate a view inside a theme. @param string $view @param array $args @param string $type @return Theme
[ "Container", "view", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L948-L956
train
teepluss/laravel-theme
src/Theme.php
Theme.scopeWithLayout
public function scopeWithLayout($view, $args = array(), $type = null) { $view = $this->getLayoutName().'.'.$view; return $this->scope($view, $args, $type); }
php
public function scopeWithLayout($view, $args = array(), $type = null) { $view = $this->getLayoutName().'.'.$view; return $this->scope($view, $args, $type); }
[ "public", "function", "scopeWithLayout", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ",", "$", "type", "=", "null", ")", "{", "$", "view", "=", "$", "this", "->", "getLayoutName", "(", ")", ".", "'.'", ".", "$", "view", ";", "retu...
The same as "scope", but having prefix layout. @param string $view @param array $args @param string $type @return Theme
[ "The", "same", "as", "scope", "but", "having", "prefix", "layout", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L966-L971
train
teepluss/laravel-theme
src/Theme.php
Theme.load
public function load($view, $args = array()) { $view = ltrim($view, '/'); $segments = explode('/', str_replace('.', '/', $view)); // Pop file from segments. $view = array_pop($segments); // Custom directory path. $pathOfView = app('path.base').'/'.implode('/', $segments); // Add temporary path with a hint type. $this->view->addNamespace('custom', $pathOfView); return $this->of('custom::'.$view, $args); }
php
public function load($view, $args = array()) { $view = ltrim($view, '/'); $segments = explode('/', str_replace('.', '/', $view)); // Pop file from segments. $view = array_pop($segments); // Custom directory path. $pathOfView = app('path.base').'/'.implode('/', $segments); // Add temporary path with a hint type. $this->view->addNamespace('custom', $pathOfView); return $this->of('custom::'.$view, $args); }
[ "public", "function", "load", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "view", "=", "ltrim", "(", "$", "view", ",", "'/'", ")", ";", "$", "segments", "=", "explode", "(", "'/'", ",", "str_replace", "(", "'.'", ...
Load subview from direct path. @param string $view @param array $args @return Theme
[ "Load", "subview", "from", "direct", "path", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L980-L996
train
teepluss/laravel-theme
src/Theme.php
Theme.watch
public function watch($view, $args = array(), $type = null) { try { return $this->scope($view, $args, $type); } catch (\InvalidArgumentException $e) { return $this->of($view, $args, $type); } }
php
public function watch($view, $args = array(), $type = null) { try { return $this->scope($view, $args, $type); } catch (\InvalidArgumentException $e) { return $this->of($view, $args, $type); } }
[ "public", "function", "watch", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ",", "$", "type", "=", "null", ")", "{", "try", "{", "return", "$", "this", "->", "scope", "(", "$", "view", ",", "$", "args", ",", "$", "type", ")", "...
Watch view file in anywhere. Finding from scope first, then try to find from application view. @param string $view @param array $args @param string $type @return Theme
[ "Watch", "view", "file", "in", "anywhere", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L1008-L1015
train
teepluss/laravel-theme
src/Theme.php
Theme.watchWithLayout
public function watchWithLayout($view, $args = array(), $type = null) { try { return $this->scopeWithLayout($view, $args, $type); } catch (\InvalidArgumentException $e) { return $this->ofWithLayout($view, $args, $type); } }
php
public function watchWithLayout($view, $args = array(), $type = null) { try { return $this->scopeWithLayout($view, $args, $type); } catch (\InvalidArgumentException $e) { return $this->ofWithLayout($view, $args, $type); } }
[ "public", "function", "watchWithLayout", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ",", "$", "type", "=", "null", ")", "{", "try", "{", "return", "$", "this", "->", "scopeWithLayout", "(", "$", "view", ",", "$", "args", ",", "$", ...
The same as "watch", but having prefix layout. Finding from scope first, then try to find from application view. @param string $view @param array $args @param string $type @return Theme
[ "The", "same", "as", "watch", "but", "having", "prefix", "layout", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L1027-L1034
train
teepluss/laravel-theme
src/Theme.php
Theme.render
public function render($statusCode = 200) { // Fire the event before render. $this->fire('after', $this); // Flush asset that need to serve. $this->asset->flush(); // Layout directory. $layoutDir = $this->getConfig('containerDir.layout'); $path = $this->getThemeNamespace($layoutDir.'.'.$this->layout); if (! $this->view->exists($path)) { throw new UnknownLayoutFileException("Layout [$this->layout] not found."); } $content = $this->view->make($path)->render(); // Append status code to view. $content = new Response($content, $statusCode); // Having cookie set. if ($this->cookie) { $content->withCookie($this->cookie); } return $content; }
php
public function render($statusCode = 200) { // Fire the event before render. $this->fire('after', $this); // Flush asset that need to serve. $this->asset->flush(); // Layout directory. $layoutDir = $this->getConfig('containerDir.layout'); $path = $this->getThemeNamespace($layoutDir.'.'.$this->layout); if (! $this->view->exists($path)) { throw new UnknownLayoutFileException("Layout [$this->layout] not found."); } $content = $this->view->make($path)->render(); // Append status code to view. $content = new Response($content, $statusCode); // Having cookie set. if ($this->cookie) { $content->withCookie($this->cookie); } return $content; }
[ "public", "function", "render", "(", "$", "statusCode", "=", "200", ")", "{", "// Fire the event before render.", "$", "this", "->", "fire", "(", "'after'", ",", "$", "this", ")", ";", "// Flush asset that need to serve.", "$", "this", "->", "asset", "->", "fl...
Return a template with content. @param integer $statusCode @throws UnknownLayoutFileException @return Response
[ "Return", "a", "template", "with", "content", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Theme.php#L1134-L1162
train
teepluss/laravel-theme
src/Breadcrumb.php
Breadcrumb.add
public function add($label, $url='') { if (is_array($label)) { if (count($label) > 0) foreach ($label as $crumb) { $defaults = [ 'label' => '', 'url' => '' ]; $crumb = array_merge($defaults, $crumb); $this->add($crumb['label'], $crumb['url']); } } else { $label = trim(strip_tags($label, '<i><b><strong>')); if (! preg_match('|^http(s)?|', $url)) { $url = URL::to($url); } $this->crumbs[] = array('label' => $label, 'url' => $url); } return $this; }
php
public function add($label, $url='') { if (is_array($label)) { if (count($label) > 0) foreach ($label as $crumb) { $defaults = [ 'label' => '', 'url' => '' ]; $crumb = array_merge($defaults, $crumb); $this->add($crumb['label'], $crumb['url']); } } else { $label = trim(strip_tags($label, '<i><b><strong>')); if (! preg_match('|^http(s)?|', $url)) { $url = URL::to($url); } $this->crumbs[] = array('label' => $label, 'url' => $url); } return $this; }
[ "public", "function", "add", "(", "$", "label", ",", "$", "url", "=", "''", ")", "{", "if", "(", "is_array", "(", "$", "label", ")", ")", "{", "if", "(", "count", "(", "$", "label", ")", ">", "0", ")", "foreach", "(", "$", "label", "as", "$",...
Add breadcrumb to array. @param mixed $label @param string $url @return Breadcrumb
[ "Add", "breadcrumb", "to", "array", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Breadcrumb.php#L78-L98
train
teepluss/laravel-theme
src/Breadcrumb.php
Breadcrumb.compile
public function compile($template, $data = array()) { $compiler = new BladeCompiler($this->files, 'theme'); // Get blade compiler. $parsed = $compiler->compileString($template); ob_start() and extract($data, EXTR_SKIP); try { eval('?>'.$parsed); } catch (\Exception $e) { ob_end_clean(); throw $e; } $template = ob_get_contents(); ob_end_clean(); return $template; }
php
public function compile($template, $data = array()) { $compiler = new BladeCompiler($this->files, 'theme'); // Get blade compiler. $parsed = $compiler->compileString($template); ob_start() and extract($data, EXTR_SKIP); try { eval('?>'.$parsed); } catch (\Exception $e) { ob_end_clean(); throw $e; } $template = ob_get_contents(); ob_end_clean(); return $template; }
[ "public", "function", "compile", "(", "$", "template", ",", "$", "data", "=", "array", "(", ")", ")", "{", "$", "compiler", "=", "new", "BladeCompiler", "(", "$", "this", "->", "files", ",", "'theme'", ")", ";", "// Get blade compiler.", "$", "parsed", ...
Compile blade template to HTML. @param string $template @param array $data @throws \Exception @return string
[ "Compile", "blade", "template", "to", "HTML", "." ]
244399b8ac60086b29fd94dd9546bb635855ce8a
https://github.com/teepluss/laravel-theme/blob/244399b8ac60086b29fd94dd9546bb635855ce8a/src/Breadcrumb.php#L119-L136
train
laravel/browser-kit-testing
src/Concerns/InteractsWithExceptionHandling.php
InteractsWithExceptionHandling.withExceptionHandling
protected function withExceptionHandling() { if ($this->previousExceptionHandler) { $this->app->instance(ExceptionHandler::class, $this->previousExceptionHandler); } return $this; }
php
protected function withExceptionHandling() { if ($this->previousExceptionHandler) { $this->app->instance(ExceptionHandler::class, $this->previousExceptionHandler); } return $this; }
[ "protected", "function", "withExceptionHandling", "(", ")", "{", "if", "(", "$", "this", "->", "previousExceptionHandler", ")", "{", "$", "this", "->", "app", "->", "instance", "(", "ExceptionHandler", "::", "class", ",", "$", "this", "->", "previousExceptionH...
Restore exception handling. @return $this
[ "Restore", "exception", "handling", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithExceptionHandling.php#L24-L31
train
laravel/browser-kit-testing
src/Concerns/InteractsWithExceptionHandling.php
InteractsWithExceptionHandling.withoutExceptionHandling
protected function withoutExceptionHandling() { $this->previousExceptionHandler = app(ExceptionHandler::class); $this->app->instance(ExceptionHandler::class, new class implements ExceptionHandler { public function __construct() { } public function report(Exception $e) { } public function shouldReport(Exception $e) { return false; } public function render($request, Exception $e) { if ($e instanceof NotFoundHttpException) { throw new NotFoundHttpException( "{$request->method()} {$request->url()}", null, $e->getCode() ); } throw $e; } public function renderForConsole($output, Exception $e) { (new ConsoleApplication)->renderException($e, $output); } }); return $this; }
php
protected function withoutExceptionHandling() { $this->previousExceptionHandler = app(ExceptionHandler::class); $this->app->instance(ExceptionHandler::class, new class implements ExceptionHandler { public function __construct() { } public function report(Exception $e) { } public function shouldReport(Exception $e) { return false; } public function render($request, Exception $e) { if ($e instanceof NotFoundHttpException) { throw new NotFoundHttpException( "{$request->method()} {$request->url()}", null, $e->getCode() ); } throw $e; } public function renderForConsole($output, Exception $e) { (new ConsoleApplication)->renderException($e, $output); } }); return $this; }
[ "protected", "function", "withoutExceptionHandling", "(", ")", "{", "$", "this", "->", "previousExceptionHandler", "=", "app", "(", "ExceptionHandler", "::", "class", ")", ";", "$", "this", "->", "app", "->", "instance", "(", "ExceptionHandler", "::", "class", ...
Disable exception handling for the test. @return $this
[ "Disable", "exception", "handling", "for", "the", "test", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithExceptionHandling.php#L38-L74
train
laravel/browser-kit-testing
src/Constraints/FormFieldConstraint.php
FormFieldConstraint.field
protected function field(Crawler $crawler) { $field = $crawler->filter(implode(', ', $this->getElements())); if ($field->count() > 0) { return $field; } $this->fail($crawler, sprintf( 'There is no %s with the name or ID [%s]', $this->validElements(), $this->selector )); }
php
protected function field(Crawler $crawler) { $field = $crawler->filter(implode(', ', $this->getElements())); if ($field->count() > 0) { return $field; } $this->fail($crawler, sprintf( 'There is no %s with the name or ID [%s]', $this->validElements(), $this->selector )); }
[ "protected", "function", "field", "(", "Crawler", "$", "crawler", ")", "{", "$", "field", "=", "$", "crawler", "->", "filter", "(", "implode", "(", "', '", ",", "$", "this", "->", "getElements", "(", ")", ")", ")", ";", "if", "(", "$", "field", "->...
Get the form field. @param \Symfony\Component\DomCrawler\Crawler $crawler @return \Symfony\Component\DomCrawler\Crawler @throws \PHPUnit\Framework\ExpectationFailedException
[ "Get", "the", "form", "field", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/FormFieldConstraint.php#L53-L65
train
laravel/browser-kit-testing
src/Constraints/FormFieldConstraint.php
FormFieldConstraint.getElements
protected function getElements() { $name = str_replace('#', '', $this->selector); $id = str_replace(['[', ']'], ['\\[', '\\]'], $name); return collect(explode(',', $this->validElements()))->map(function ($element) use ($name, $id) { return "{$element}#{$id}, {$element}[name='{$name}']"; })->all(); }
php
protected function getElements() { $name = str_replace('#', '', $this->selector); $id = str_replace(['[', ']'], ['\\[', '\\]'], $name); return collect(explode(',', $this->validElements()))->map(function ($element) use ($name, $id) { return "{$element}#{$id}, {$element}[name='{$name}']"; })->all(); }
[ "protected", "function", "getElements", "(", ")", "{", "$", "name", "=", "str_replace", "(", "'#'", ",", "''", ",", "$", "this", "->", "selector", ")", ";", "$", "id", "=", "str_replace", "(", "[", "'['", ",", "']'", "]", ",", "[", "'\\\\['", ",", ...
Get the elements relevant to the selector. @return array
[ "Get", "the", "elements", "relevant", "to", "the", "selector", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/FormFieldConstraint.php#L72-L81
train
laravel/browser-kit-testing
src/Concerns/InteractsWithSession.php
InteractsWithSession.session
public function session(array $data) { $this->startSession(); foreach ($data as $key => $value) { $this->app['session']->put($key, $value); } }
php
public function session(array $data) { $this->startSession(); foreach ($data as $key => $value) { $this->app['session']->put($key, $value); } }
[ "public", "function", "session", "(", "array", "$", "data", ")", "{", "$", "this", "->", "startSession", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "app", "[", "'session'", "]", ...
Set the session to the given array. @param array $data @return void
[ "Set", "the", "session", "to", "the", "given", "array", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithSession.php#L28-L35
train
laravel/browser-kit-testing
src/Concerns/InteractsWithSession.php
InteractsWithSession.assertSessionHas
public function assertSessionHas($key, $value = null) { if (is_array($key)) { return $this->assertSessionHasAll($key); } if (is_null($value)) { PHPUnit::assertTrue($this->app['session.store']->has($key), "Session missing key: $key"); } else { PHPUnit::assertEquals($value, $this->app['session.store']->get($key)); } }
php
public function assertSessionHas($key, $value = null) { if (is_array($key)) { return $this->assertSessionHasAll($key); } if (is_null($value)) { PHPUnit::assertTrue($this->app['session.store']->has($key), "Session missing key: $key"); } else { PHPUnit::assertEquals($value, $this->app['session.store']->get($key)); } }
[ "public", "function", "assertSessionHas", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "assertSessionHasAll", "(", "$", "key", ")", ";", "}", "if", "(...
Assert that the session has a given value. @param string|array $key @param mixed $value @return void
[ "Assert", "that", "the", "session", "has", "a", "given", "value", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithSession.php#L82-L93
train
laravel/browser-kit-testing
src/Concerns/InteractsWithSession.php
InteractsWithSession.assertSessionMissing
public function assertSessionMissing($key) { if (is_array($key)) { foreach ($key as $k) { $this->assertSessionMissing($k); } } else { PHPUnit::assertFalse($this->app['session.store']->has($key), "Session has unexpected key: $key"); } }
php
public function assertSessionMissing($key) { if (is_array($key)) { foreach ($key as $k) { $this->assertSessionMissing($k); } } else { PHPUnit::assertFalse($this->app['session.store']->has($key), "Session has unexpected key: $key"); } }
[ "public", "function", "assertSessionMissing", "(", "$", "key", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "foreach", "(", "$", "key", "as", "$", "k", ")", "{", "$", "this", "->", "assertSessionMissing", "(", "$", "k", ")", ";"...
Assert that the session does not have a given key. @param string|array $key @return void
[ "Assert", "that", "the", "session", "does", "not", "have", "a", "given", "key", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithSession.php#L118-L127
train
laravel/browser-kit-testing
src/Concerns/InteractsWithSession.php
InteractsWithSession.assertSessionHasErrors
public function assertSessionHasErrors($bindings = [], $format = null) { $this->assertSessionHas('errors'); $bindings = (array) $bindings; $errors = $this->app['session.store']->get('errors'); foreach ($bindings as $key => $value) { if (is_int($key)) { PHPUnit::assertTrue($errors->has($value), "Session missing error: $value"); } else { PHPUnit::assertContains($value, $errors->get($key, $format)); } } }
php
public function assertSessionHasErrors($bindings = [], $format = null) { $this->assertSessionHas('errors'); $bindings = (array) $bindings; $errors = $this->app['session.store']->get('errors'); foreach ($bindings as $key => $value) { if (is_int($key)) { PHPUnit::assertTrue($errors->has($value), "Session missing error: $value"); } else { PHPUnit::assertContains($value, $errors->get($key, $format)); } } }
[ "public", "function", "assertSessionHasErrors", "(", "$", "bindings", "=", "[", "]", ",", "$", "format", "=", "null", ")", "{", "$", "this", "->", "assertSessionHas", "(", "'errors'", ")", ";", "$", "bindings", "=", "(", "array", ")", "$", "bindings", ...
Assert that the session has errors bound. @param string|array $bindings @param mixed $format @return void
[ "Assert", "that", "the", "session", "has", "errors", "bound", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithSession.php#L136-L151
train
laravel/browser-kit-testing
src/Constraints/IsChecked.php
IsChecked.matches
public function matches($crawler): bool { $crawler = $this->crawler($crawler); return ! is_null($this->field($crawler)->attr('checked')); }
php
public function matches($crawler): bool { $crawler = $this->crawler($crawler); return ! is_null($this->field($crawler)->attr('checked')); }
[ "public", "function", "matches", "(", "$", "crawler", ")", ":", "bool", "{", "$", "crawler", "=", "$", "this", "->", "crawler", "(", "$", "crawler", ")", ";", "return", "!", "is_null", "(", "$", "this", "->", "field", "(", "$", "crawler", ")", "->"...
Determine if the checkbox is checked. @param \Symfony\Component\DomCrawler\Crawler|string $crawler @return bool
[ "Determine", "if", "the", "checkbox", "is", "checked", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/IsChecked.php#L34-L39
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.makeRequest
protected function makeRequest($method, $uri, $parameters = [], $cookies = [], $files = []) { $uri = $this->prepareUrlForRequest($uri); $this->call($method, $uri, $parameters, $cookies, $files); $this->clearInputs()->followRedirects()->assertPageLoaded($uri); $this->currentUri = $this->app->make('request')->fullUrl(); $this->crawler = new Crawler($this->response->getContent(), $this->currentUri); return $this; }
php
protected function makeRequest($method, $uri, $parameters = [], $cookies = [], $files = []) { $uri = $this->prepareUrlForRequest($uri); $this->call($method, $uri, $parameters, $cookies, $files); $this->clearInputs()->followRedirects()->assertPageLoaded($uri); $this->currentUri = $this->app->make('request')->fullUrl(); $this->crawler = new Crawler($this->response->getContent(), $this->currentUri); return $this; }
[ "protected", "function", "makeRequest", "(", "$", "method", ",", "$", "uri", ",", "$", "parameters", "=", "[", "]", ",", "$", "cookies", "=", "[", "]", ",", "$", "files", "=", "[", "]", ")", "{", "$", "uri", "=", "$", "this", "->", "prepareUrlFor...
Make a request to the application and create a Crawler instance. @param string $method @param string $uri @param array $parameters @param array $cookies @param array $files @return $this
[ "Make", "a", "request", "to", "the", "application", "and", "create", "a", "Crawler", "instance", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L86-L99
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.makeRequestUsingForm
protected function makeRequestUsingForm(Form $form, array $uploads = []) { $files = $this->convertUploadsForTesting($form, $uploads); return $this->makeRequest( $form->getMethod(), $form->getUri(), $this->extractParametersFromForm($form), [], $files ); }
php
protected function makeRequestUsingForm(Form $form, array $uploads = []) { $files = $this->convertUploadsForTesting($form, $uploads); return $this->makeRequest( $form->getMethod(), $form->getUri(), $this->extractParametersFromForm($form), [], $files ); }
[ "protected", "function", "makeRequestUsingForm", "(", "Form", "$", "form", ",", "array", "$", "uploads", "=", "[", "]", ")", "{", "$", "files", "=", "$", "this", "->", "convertUploadsForTesting", "(", "$", "form", ",", "$", "uploads", ")", ";", "return",...
Make a request to the application using the given form. @param \Symfony\Component\DomCrawler\Form $form @param array $uploads @return $this
[ "Make", "a", "request", "to", "the", "application", "using", "the", "given", "form", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L120-L127
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.followRedirects
protected function followRedirects() { while ($this->response->isRedirect()) { $this->makeRequest('GET', $this->response->getTargetUrl()); } return $this; }
php
protected function followRedirects() { while ($this->response->isRedirect()) { $this->makeRequest('GET', $this->response->getTargetUrl()); } return $this; }
[ "protected", "function", "followRedirects", "(", ")", "{", "while", "(", "$", "this", "->", "response", "->", "isRedirect", "(", ")", ")", "{", "$", "this", "->", "makeRequest", "(", "'GET'", ",", "$", "this", "->", "response", "->", "getTargetUrl", "(",...
Follow redirects from the last response. @return $this
[ "Follow", "redirects", "from", "the", "last", "response", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L147-L154
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.seePageIs
protected function seePageIs($uri) { $this->assertPageLoaded($uri = $this->prepareUrlForRequest($uri)); $this->assertEquals( $uri, $this->currentUri, "Did not land on expected page [{$uri}].\n" ); return $this; }
php
protected function seePageIs($uri) { $this->assertPageLoaded($uri = $this->prepareUrlForRequest($uri)); $this->assertEquals( $uri, $this->currentUri, "Did not land on expected page [{$uri}].\n" ); return $this; }
[ "protected", "function", "seePageIs", "(", "$", "uri", ")", "{", "$", "this", "->", "assertPageLoaded", "(", "$", "uri", "=", "$", "this", "->", "prepareUrlForRequest", "(", "$", "uri", ")", ")", ";", "$", "this", "->", "assertEquals", "(", "$", "uri",...
Assert that the current page matches a given URI. @param string $uri @return $this
[ "Assert", "that", "the", "current", "page", "matches", "a", "given", "URI", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L176-L185
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.assertPageLoaded
protected function assertPageLoaded($uri, $message = null) { $status = $this->response->getStatusCode(); try { $this->assertEquals(200, $status); } catch (PHPUnitException $e) { $message = $message ?: "A request to [{$uri}] failed. Received status code [{$status}]."; if (isset($this->response->exception)) { throw new HttpException($message, 0, $this->response->exception); } throw new HttpException($message); } }
php
protected function assertPageLoaded($uri, $message = null) { $status = $this->response->getStatusCode(); try { $this->assertEquals(200, $status); } catch (PHPUnitException $e) { $message = $message ?: "A request to [{$uri}] failed. Received status code [{$status}]."; if (isset($this->response->exception)) { throw new HttpException($message, 0, $this->response->exception); } throw new HttpException($message); } }
[ "protected", "function", "assertPageLoaded", "(", "$", "uri", ",", "$", "message", "=", "null", ")", "{", "$", "status", "=", "$", "this", "->", "response", "->", "getStatusCode", "(", ")", ";", "try", "{", "$", "this", "->", "assertEquals", "(", "200"...
Assert that a given page successfully loaded. @param string $uri @param string|null $message @return void @throws \Laravel\BrowserKitTesting\HttpException
[ "Assert", "that", "a", "given", "page", "successfully", "loaded", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L208-L223
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.within
public function within($element, Closure $callback) { $this->subCrawlers[] = $this->crawler()->filter($element); $callback(); array_pop($this->subCrawlers); return $this; }
php
public function within($element, Closure $callback) { $this->subCrawlers[] = $this->crawler()->filter($element); $callback(); array_pop($this->subCrawlers); return $this; }
[ "public", "function", "within", "(", "$", "element", ",", "Closure", "$", "callback", ")", "{", "$", "this", "->", "subCrawlers", "[", "]", "=", "$", "this", "->", "crawler", "(", ")", "->", "filter", "(", "$", "element", ")", ";", "$", "callback", ...
Narrow the test content to a specific area of the page. @param string $element @param \Closure $callback @return $this
[ "Narrow", "the", "test", "content", "to", "a", "specific", "area", "of", "the", "page", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L232-L241
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.assertInPage
protected function assertInPage(PageConstraint $constraint, $reverse = false, $message = '') { if ($reverse) { $constraint = new ReversePageConstraint($constraint); } self::assertThat( $this->crawler() ?: $this->response->getContent(), $constraint, $message ); return $this; }
php
protected function assertInPage(PageConstraint $constraint, $reverse = false, $message = '') { if ($reverse) { $constraint = new ReversePageConstraint($constraint); } self::assertThat( $this->crawler() ?: $this->response->getContent(), $constraint, $message ); return $this; }
[ "protected", "function", "assertInPage", "(", "PageConstraint", "$", "constraint", ",", "$", "reverse", "=", "false", ",", "$", "message", "=", "''", ")", "{", "if", "(", "$", "reverse", ")", "{", "$", "constraint", "=", "new", "ReversePageConstraint", "("...
Assert the given constraint. @param \Laravel\BrowserKitTesting\Constraints\PageConstraint $constraint @param bool $reverse @param string $message @return $this
[ "Assert", "the", "given", "constraint", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L265-L277
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.seeElement
public function seeElement($selector, array $attributes = [], $negate = false) { return $this->assertInPage(new HasElement($selector, $attributes), $negate); }
php
public function seeElement($selector, array $attributes = [], $negate = false) { return $this->assertInPage(new HasElement($selector, $attributes), $negate); }
[ "public", "function", "seeElement", "(", "$", "selector", ",", "array", "$", "attributes", "=", "[", "]", ",", "$", "negate", "=", "false", ")", "{", "return", "$", "this", "->", "assertInPage", "(", "new", "HasElement", "(", "$", "selector", ",", "$",...
Assert that an element is present on the page. @param string $selector @param array $attributes @param bool $negate @return $this
[ "Assert", "that", "an", "element", "is", "present", "on", "the", "page", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L310-L313
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.seeElementCount
public function seeElementCount($selector, $count) { $this->assertCount($count, $this->crawler->filter($selector)); return $this; }
php
public function seeElementCount($selector, $count) { $this->assertCount($count, $this->crawler->filter($selector)); return $this; }
[ "public", "function", "seeElementCount", "(", "$", "selector", ",", "$", "count", ")", "{", "$", "this", "->", "assertCount", "(", "$", "count", ",", "$", "this", "->", "crawler", "->", "filter", "(", "$", "selector", ")", ")", ";", "return", "$", "t...
Verify the number of DOM elements. @param string $selector @param int $number @return $this
[ "Verify", "the", "number", "of", "DOM", "elements", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L334-L339
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.seeInElement
public function seeInElement($element, $text, $negate = false) { return $this->assertInPage(new HasInElement($element, $text), $negate); }
php
public function seeInElement($element, $text, $negate = false) { return $this->assertInPage(new HasInElement($element, $text), $negate); }
[ "public", "function", "seeInElement", "(", "$", "element", ",", "$", "text", ",", "$", "negate", "=", "false", ")", "{", "return", "$", "this", "->", "assertInPage", "(", "new", "HasInElement", "(", "$", "element", ",", "$", "text", ")", ",", "$", "n...
Assert that a given string is seen inside an element. @param string $element @param string $text @param bool $negate @return $this
[ "Assert", "that", "a", "given", "string", "is", "seen", "inside", "an", "element", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L372-L375
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.seeLink
public function seeLink($text, $url = null, $negate = false) { return $this->assertInPage(new HasLink($text, $url), $negate); }
php
public function seeLink($text, $url = null, $negate = false) { return $this->assertInPage(new HasLink($text, $url), $negate); }
[ "public", "function", "seeLink", "(", "$", "text", ",", "$", "url", "=", "null", ",", "$", "negate", "=", "false", ")", "{", "return", "$", "this", "->", "assertInPage", "(", "new", "HasLink", "(", "$", "text", ",", "$", "url", ")", ",", "$", "ne...
Assert that a given link is seen on the page. @param string $text @param string|null $url @param bool $negate @return $this
[ "Assert", "that", "a", "given", "link", "is", "seen", "on", "the", "page", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L397-L400
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.dontSeeLink
public function dontSeeLink($text, $url = null) { return $this->assertInPage(new HasLink($text, $url), true); }
php
public function dontSeeLink($text, $url = null) { return $this->assertInPage(new HasLink($text, $url), true); }
[ "public", "function", "dontSeeLink", "(", "$", "text", ",", "$", "url", "=", "null", ")", "{", "return", "$", "this", "->", "assertInPage", "(", "new", "HasLink", "(", "$", "text", ",", "$", "url", ")", ",", "true", ")", ";", "}" ]
Assert that a given link is not seen on the page. @param string $text @param string|null $url @return $this
[ "Assert", "that", "a", "given", "link", "is", "not", "seen", "on", "the", "page", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L409-L412
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.seeInField
public function seeInField($selector, $expected, $negate = false) { return $this->assertInPage(new HasValue($selector, $expected), $negate); }
php
public function seeInField($selector, $expected, $negate = false) { return $this->assertInPage(new HasValue($selector, $expected), $negate); }
[ "public", "function", "seeInField", "(", "$", "selector", ",", "$", "expected", ",", "$", "negate", "=", "false", ")", "{", "return", "$", "this", "->", "assertInPage", "(", "new", "HasValue", "(", "$", "selector", ",", "$", "expected", ")", ",", "$", ...
Assert that an input field contains the given value. @param string $selector @param string $expected @param bool $negate @return $this
[ "Assert", "that", "an", "input", "field", "contains", "the", "given", "value", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L422-L425
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.seeIsSelected
public function seeIsSelected($selector, $value, $negate = false) { return $this->assertInPage(new IsSelected($selector, $value), $negate); }
php
public function seeIsSelected($selector, $value, $negate = false) { return $this->assertInPage(new IsSelected($selector, $value), $negate); }
[ "public", "function", "seeIsSelected", "(", "$", "selector", ",", "$", "value", ",", "$", "negate", "=", "false", ")", "{", "return", "$", "this", "->", "assertInPage", "(", "new", "IsSelected", "(", "$", "selector", ",", "$", "value", ")", ",", "$", ...
Assert that the expected value is selected. @param string $selector @param string $value @param bool $negate @return $this
[ "Assert", "that", "the", "expected", "value", "is", "selected", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L447-L450
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.click
protected function click($name) { $link = $this->crawler()->selectLink($name); if (! count($link)) { $link = $this->filterByNameOrId($name, 'a'); if (! count($link)) { throw new InvalidArgumentException( "Could not find a link with a body, name, or ID attribute of [{$name}]." ); } } $this->visit($link->link()->getUri()); return $this; }
php
protected function click($name) { $link = $this->crawler()->selectLink($name); if (! count($link)) { $link = $this->filterByNameOrId($name, 'a'); if (! count($link)) { throw new InvalidArgumentException( "Could not find a link with a body, name, or ID attribute of [{$name}]." ); } } $this->visit($link->link()->getUri()); return $this; }
[ "protected", "function", "click", "(", "$", "name", ")", "{", "$", "link", "=", "$", "this", "->", "crawler", "(", ")", "->", "selectLink", "(", "$", "name", ")", ";", "if", "(", "!", "count", "(", "$", "link", ")", ")", "{", "$", "link", "=", ...
Click a link with the given body, name, or ID attribute. @param string $name @return $this @throws \InvalidArgumentException
[ "Click", "a", "link", "with", "the", "given", "body", "name", "or", "ID", "attribute", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L495-L512
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.attach
protected function attach($absolutePath, $element) { $this->uploads[$element] = $absolutePath; return $this->storeInput($element, $absolutePath); }
php
protected function attach($absolutePath, $element) { $this->uploads[$element] = $absolutePath; return $this->storeInput($element, $absolutePath); }
[ "protected", "function", "attach", "(", "$", "absolutePath", ",", "$", "element", ")", "{", "$", "this", "->", "uploads", "[", "$", "element", "]", "=", "$", "absolutePath", ";", "return", "$", "this", "->", "storeInput", "(", "$", "element", ",", "$",...
Attach a file to a form field on the page. @param string $absolutePath @param string $element @return $this
[ "Attach", "a", "file", "to", "a", "form", "field", "on", "the", "page", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L567-L572
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.submitForm
protected function submitForm($buttonText, $inputs = [], $uploads = []) { $this->makeRequestUsingForm($this->fillForm($buttonText, $inputs), $uploads); return $this; }
php
protected function submitForm($buttonText, $inputs = [], $uploads = []) { $this->makeRequestUsingForm($this->fillForm($buttonText, $inputs), $uploads); return $this; }
[ "protected", "function", "submitForm", "(", "$", "buttonText", ",", "$", "inputs", "=", "[", "]", ",", "$", "uploads", "=", "[", "]", ")", "{", "$", "this", "->", "makeRequestUsingForm", "(", "$", "this", "->", "fillForm", "(", "$", "buttonText", ",", ...
Submit a form on the page with the given input. @param string $buttonText @param array $inputs @param array $uploads @return $this
[ "Submit", "a", "form", "on", "the", "page", "with", "the", "given", "input", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L593-L598
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.fillForm
protected function fillForm($buttonText, $inputs = []) { if (! is_string($buttonText)) { $inputs = $buttonText; $buttonText = null; } return $this->getForm($buttonText)->setValues($inputs); }
php
protected function fillForm($buttonText, $inputs = []) { if (! is_string($buttonText)) { $inputs = $buttonText; $buttonText = null; } return $this->getForm($buttonText)->setValues($inputs); }
[ "protected", "function", "fillForm", "(", "$", "buttonText", ",", "$", "inputs", "=", "[", "]", ")", "{", "if", "(", "!", "is_string", "(", "$", "buttonText", ")", ")", "{", "$", "inputs", "=", "$", "buttonText", ";", "$", "buttonText", "=", "null", ...
Fill the form with the given data. @param string $buttonText @param array $inputs @return \Symfony\Component\DomCrawler\Form
[ "Fill", "the", "form", "with", "the", "given", "data", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L607-L616
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.getForm
protected function getForm($buttonText = null) { try { if ($buttonText) { return $this->crawler()->selectButton($buttonText)->form(); } return $this->crawler()->filter('form')->form(); } catch (InvalidArgumentException $e) { throw new InvalidArgumentException( "Could not find a form that has submit button [{$buttonText}]." ); } }
php
protected function getForm($buttonText = null) { try { if ($buttonText) { return $this->crawler()->selectButton($buttonText)->form(); } return $this->crawler()->filter('form')->form(); } catch (InvalidArgumentException $e) { throw new InvalidArgumentException( "Could not find a form that has submit button [{$buttonText}]." ); } }
[ "protected", "function", "getForm", "(", "$", "buttonText", "=", "null", ")", "{", "try", "{", "if", "(", "$", "buttonText", ")", "{", "return", "$", "this", "->", "crawler", "(", ")", "->", "selectButton", "(", "$", "buttonText", ")", "->", "form", ...
Get the form from the page with the given submit button text. @param string|null $buttonText @return \Symfony\Component\DomCrawler\Form @throws \InvalidArgumentException
[ "Get", "the", "form", "from", "the", "page", "with", "the", "given", "submit", "button", "text", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L626-L639
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.storeInput
protected function storeInput($element, $text) { $this->assertFilterProducesResults($element); $element = str_replace(['#', '[]'], '', $element); $this->inputs[$element] = $text; return $this; }
php
protected function storeInput($element, $text) { $this->assertFilterProducesResults($element); $element = str_replace(['#', '[]'], '', $element); $this->inputs[$element] = $text; return $this; }
[ "protected", "function", "storeInput", "(", "$", "element", ",", "$", "text", ")", "{", "$", "this", "->", "assertFilterProducesResults", "(", "$", "element", ")", ";", "$", "element", "=", "str_replace", "(", "[", "'#'", ",", "'[]'", "]", ",", "''", "...
Store a form input in the local array. @param string $element @param string $text @return $this
[ "Store", "a", "form", "input", "in", "the", "local", "array", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L648-L657
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.filterByNameOrId
protected function filterByNameOrId($name, $elements = '*') { $name = str_replace('#', '', $name); $id = str_replace(['[', ']'], ['\\[', '\\]'], $name); $elements = is_array($elements) ? $elements : [$elements]; array_walk($elements, function (&$element) use ($name, $id) { $element = "{$element}#{$id}, {$element}[name='{$name}']"; }); return $this->crawler()->filter(implode(', ', $elements)); }
php
protected function filterByNameOrId($name, $elements = '*') { $name = str_replace('#', '', $name); $id = str_replace(['[', ']'], ['\\[', '\\]'], $name); $elements = is_array($elements) ? $elements : [$elements]; array_walk($elements, function (&$element) use ($name, $id) { $element = "{$element}#{$id}, {$element}[name='{$name}']"; }); return $this->crawler()->filter(implode(', ', $elements)); }
[ "protected", "function", "filterByNameOrId", "(", "$", "name", ",", "$", "elements", "=", "'*'", ")", "{", "$", "name", "=", "str_replace", "(", "'#'", ",", "''", ",", "$", "name", ")", ";", "$", "id", "=", "str_replace", "(", "[", "'['", ",", "']'...
Filter elements according to the given name or ID attribute. @param string $name @param array|string $elements @return \Symfony\Component\DomCrawler\Crawler
[ "Filter", "elements", "according", "to", "the", "given", "name", "or", "ID", "attribute", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L685-L698
train
laravel/browser-kit-testing
src/Concerns/InteractsWithPages.php
InteractsWithPages.prepareArrayBasedFileInput
protected function prepareArrayBasedFileInput(&$uploads, $key, $file) { preg_match_all('/([^\[\]]+)/', $key, $segments); $segments = array_reverse($segments[1]); $newKey = array_pop($segments); foreach ($segments as $segment) { $file = [$segment => $file]; } $uploads[$newKey] = $file; unset($uploads[$key]); }
php
protected function prepareArrayBasedFileInput(&$uploads, $key, $file) { preg_match_all('/([^\[\]]+)/', $key, $segments); $segments = array_reverse($segments[1]); $newKey = array_pop($segments); foreach ($segments as $segment) { $file = [$segment => $file]; } $uploads[$newKey] = $file; unset($uploads[$key]); }
[ "protected", "function", "prepareArrayBasedFileInput", "(", "&", "$", "uploads", ",", "$", "key", ",", "$", "file", ")", "{", "preg_match_all", "(", "'/([^\\[\\]]+)/'", ",", "$", "key", ",", "$", "segments", ")", ";", "$", "segments", "=", "array_reverse", ...
Store an array based file upload with the proper nested array structure. @param array $uploads @param string $key @param mixed $file
[ "Store", "an", "array", "based", "file", "upload", "with", "the", "proper", "nested", "array", "structure", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithPages.php#L735-L750
train
laravel/browser-kit-testing
src/Constraints/PageConstraint.php
PageConstraint.getEscapedPattern
protected function getEscapedPattern($text) { $rawPattern = preg_quote($text, '/'); $escapedPattern = preg_quote(e($text), '/'); return $rawPattern == $escapedPattern ? $rawPattern : "({$rawPattern}|{$escapedPattern})"; }
php
protected function getEscapedPattern($text) { $rawPattern = preg_quote($text, '/'); $escapedPattern = preg_quote(e($text), '/'); return $rawPattern == $escapedPattern ? $rawPattern : "({$rawPattern}|{$escapedPattern})"; }
[ "protected", "function", "getEscapedPattern", "(", "$", "text", ")", "{", "$", "rawPattern", "=", "preg_quote", "(", "$", "text", ",", "'/'", ")", ";", "$", "escapedPattern", "=", "preg_quote", "(", "e", "(", "$", "text", ")", ",", "'/'", ")", ";", "...
Get the escaped text pattern for the constraint. @param string $text @return string
[ "Get", "the", "escaped", "text", "pattern", "for", "the", "constraint", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/PageConstraint.php#L51-L59
train
laravel/browser-kit-testing
src/Constraints/PageConstraint.php
PageConstraint.fail
protected function fail($crawler, $description, ComparisonFailure $comparisonFailure = null): void { $html = $this->html($crawler); $failureDescription = sprintf( "%s\n\n\nFailed asserting that %s", $html, $this->getFailureDescription() ); if (! empty($description)) { $failureDescription .= ": {$description}"; } if (trim($html) != '') { $failureDescription .= '. Please check the content above.'; } else { $failureDescription .= '. The response is empty.'; } throw new ExpectationFailedException($failureDescription, $comparisonFailure); }
php
protected function fail($crawler, $description, ComparisonFailure $comparisonFailure = null): void { $html = $this->html($crawler); $failureDescription = sprintf( "%s\n\n\nFailed asserting that %s", $html, $this->getFailureDescription() ); if (! empty($description)) { $failureDescription .= ": {$description}"; } if (trim($html) != '') { $failureDescription .= '. Please check the content above.'; } else { $failureDescription .= '. The response is empty.'; } throw new ExpectationFailedException($failureDescription, $comparisonFailure); }
[ "protected", "function", "fail", "(", "$", "crawler", ",", "$", "description", ",", "ComparisonFailure", "$", "comparisonFailure", "=", "null", ")", ":", "void", "{", "$", "html", "=", "$", "this", "->", "html", "(", "$", "crawler", ")", ";", "$", "fai...
Throw an exception for the given comparison and test description. @param \Symfony\Component\DomCrawler\Crawler|string $crawler @param string $description @param \SebastianBergmann\Comparator\ComparisonFailure|null $comparisonFailure @return void @throws \PHPUnit\Framework\ExpectationFailedException
[ "Throw", "an", "exception", "for", "the", "given", "comparison", "and", "test", "description", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/PageConstraint.php#L71-L91
train
laravel/browser-kit-testing
src/Concerns/MocksApplicationServices.php
MocksApplicationServices.withoutEvents
protected function withoutEvents() { $mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher'); $mock->shouldReceive('fire', 'dispatch', 'getCommandHandler')->andReturnUsing(function ($called) { $this->firedEvents[] = $called; }); $this->app->instance('events', $mock); return $this; }
php
protected function withoutEvents() { $mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher'); $mock->shouldReceive('fire', 'dispatch', 'getCommandHandler')->andReturnUsing(function ($called) { $this->firedEvents[] = $called; }); $this->app->instance('events', $mock); return $this; }
[ "protected", "function", "withoutEvents", "(", ")", "{", "$", "mock", "=", "Mockery", "::", "mock", "(", "'Illuminate\\Contracts\\Events\\Dispatcher'", ")", ";", "$", "mock", "->", "shouldReceive", "(", "'fire'", ",", "'dispatch'", ",", "'getCommandHandler'", ")",...
Mock the event dispatcher so all events are silenced and collected. @return $this
[ "Mock", "the", "event", "dispatcher", "so", "all", "events", "are", "silenced", "and", "collected", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MocksApplicationServices.php#L97-L108
train
laravel/browser-kit-testing
src/Concerns/MocksApplicationServices.php
MocksApplicationServices.withoutModelEvents
protected function withoutModelEvents() { $mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher'); $mock->shouldReceive('dispatch')->andReturnUsing(function ($called) { $this->firedModelEvents[] = $called; }); $mock->shouldReceive('until')->andReturnUsing(function ($called) { $this->firedModelEvents[] = $called; return true; }); $mock->shouldReceive('listen')->andReturnUsing(function ($event, $listener) { // }); Model::setEventDispatcher($mock); return $this; }
php
protected function withoutModelEvents() { $mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher'); $mock->shouldReceive('dispatch')->andReturnUsing(function ($called) { $this->firedModelEvents[] = $called; }); $mock->shouldReceive('until')->andReturnUsing(function ($called) { $this->firedModelEvents[] = $called; return true; }); $mock->shouldReceive('listen')->andReturnUsing(function ($event, $listener) { // }); Model::setEventDispatcher($mock); return $this; }
[ "protected", "function", "withoutModelEvents", "(", ")", "{", "$", "mock", "=", "Mockery", "::", "mock", "(", "'Illuminate\\Contracts\\Events\\Dispatcher'", ")", ";", "$", "mock", "->", "shouldReceive", "(", "'dispatch'", ")", "->", "andReturnUsing", "(", "functio...
Mock the model event dispatcher so all Eloquent events are silenced. @return $this
[ "Mock", "the", "model", "event", "dispatcher", "so", "all", "Eloquent", "events", "are", "silenced", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MocksApplicationServices.php#L189-L210
train
laravel/browser-kit-testing
src/Concerns/MocksApplicationServices.php
MocksApplicationServices.withoutObservers
public function withoutObservers($observers) { $observers = is_array($observers) ? $observers : [$observers]; array_map(function ($observer) { $this->app->bind($observer, function () use ($observer) { return $this->getMockBuilder($observer)->disableOriginalConstructor()->getMock(); }); }, $observers); return $this; }
php
public function withoutObservers($observers) { $observers = is_array($observers) ? $observers : [$observers]; array_map(function ($observer) { $this->app->bind($observer, function () use ($observer) { return $this->getMockBuilder($observer)->disableOriginalConstructor()->getMock(); }); }, $observers); return $this; }
[ "public", "function", "withoutObservers", "(", "$", "observers", ")", "{", "$", "observers", "=", "is_array", "(", "$", "observers", ")", "?", "$", "observers", ":", "[", "$", "observers", "]", ";", "array_map", "(", "function", "(", "$", "observer", ")"...
Specify a list of observers that will not run for the given operation. @param array|string $observers @return $this
[ "Specify", "a", "list", "of", "observers", "that", "will", "not", "run", "for", "the", "given", "operation", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MocksApplicationServices.php#L218-L229
train
laravel/browser-kit-testing
src/Concerns/MocksApplicationServices.php
MocksApplicationServices.doesntExpectJobs
protected function doesntExpectJobs($jobs) { $jobs = is_array($jobs) ? $jobs : func_get_args(); $this->withoutJobs(); $this->beforeApplicationDestroyed(function () use ($jobs) { $this->assertEmpty( $dispatched = $this->getDispatchedJobs($jobs), 'These unexpected jobs were dispatched: ['.implode(', ', $dispatched).']' ); }); return $this; }
php
protected function doesntExpectJobs($jobs) { $jobs = is_array($jobs) ? $jobs : func_get_args(); $this->withoutJobs(); $this->beforeApplicationDestroyed(function () use ($jobs) { $this->assertEmpty( $dispatched = $this->getDispatchedJobs($jobs), 'These unexpected jobs were dispatched: ['.implode(', ', $dispatched).']' ); }); return $this; }
[ "protected", "function", "doesntExpectJobs", "(", "$", "jobs", ")", "{", "$", "jobs", "=", "is_array", "(", "$", "jobs", ")", "?", "$", "jobs", ":", "func_get_args", "(", ")", ";", "$", "this", "->", "withoutJobs", "(", ")", ";", "$", "this", "->", ...
Specify a list of jobs that should not be dispatched for the given operation. These jobs will be mocked, so that handlers will not actually be executed. @param array|string $jobs @return $this
[ "Specify", "a", "list", "of", "jobs", "that", "should", "not", "be", "dispatched", "for", "the", "given", "operation", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MocksApplicationServices.php#L287-L301
train
laravel/browser-kit-testing
src/Concerns/MocksApplicationServices.php
MocksApplicationServices.withoutJobs
protected function withoutJobs() { $mock = Mockery::mock('Illuminate\Contracts\Bus\Dispatcher'); $mock->shouldReceive('dispatch', 'dispatchNow', 'getCommandHandler')->andReturnUsing(function ($dispatched) { $this->dispatchedJobs[] = $dispatched; }); $this->app->instance( 'Illuminate\Contracts\Bus\Dispatcher', $mock ); return $this; }
php
protected function withoutJobs() { $mock = Mockery::mock('Illuminate\Contracts\Bus\Dispatcher'); $mock->shouldReceive('dispatch', 'dispatchNow', 'getCommandHandler')->andReturnUsing(function ($dispatched) { $this->dispatchedJobs[] = $dispatched; }); $this->app->instance( 'Illuminate\Contracts\Bus\Dispatcher', $mock ); return $this; }
[ "protected", "function", "withoutJobs", "(", ")", "{", "$", "mock", "=", "Mockery", "::", "mock", "(", "'Illuminate\\Contracts\\Bus\\Dispatcher'", ")", ";", "$", "mock", "->", "shouldReceive", "(", "'dispatch'", ",", "'dispatchNow'", ",", "'getCommandHandler'", ")...
Mock the job dispatcher so all jobs are silenced and collected. @return $this
[ "Mock", "the", "job", "dispatcher", "so", "all", "jobs", "are", "silenced", "and", "collected", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MocksApplicationServices.php#L308-L321
train
laravel/browser-kit-testing
src/Concerns/MocksApplicationServices.php
MocksApplicationServices.wasDispatched
protected function wasDispatched($needle, array $haystack) { foreach ($haystack as $dispatched) { if ((is_string($dispatched) && ($dispatched === $needle || is_subclass_of($dispatched, $needle))) || $dispatched instanceof $needle) { return true; } } return false; }
php
protected function wasDispatched($needle, array $haystack) { foreach ($haystack as $dispatched) { if ((is_string($dispatched) && ($dispatched === $needle || is_subclass_of($dispatched, $needle))) || $dispatched instanceof $needle) { return true; } } return false; }
[ "protected", "function", "wasDispatched", "(", "$", "needle", ",", "array", "$", "haystack", ")", "{", "foreach", "(", "$", "haystack", "as", "$", "dispatched", ")", "{", "if", "(", "(", "is_string", "(", "$", "dispatched", ")", "&&", "(", "$", "dispat...
Check if the given class exists in an array of dispatched classes. @param string $needle @param array $haystack @return bool
[ "Check", "if", "the", "given", "class", "exists", "in", "an", "array", "of", "dispatched", "classes", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MocksApplicationServices.php#L355-L365
train
laravel/browser-kit-testing
src/Concerns/MocksApplicationServices.php
MocksApplicationServices.withoutNotifications
protected function withoutNotifications() { $mock = Mockery::mock(NotificationDispatcher::class); $mock->shouldReceive('send')->andReturnUsing(function ($notifiable, $instance, $channels = []) { $this->dispatchedNotifications[] = compact( 'notifiable', 'instance', 'channels' ); }); $this->app->instance(NotificationDispatcher::class, $mock); return $this; }
php
protected function withoutNotifications() { $mock = Mockery::mock(NotificationDispatcher::class); $mock->shouldReceive('send')->andReturnUsing(function ($notifiable, $instance, $channels = []) { $this->dispatchedNotifications[] = compact( 'notifiable', 'instance', 'channels' ); }); $this->app->instance(NotificationDispatcher::class, $mock); return $this; }
[ "protected", "function", "withoutNotifications", "(", ")", "{", "$", "mock", "=", "Mockery", "::", "mock", "(", "NotificationDispatcher", "::", "class", ")", ";", "$", "mock", "->", "shouldReceive", "(", "'send'", ")", "->", "andReturnUsing", "(", "function", ...
Mock the notification dispatcher so all notifications are silenced. @return $this
[ "Mock", "the", "notification", "dispatcher", "so", "all", "notifications", "are", "silenced", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MocksApplicationServices.php#L372-L385
train
laravel/browser-kit-testing
src/Concerns/MocksApplicationServices.php
MocksApplicationServices.expectsNotification
protected function expectsNotification($notifiable, $notification) { $this->withoutNotifications(); $this->beforeApplicationDestroyed(function () use ($notifiable, $notification) { foreach ($this->dispatchedNotifications as $dispatched) { $notified = $dispatched['notifiable']; if (($notified === $notifiable || $notified->getKey() == $notifiable->getKey()) && get_class($dispatched['instance']) === $notification ) { return $this; } } $this->fail('The following expected notification was not dispatched: ['.$notification.']'); }); return $this; }
php
protected function expectsNotification($notifiable, $notification) { $this->withoutNotifications(); $this->beforeApplicationDestroyed(function () use ($notifiable, $notification) { foreach ($this->dispatchedNotifications as $dispatched) { $notified = $dispatched['notifiable']; if (($notified === $notifiable || $notified->getKey() == $notifiable->getKey()) && get_class($dispatched['instance']) === $notification ) { return $this; } } $this->fail('The following expected notification was not dispatched: ['.$notification.']'); }); return $this; }
[ "protected", "function", "expectsNotification", "(", "$", "notifiable", ",", "$", "notification", ")", "{", "$", "this", "->", "withoutNotifications", "(", ")", ";", "$", "this", "->", "beforeApplicationDestroyed", "(", "function", "(", ")", "use", "(", "$", ...
Specify a notification that is expected to be dispatched. @param mixed $notifiable @param string $notification @return $this
[ "Specify", "a", "notification", "that", "is", "expected", "to", "be", "dispatched", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MocksApplicationServices.php#L394-L414
train
laravel/browser-kit-testing
src/Constraints/HasSource.php
HasSource.matches
protected function matches($crawler): bool { $pattern = $this->getEscapedPattern($this->source); return preg_match("/{$pattern}/i", $this->html($crawler)); }
php
protected function matches($crawler): bool { $pattern = $this->getEscapedPattern($this->source); return preg_match("/{$pattern}/i", $this->html($crawler)); }
[ "protected", "function", "matches", "(", "$", "crawler", ")", ":", "bool", "{", "$", "pattern", "=", "$", "this", "->", "getEscapedPattern", "(", "$", "this", "->", "source", ")", ";", "return", "preg_match", "(", "\"/{$pattern}/i\"", ",", "$", "this", "...
Check if the source is found in the given crawler. @param \Symfony\Component\DomCrawler\Crawler|string $crawler @return bool
[ "Check", "if", "the", "source", "is", "found", "in", "the", "given", "crawler", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/HasSource.php#L31-L36
train
laravel/browser-kit-testing
src/Constraints/IsSelected.php
IsSelected.matches
protected function matches($crawler): bool { $crawler = $this->crawler($crawler); return in_array($this->value, $this->getSelectedValue($crawler)); }
php
protected function matches($crawler): bool { $crawler = $this->crawler($crawler); return in_array($this->value, $this->getSelectedValue($crawler)); }
[ "protected", "function", "matches", "(", "$", "crawler", ")", ":", "bool", "{", "$", "crawler", "=", "$", "this", "->", "crawler", "(", "$", "crawler", ")", ";", "return", "in_array", "(", "$", "this", "->", "value", ",", "$", "this", "->", "getSelec...
Determine if the select or radio element is selected. @param \Symfony\Component\DomCrawler\Crawler|string $crawler @return bool
[ "Determine", "if", "the", "select", "or", "radio", "element", "is", "selected", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/IsSelected.php#L26-L31
train
laravel/browser-kit-testing
src/Constraints/IsSelected.php
IsSelected.getSelectedValue
public function getSelectedValue(Crawler $crawler) { $field = $this->field($crawler); return $field->nodeName() == 'select' ? $this->getSelectedValueFromSelect($field) : [$this->getCheckedValueFromRadioGroup($field)]; }
php
public function getSelectedValue(Crawler $crawler) { $field = $this->field($crawler); return $field->nodeName() == 'select' ? $this->getSelectedValueFromSelect($field) : [$this->getCheckedValueFromRadioGroup($field)]; }
[ "public", "function", "getSelectedValue", "(", "Crawler", "$", "crawler", ")", "{", "$", "field", "=", "$", "this", "->", "field", "(", "$", "crawler", ")", ";", "return", "$", "field", "->", "nodeName", "(", ")", "==", "'select'", "?", "$", "this", ...
Get the selected value of a select field or radio group. @param \Symfony\Component\DomCrawler\Crawler $crawler @return array @throws \PHPUnit\Framework\ExpectationFailedException
[ "Get", "the", "selected", "value", "of", "a", "select", "field", "or", "radio", "group", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/IsSelected.php#L41-L48
train
laravel/browser-kit-testing
src/Constraints/IsSelected.php
IsSelected.getSelectedValueFromSelect
protected function getSelectedValueFromSelect(Crawler $select) { $selected = []; foreach ($select->children() as $option) { if ($option->nodeName === 'optgroup') { foreach ($option->childNodes as $child) { if ($child->hasAttribute('selected')) { $selected[] = $this->getOptionValue($child); } } } elseif ($option->hasAttribute('selected')) { $selected[] = $this->getOptionValue($option); } } return $selected; }
php
protected function getSelectedValueFromSelect(Crawler $select) { $selected = []; foreach ($select->children() as $option) { if ($option->nodeName === 'optgroup') { foreach ($option->childNodes as $child) { if ($child->hasAttribute('selected')) { $selected[] = $this->getOptionValue($child); } } } elseif ($option->hasAttribute('selected')) { $selected[] = $this->getOptionValue($option); } } return $selected; }
[ "protected", "function", "getSelectedValueFromSelect", "(", "Crawler", "$", "select", ")", "{", "$", "selected", "=", "[", "]", ";", "foreach", "(", "$", "select", "->", "children", "(", ")", "as", "$", "option", ")", "{", "if", "(", "$", "option", "->...
Get the selected value from a select field. @param \Symfony\Component\DomCrawler\Crawler $select @return array
[ "Get", "the", "selected", "value", "from", "a", "select", "field", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/IsSelected.php#L56-L73
train
laravel/browser-kit-testing
src/Constraints/IsSelected.php
IsSelected.getCheckedValueFromRadioGroup
protected function getCheckedValueFromRadioGroup(Crawler $radioGroup) { foreach ($radioGroup as $radio) { if ($radio->hasAttribute('checked')) { return $radio->getAttribute('value'); } } }
php
protected function getCheckedValueFromRadioGroup(Crawler $radioGroup) { foreach ($radioGroup as $radio) { if ($radio->hasAttribute('checked')) { return $radio->getAttribute('value'); } } }
[ "protected", "function", "getCheckedValueFromRadioGroup", "(", "Crawler", "$", "radioGroup", ")", "{", "foreach", "(", "$", "radioGroup", "as", "$", "radio", ")", "{", "if", "(", "$", "radio", "->", "hasAttribute", "(", "'checked'", ")", ")", "{", "return", ...
Get the checked value from a radio group. @param \Symfony\Component\DomCrawler\Crawler $radioGroup @return string|null
[ "Get", "the", "checked", "value", "from", "a", "radio", "group", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/IsSelected.php#L96-L103
train
laravel/browser-kit-testing
src/Constraints/HasValue.php
HasValue.matches
public function matches($crawler): bool { $crawler = $this->crawler($crawler); return $this->getInputOrTextAreaValue($crawler) == $this->value; }
php
public function matches($crawler): bool { $crawler = $this->crawler($crawler); return $this->getInputOrTextAreaValue($crawler) == $this->value; }
[ "public", "function", "matches", "(", "$", "crawler", ")", ":", "bool", "{", "$", "crawler", "=", "$", "this", "->", "crawler", "(", "$", "crawler", ")", ";", "return", "$", "this", "->", "getInputOrTextAreaValue", "(", "$", "crawler", ")", "==", "$", ...
Check if the input contains the expected value. @param \Symfony\Component\DomCrawler\Crawler|string $crawler @return bool
[ "Check", "if", "the", "input", "contains", "the", "expected", "value", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/HasValue.php#L25-L30
train
laravel/browser-kit-testing
src/Constraints/HasValue.php
HasValue.getInputOrTextAreaValue
public function getInputOrTextAreaValue(Crawler $crawler) { $field = $this->field($crawler); return $field->nodeName() == 'input' ? $field->attr('value') : $field->text(); }
php
public function getInputOrTextAreaValue(Crawler $crawler) { $field = $this->field($crawler); return $field->nodeName() == 'input' ? $field->attr('value') : $field->text(); }
[ "public", "function", "getInputOrTextAreaValue", "(", "Crawler", "$", "crawler", ")", "{", "$", "field", "=", "$", "this", "->", "field", "(", "$", "crawler", ")", ";", "return", "$", "field", "->", "nodeName", "(", ")", "==", "'input'", "?", "$", "fie...
Get the value of an input or textarea. @param \Symfony\Component\DomCrawler\Crawler $crawler @return string @throws \PHPUnit\Framework\ExpectationFailedException
[ "Get", "the", "value", "of", "an", "input", "or", "textarea", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/HasValue.php#L40-L47
train
laravel/browser-kit-testing
src/Constraints/HasElement.php
HasElement.matches
public function matches($crawler): bool { $elements = $this->crawler($crawler)->filter($this->selector); if ($elements->count() == 0) { return false; } if (empty($this->attributes)) { return true; } $elements = $elements->reduce(function ($element) { return $this->hasAttributes($element); }); return $elements->count() > 0; }
php
public function matches($crawler): bool { $elements = $this->crawler($crawler)->filter($this->selector); if ($elements->count() == 0) { return false; } if (empty($this->attributes)) { return true; } $elements = $elements->reduce(function ($element) { return $this->hasAttributes($element); }); return $elements->count() > 0; }
[ "public", "function", "matches", "(", "$", "crawler", ")", ":", "bool", "{", "$", "elements", "=", "$", "this", "->", "crawler", "(", "$", "crawler", ")", "->", "filter", "(", "$", "this", "->", "selector", ")", ";", "if", "(", "$", "elements", "->...
Check if the element is found in the given crawler. @param \Symfony\Component\DomCrawler\Crawler|string $crawler @return bool
[ "Check", "if", "the", "element", "is", "found", "in", "the", "given", "crawler", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/HasElement.php#L42-L59
train
laravel/browser-kit-testing
src/Constraints/HasElement.php
HasElement.hasAttributes
protected function hasAttributes(Crawler $element) { foreach ($this->attributes as $name => $value) { if (is_numeric($name)) { if (is_null($element->attr($value))) { return false; } } else { if ($element->attr($name) != $value) { return false; } } } return true; }
php
protected function hasAttributes(Crawler $element) { foreach ($this->attributes as $name => $value) { if (is_numeric($name)) { if (is_null($element->attr($value))) { return false; } } else { if ($element->attr($name) != $value) { return false; } } } return true; }
[ "protected", "function", "hasAttributes", "(", "Crawler", "$", "element", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "name", ")", ")", "{", "if", "(",...
Determines if the given element has the attributes. @param \Symfony\Component\DomCrawler\Crawler $element @return bool
[ "Determines", "if", "the", "given", "element", "has", "the", "attributes", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/HasElement.php#L67-L82
train
laravel/browser-kit-testing
src/Constraints/HasInElement.php
HasInElement.matches
public function matches($crawler): bool { $elements = $this->crawler($crawler)->filter($this->element); $pattern = $this->getEscapedPattern($this->text); foreach ($elements as $element) { $element = new Crawler($element); if (preg_match("/$pattern/i", $element->html())) { return true; } } return false; }
php
public function matches($crawler): bool { $elements = $this->crawler($crawler)->filter($this->element); $pattern = $this->getEscapedPattern($this->text); foreach ($elements as $element) { $element = new Crawler($element); if (preg_match("/$pattern/i", $element->html())) { return true; } } return false; }
[ "public", "function", "matches", "(", "$", "crawler", ")", ":", "bool", "{", "$", "elements", "=", "$", "this", "->", "crawler", "(", "$", "crawler", ")", "->", "filter", "(", "$", "this", "->", "element", ")", ";", "$", "pattern", "=", "$", "this"...
Check if the source or text is found within the element in the given crawler. @param \Symfony\Component\DomCrawler\Crawler|string $crawler @return bool
[ "Check", "if", "the", "source", "or", "text", "is", "found", "within", "the", "element", "in", "the", "given", "crawler", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/HasInElement.php#L42-L57
train
laravel/browser-kit-testing
src/Constraints/HasText.php
HasText.matches
protected function matches($crawler): bool { $pattern = $this->getEscapedPattern($this->text); return preg_match("/{$pattern}/i", $this->text($crawler)); }
php
protected function matches($crawler): bool { $pattern = $this->getEscapedPattern($this->text); return preg_match("/{$pattern}/i", $this->text($crawler)); }
[ "protected", "function", "matches", "(", "$", "crawler", ")", ":", "bool", "{", "$", "pattern", "=", "$", "this", "->", "getEscapedPattern", "(", "$", "this", "->", "text", ")", ";", "return", "preg_match", "(", "\"/{$pattern}/i\"", ",", "$", "this", "->...
Check if the plain text is found in the given crawler. @param \Symfony\Component\DomCrawler\Crawler|string $crawler @return bool
[ "Check", "if", "the", "plain", "text", "is", "found", "in", "the", "given", "crawler", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/HasText.php#L31-L36
train
laravel/browser-kit-testing
src/Concerns/InteractsWithAuthentication.php
InteractsWithAuthentication.seeCredentials
public function seeCredentials(array $credentials, $guard = null) { $this->assertTrue( $this->hasCredentials($credentials, $guard), 'The given credentials are invalid.' ); return $this; }
php
public function seeCredentials(array $credentials, $guard = null) { $this->assertTrue( $this->hasCredentials($credentials, $guard), 'The given credentials are invalid.' ); return $this; }
[ "public", "function", "seeCredentials", "(", "array", "$", "credentials", ",", "$", "guard", "=", "null", ")", "{", "$", "this", "->", "assertTrue", "(", "$", "this", "->", "hasCredentials", "(", "$", "credentials", ",", "$", "guard", ")", ",", "'The giv...
Assert that the given credentials are valid. @param array $credentials @param string|null $guard @return $this
[ "Assert", "that", "the", "given", "credentials", "are", "valid", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithAuthentication.php#L75-L82
train
laravel/browser-kit-testing
src/Concerns/InteractsWithAuthentication.php
InteractsWithAuthentication.dontSeeCredentials
public function dontSeeCredentials(array $credentials, $guard = null) { $this->assertFalse( $this->hasCredentials($credentials, $guard), 'The given credentials are valid.' ); return $this; }
php
public function dontSeeCredentials(array $credentials, $guard = null) { $this->assertFalse( $this->hasCredentials($credentials, $guard), 'The given credentials are valid.' ); return $this; }
[ "public", "function", "dontSeeCredentials", "(", "array", "$", "credentials", ",", "$", "guard", "=", "null", ")", "{", "$", "this", "->", "assertFalse", "(", "$", "this", "->", "hasCredentials", "(", "$", "credentials", ",", "$", "guard", ")", ",", "'Th...
Assert that the given credentials are invalid. @param array $credentials @param string|null $guard @return $this
[ "Assert", "that", "the", "given", "credentials", "are", "invalid", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithAuthentication.php#L91-L98
train
laravel/browser-kit-testing
src/Concerns/InteractsWithAuthentication.php
InteractsWithAuthentication.hasCredentials
protected function hasCredentials(array $credentials, $guard = null) { $provider = $this->app->make('auth')->guard($guard)->getProvider(); $user = $provider->retrieveByCredentials($credentials); return $user && $provider->validateCredentials($user, $credentials); }
php
protected function hasCredentials(array $credentials, $guard = null) { $provider = $this->app->make('auth')->guard($guard)->getProvider(); $user = $provider->retrieveByCredentials($credentials); return $user && $provider->validateCredentials($user, $credentials); }
[ "protected", "function", "hasCredentials", "(", "array", "$", "credentials", ",", "$", "guard", "=", "null", ")", "{", "$", "provider", "=", "$", "this", "->", "app", "->", "make", "(", "'auth'", ")", "->", "guard", "(", "$", "guard", ")", "->", "get...
Return true is the credentials are valid, false otherwise. @param array $credentials @param string|null $guard @return bool
[ "Return", "true", "is", "the", "credentials", "are", "valid", "false", "otherwise", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/InteractsWithAuthentication.php#L107-L114
train
laravel/browser-kit-testing
src/Constraints/HasLink.php
HasLink.matches
public function matches($crawler): bool { $links = $this->crawler($crawler)->selectLink($this->text); if ($links->count() == 0) { return false; } // If the URL is null we assume the developer only wants to find a link // with the given text regardless of the URL. So if we find the link // we will return true. Otherwise, we will look for the given URL. if ($this->url == null) { return true; } $absoluteUrl = $this->absoluteUrl(); foreach ($links as $link) { $linkHref = $link->getAttribute('href'); if ($linkHref == $this->url || $linkHref == $absoluteUrl) { return true; } } return false; }
php
public function matches($crawler): bool { $links = $this->crawler($crawler)->selectLink($this->text); if ($links->count() == 0) { return false; } // If the URL is null we assume the developer only wants to find a link // with the given text regardless of the URL. So if we find the link // we will return true. Otherwise, we will look for the given URL. if ($this->url == null) { return true; } $absoluteUrl = $this->absoluteUrl(); foreach ($links as $link) { $linkHref = $link->getAttribute('href'); if ($linkHref == $this->url || $linkHref == $absoluteUrl) { return true; } } return false; }
[ "public", "function", "matches", "(", "$", "crawler", ")", ":", "bool", "{", "$", "links", "=", "$", "this", "->", "crawler", "(", "$", "crawler", ")", "->", "selectLink", "(", "$", "this", "->", "text", ")", ";", "if", "(", "$", "links", "->", "...
Check if the link is found in the given crawler. @param \Symfony\Component\DomCrawler\Crawler|string $crawler @return bool
[ "Check", "if", "the", "link", "is", "found", "in", "the", "given", "crawler", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Constraints/HasLink.php#L43-L69
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.withoutMiddleware
public function withoutMiddleware($middleware = null) { if (is_null($middleware)) { $this->app->instance('middleware.disable', true); return $this; } foreach ((array) $middleware as $abstract) { $this->app->instance($abstract, new class { public function handle($request, $next) { return $next($request); } }); } return $this; }
php
public function withoutMiddleware($middleware = null) { if (is_null($middleware)) { $this->app->instance('middleware.disable', true); return $this; } foreach ((array) $middleware as $abstract) { $this->app->instance($abstract, new class { public function handle($request, $next) { return $next($request); } }); } return $this; }
[ "public", "function", "withoutMiddleware", "(", "$", "middleware", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "middleware", ")", ")", "{", "$", "this", "->", "app", "->", "instance", "(", "'middleware.disable'", ",", "true", ")", ";", "return...
Disable middleware for the test. @param null $middleware @return $this
[ "Disable", "middleware", "for", "the", "test", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L48-L66
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.patch
public function patch($uri, array $data = [], array $headers = []) { $server = $this->transformHeadersToServerVars($headers); $this->call('PATCH', $uri, $data, [], [], $server); return $this; }
php
public function patch($uri, array $data = [], array $headers = []) { $server = $this->transformHeadersToServerVars($headers); $this->call('PATCH', $uri, $data, [], [], $server); return $this; }
[ "public", "function", "patch", "(", "$", "uri", ",", "array", "$", "data", "=", "[", "]", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "$", "server", "=", "$", "this", "->", "transformHeadersToServerVars", "(", "$", "headers", ")", ";", "...
Visit the given URI with a PATCH request. @param string $uri @param array $data @param array $headers @return $this
[ "Visit", "the", "given", "URI", "with", "a", "PATCH", "request", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L213-L220
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.delete
public function delete($uri, array $data = [], array $headers = []) { $server = $this->transformHeadersToServerVars($headers); $this->call('DELETE', $uri, $data, [], [], $server); return $this; }
php
public function delete($uri, array $data = [], array $headers = []) { $server = $this->transformHeadersToServerVars($headers); $this->call('DELETE', $uri, $data, [], [], $server); return $this; }
[ "public", "function", "delete", "(", "$", "uri", ",", "array", "$", "data", "=", "[", "]", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "$", "server", "=", "$", "this", "->", "transformHeadersToServerVars", "(", "$", "headers", ")", ";", ...
Visit the given URI with a DELETE request. @param string $uri @param array $data @param array $headers @return $this
[ "Visit", "the", "given", "URI", "with", "a", "DELETE", "request", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L243-L250
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.handle
public function handle(Request $request) { $this->currentUri = $request->fullUrl(); $this->response = $this->app->prepareResponse($this->app->handle($request)); return $this; }
php
public function handle(Request $request) { $this->currentUri = $request->fullUrl(); $this->response = $this->app->prepareResponse($this->app->handle($request)); return $this; }
[ "public", "function", "handle", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "currentUri", "=", "$", "request", "->", "fullUrl", "(", ")", ";", "$", "this", "->", "response", "=", "$", "this", "->", "app", "->", "prepareResponse", "(", ...
Send the given request through the application. This method allows you to fully customize the entire Request object. @param \Illuminate\Http\Request $request @return $this
[ "Send", "the", "given", "request", "through", "the", "application", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L273-L280
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.seeJsonEquals
public function seeJsonEquals(array $data) { $actual = json_encode(Arr::sortRecursive( (array) $this->decodeResponseJson() )); $this->assertEquals(json_encode(Arr::sortRecursive($data)), $actual); return $this; }
php
public function seeJsonEquals(array $data) { $actual = json_encode(Arr::sortRecursive( (array) $this->decodeResponseJson() )); $this->assertEquals(json_encode(Arr::sortRecursive($data)), $actual); return $this; }
[ "public", "function", "seeJsonEquals", "(", "array", "$", "data", ")", "{", "$", "actual", "=", "json_encode", "(", "Arr", "::", "sortRecursive", "(", "(", "array", ")", "$", "this", "->", "decodeResponseJson", "(", ")", ")", ")", ";", "$", "this", "->...
Assert that the response contains an exact JSON array. @param array $data @return $this
[ "Assert", "that", "the", "response", "contains", "an", "exact", "JSON", "array", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L310-L319
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.seeJson
public function seeJson(array $data = null, $negate = false) { if (is_null($data)) { $this->assertJson( $this->response->getContent(), "JSON was not returned from [{$this->currentUri}]." ); return $this; } try { return $this->seeJsonEquals($data); } catch (ExpectationFailedException $e) { return $this->seeJsonContains($data, $negate); } }
php
public function seeJson(array $data = null, $negate = false) { if (is_null($data)) { $this->assertJson( $this->response->getContent(), "JSON was not returned from [{$this->currentUri}]." ); return $this; } try { return $this->seeJsonEquals($data); } catch (ExpectationFailedException $e) { return $this->seeJsonContains($data, $negate); } }
[ "public", "function", "seeJson", "(", "array", "$", "data", "=", "null", ",", "$", "negate", "=", "false", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "this", "->", "assertJson", "(", "$", "this", "->", "response", "->", ...
Assert that the response contains JSON. @param array|null $data @param bool $negate @return $this
[ "Assert", "that", "the", "response", "contains", "JSON", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L328-L343
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.seeJsonStructure
public function seeJsonStructure(array $structure = null, $responseData = null) { if (is_null($structure)) { return $this->seeJson(); } if (is_null($responseData)) { $responseData = $this->decodeResponseJson(); } foreach ($structure as $key => $value) { if (is_array($value) && $key === '*') { $this->assertIsArray($responseData); foreach ($responseData as $responseDataItem) { $this->seeJsonStructure($structure['*'], $responseDataItem); } } elseif (is_array($value)) { $this->assertArrayHasKey($key, $responseData); $this->seeJsonStructure($structure[$key], $responseData[$key]); } else { $this->assertArrayHasKey($value, $responseData); } } return $this; }
php
public function seeJsonStructure(array $structure = null, $responseData = null) { if (is_null($structure)) { return $this->seeJson(); } if (is_null($responseData)) { $responseData = $this->decodeResponseJson(); } foreach ($structure as $key => $value) { if (is_array($value) && $key === '*') { $this->assertIsArray($responseData); foreach ($responseData as $responseDataItem) { $this->seeJsonStructure($structure['*'], $responseDataItem); } } elseif (is_array($value)) { $this->assertArrayHasKey($key, $responseData); $this->seeJsonStructure($structure[$key], $responseData[$key]); } else { $this->assertArrayHasKey($value, $responseData); } } return $this; }
[ "public", "function", "seeJsonStructure", "(", "array", "$", "structure", "=", "null", ",", "$", "responseData", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "structure", ")", ")", "{", "return", "$", "this", "->", "seeJson", "(", ")", ";", ...
Assert that the JSON response has a given structure. @param array|null $structure @param array|null $responseData @return $this
[ "Assert", "that", "the", "JSON", "response", "has", "a", "given", "structure", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L363-L389
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.seeJsonContains
protected function seeJsonContains(array $data, $negate = false) { $method = $negate ? 'assertFalse' : 'assertTrue'; $actual = json_encode(Arr::sortRecursive( (array) $this->decodeResponseJson() )); foreach (Arr::sortRecursive($data) as $key => $value) { $expected = $this->formatToExpectedJson($key, $value); $this->{$method}( Str::contains($actual, $expected), ($negate ? 'Found unexpected' : 'Unable to find').' JSON fragment'.PHP_EOL."[{$expected}]".PHP_EOL.'within'.PHP_EOL."[{$actual}]." ); } return $this; }
php
protected function seeJsonContains(array $data, $negate = false) { $method = $negate ? 'assertFalse' : 'assertTrue'; $actual = json_encode(Arr::sortRecursive( (array) $this->decodeResponseJson() )); foreach (Arr::sortRecursive($data) as $key => $value) { $expected = $this->formatToExpectedJson($key, $value); $this->{$method}( Str::contains($actual, $expected), ($negate ? 'Found unexpected' : 'Unable to find').' JSON fragment'.PHP_EOL."[{$expected}]".PHP_EOL.'within'.PHP_EOL."[{$actual}]." ); } return $this; }
[ "protected", "function", "seeJsonContains", "(", "array", "$", "data", ",", "$", "negate", "=", "false", ")", "{", "$", "method", "=", "$", "negate", "?", "'assertFalse'", ":", "'assertTrue'", ";", "$", "actual", "=", "json_encode", "(", "Arr", "::", "so...
Assert that the response contains the given JSON. @param array $data @param bool $negate @return $this
[ "Assert", "that", "the", "response", "contains", "the", "given", "JSON", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L398-L416
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.decodeResponseJson
protected function decodeResponseJson() { $decodedResponse = json_decode($this->response->getContent(), true); if (is_null($decodedResponse) || $decodedResponse === false) { $this->fail('Invalid JSON was returned from the route. Perhaps an exception was thrown?'); } return $decodedResponse; }
php
protected function decodeResponseJson() { $decodedResponse = json_decode($this->response->getContent(), true); if (is_null($decodedResponse) || $decodedResponse === false) { $this->fail('Invalid JSON was returned from the route. Perhaps an exception was thrown?'); } return $decodedResponse; }
[ "protected", "function", "decodeResponseJson", "(", ")", "{", "$", "decodedResponse", "=", "json_decode", "(", "$", "this", "->", "response", "->", "getContent", "(", ")", ",", "true", ")", ";", "if", "(", "is_null", "(", "$", "decodedResponse", ")", "||",...
Validate and return the decoded response JSON. @return array
[ "Validate", "and", "return", "the", "decoded", "response", "JSON", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L438-L447
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.formatToExpectedJson
protected function formatToExpectedJson($key, $value) { $expected = json_encode([$key => $value]); if (Str::startsWith($expected, '{')) { $expected = substr($expected, 1); } if (Str::endsWith($expected, '}')) { $expected = substr($expected, 0, -1); } return trim($expected); }
php
protected function formatToExpectedJson($key, $value) { $expected = json_encode([$key => $value]); if (Str::startsWith($expected, '{')) { $expected = substr($expected, 1); } if (Str::endsWith($expected, '}')) { $expected = substr($expected, 0, -1); } return trim($expected); }
[ "protected", "function", "formatToExpectedJson", "(", "$", "key", ",", "$", "value", ")", "{", "$", "expected", "=", "json_encode", "(", "[", "$", "key", "=>", "$", "value", "]", ")", ";", "if", "(", "Str", "::", "startsWith", "(", "$", "expected", "...
Format the given key and value into a JSON string for expectation checks. @param string $key @param mixed $value @return string
[ "Format", "the", "given", "key", "and", "value", "into", "a", "JSON", "string", "for", "expectation", "checks", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L456-L469
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.seeHeader
protected function seeHeader($headerName, $value = null) { $headers = $this->response->headers; $this->assertTrue($headers->has($headerName), "Header [{$headerName}] not present on response."); if (! is_null($value)) { $this->assertEquals( $headers->get($headerName), $value, "Header [{$headerName}] was found, but value [{$headers->get($headerName)}] does not match [{$value}]." ); } return $this; }
php
protected function seeHeader($headerName, $value = null) { $headers = $this->response->headers; $this->assertTrue($headers->has($headerName), "Header [{$headerName}] not present on response."); if (! is_null($value)) { $this->assertEquals( $headers->get($headerName), $value, "Header [{$headerName}] was found, but value [{$headers->get($headerName)}] does not match [{$value}]." ); } return $this; }
[ "protected", "function", "seeHeader", "(", "$", "headerName", ",", "$", "value", "=", "null", ")", "{", "$", "headers", "=", "$", "this", "->", "response", "->", "headers", ";", "$", "this", "->", "assertTrue", "(", "$", "headers", "->", "has", "(", ...
Asserts that the response contains the given header and equals the optional value. @param string $headerName @param mixed $value @return $this
[ "Asserts", "that", "the", "response", "contains", "the", "given", "header", "and", "equals", "the", "optional", "value", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L491-L505
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.seeCookie
protected function seeCookie($cookieName, $value = null, $encrypted = true, $unserialize = true) { $headers = $this->response->headers; $exist = false; foreach ($headers->getCookies() as $cookie) { if ($cookie->getName() === $cookieName) { $exist = true; break; } } $this->assertTrue($exist, "Cookie [{$cookieName}] not present on response."); if (! $exist || is_null($value)) { return $this; } $cookieValue = $cookie->getValue(); $actual = $encrypted ? $this->app['encrypter']->decrypt($cookieValue, $unserialize) : $cookieValue; $this->assertEquals( $actual, $value, "Cookie [{$cookieName}] was found, but value [{$actual}] does not match [{$value}]." ); return $this; }
php
protected function seeCookie($cookieName, $value = null, $encrypted = true, $unserialize = true) { $headers = $this->response->headers; $exist = false; foreach ($headers->getCookies() as $cookie) { if ($cookie->getName() === $cookieName) { $exist = true; break; } } $this->assertTrue($exist, "Cookie [{$cookieName}] not present on response."); if (! $exist || is_null($value)) { return $this; } $cookieValue = $cookie->getValue(); $actual = $encrypted ? $this->app['encrypter']->decrypt($cookieValue, $unserialize) : $cookieValue; $this->assertEquals( $actual, $value, "Cookie [{$cookieName}] was found, but value [{$actual}] does not match [{$value}]." ); return $this; }
[ "protected", "function", "seeCookie", "(", "$", "cookieName", ",", "$", "value", "=", "null", ",", "$", "encrypted", "=", "true", ",", "$", "unserialize", "=", "true", ")", "{", "$", "headers", "=", "$", "this", "->", "response", "->", "headers", ";", ...
Asserts that the response contains the given cookie and equals the optional value. @param string $cookieName @param mixed $value @param bool $encrypted @param bool $unserialize @return $this
[ "Asserts", "that", "the", "response", "contains", "the", "given", "cookie", "and", "equals", "the", "optional", "value", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L528-L558
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.action
public function action($method, $action, $wildcards = [], $parameters = [], $cookies = [], $files = [], $server = [], $content = null) { $uri = $this->app['url']->action($action, $wildcards, true); return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); }
php
public function action($method, $action, $wildcards = [], $parameters = [], $cookies = [], $files = [], $server = [], $content = null) { $uri = $this->app['url']->action($action, $wildcards, true); return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); }
[ "public", "function", "action", "(", "$", "method", ",", "$", "action", ",", "$", "wildcards", "=", "[", "]", ",", "$", "parameters", "=", "[", "]", ",", "$", "cookies", "=", "[", "]", ",", "$", "files", "=", "[", "]", ",", "$", "server", "=", ...
Call a controller action and return the Response. @param string $method @param string $action @param array $wildcards @param array $parameters @param array $cookies @param array $files @param array $server @param string $content @return \Illuminate\Http\Response
[ "Call", "a", "controller", "action", "and", "return", "the", "Response", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L639-L644
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.route
public function route($method, $name, $routeParameters = [], $parameters = [], $cookies = [], $files = [], $server = [], $content = null) { $uri = $this->app['url']->route($name, $routeParameters); return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); }
php
public function route($method, $name, $routeParameters = [], $parameters = [], $cookies = [], $files = [], $server = [], $content = null) { $uri = $this->app['url']->route($name, $routeParameters); return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); }
[ "public", "function", "route", "(", "$", "method", ",", "$", "name", ",", "$", "routeParameters", "=", "[", "]", ",", "$", "parameters", "=", "[", "]", ",", "$", "cookies", "=", "[", "]", ",", "$", "files", "=", "[", "]", ",", "$", "server", "=...
Call a named route and return the Response. @param string $method @param string $name @param array $routeParameters @param array $parameters @param array $cookies @param array $files @param array $server @param string $content @return \Illuminate\Http\Response
[ "Call", "a", "named", "route", "and", "return", "the", "Response", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L659-L664
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.assertResponseOk
public function assertResponseOk() { $actual = $this->response->getStatusCode(); PHPUnit::assertTrue($this->response->isOk(), "Expected status code 200, got {$actual}."); return $this; }
php
public function assertResponseOk() { $actual = $this->response->getStatusCode(); PHPUnit::assertTrue($this->response->isOk(), "Expected status code 200, got {$actual}."); return $this; }
[ "public", "function", "assertResponseOk", "(", ")", "{", "$", "actual", "=", "$", "this", "->", "response", "->", "getStatusCode", "(", ")", ";", "PHPUnit", "::", "assertTrue", "(", "$", "this", "->", "response", "->", "isOk", "(", ")", ",", "\"Expected ...
Assert that the client response has an OK status code. @return $this
[ "Assert", "that", "the", "client", "response", "has", "an", "OK", "status", "code", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L743-L750
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.assertResponseStatus
public function assertResponseStatus($code) { $actual = $this->response->getStatusCode(); PHPUnit::assertEquals($code, $this->response->getStatusCode(), "Expected status code {$code}, got {$actual}."); return $this; }
php
public function assertResponseStatus($code) { $actual = $this->response->getStatusCode(); PHPUnit::assertEquals($code, $this->response->getStatusCode(), "Expected status code {$code}, got {$actual}."); return $this; }
[ "public", "function", "assertResponseStatus", "(", "$", "code", ")", "{", "$", "actual", "=", "$", "this", "->", "response", "->", "getStatusCode", "(", ")", ";", "PHPUnit", "::", "assertEquals", "(", "$", "code", ",", "$", "this", "->", "response", "->"...
Assert that the client response has a given code. @param int $code @return $this
[ "Assert", "that", "the", "client", "response", "has", "a", "given", "code", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L758-L765
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.assertRedirectedTo
public function assertRedirectedTo($uri, $with = []) { PHPUnit::assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $this->response); PHPUnit::assertEquals($this->app['url']->to($uri), $this->response->headers->get('Location')); $this->assertSessionHasAll($with); return $this; }
php
public function assertRedirectedTo($uri, $with = []) { PHPUnit::assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $this->response); PHPUnit::assertEquals($this->app['url']->to($uri), $this->response->headers->get('Location')); $this->assertSessionHasAll($with); return $this; }
[ "public", "function", "assertRedirectedTo", "(", "$", "uri", ",", "$", "with", "=", "[", "]", ")", "{", "PHPUnit", "::", "assertInstanceOf", "(", "'Symfony\\Component\\HttpFoundation\\RedirectResponse'", ",", "$", "this", "->", "response", ")", ";", "PHPUnit", "...
Assert whether the client was redirected to a given URI. @param string $uri @param array $with @return $this
[ "Assert", "whether", "the", "client", "was", "redirected", "to", "a", "given", "URI", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L838-L847
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.assertRedirectedToRoute
public function assertRedirectedToRoute($name, $parameters = [], $with = []) { return $this->assertRedirectedTo($this->app['url']->route($name, $parameters), $with); }
php
public function assertRedirectedToRoute($name, $parameters = [], $with = []) { return $this->assertRedirectedTo($this->app['url']->route($name, $parameters), $with); }
[ "public", "function", "assertRedirectedToRoute", "(", "$", "name", ",", "$", "parameters", "=", "[", "]", ",", "$", "with", "=", "[", "]", ")", "{", "return", "$", "this", "->", "assertRedirectedTo", "(", "$", "this", "->", "app", "[", "'url'", "]", ...
Assert whether the client was redirected to a given route. @param string $name @param array $parameters @param array $with @return $this
[ "Assert", "whether", "the", "client", "was", "redirected", "to", "a", "given", "route", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L857-L860
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.assertRedirectedToAction
public function assertRedirectedToAction($name, $parameters = [], $with = []) { return $this->assertRedirectedTo($this->app['url']->action($name, $parameters), $with); }
php
public function assertRedirectedToAction($name, $parameters = [], $with = []) { return $this->assertRedirectedTo($this->app['url']->action($name, $parameters), $with); }
[ "public", "function", "assertRedirectedToAction", "(", "$", "name", ",", "$", "parameters", "=", "[", "]", ",", "$", "with", "=", "[", "]", ")", "{", "return", "$", "this", "->", "assertRedirectedTo", "(", "$", "this", "->", "app", "[", "'url'", "]", ...
Assert whether the client was redirected to a given action. @param string $name @param array $parameters @param array $with @return $this
[ "Assert", "whether", "the", "client", "was", "redirected", "to", "a", "given", "action", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L870-L873
train
laravel/browser-kit-testing
src/Concerns/MakesHttpRequests.php
MakesHttpRequests.dump
public function dump() { $content = $this->response->getContent(); $json = json_decode($content); if (json_last_error() === JSON_ERROR_NONE) { $content = $json; } dd($content); }
php
public function dump() { $content = $this->response->getContent(); $json = json_decode($content); if (json_last_error() === JSON_ERROR_NONE) { $content = $json; } dd($content); }
[ "public", "function", "dump", "(", ")", "{", "$", "content", "=", "$", "this", "->", "response", "->", "getContent", "(", ")", ";", "$", "json", "=", "json_decode", "(", "$", "content", ")", ";", "if", "(", "json_last_error", "(", ")", "===", "JSON_E...
Dump the content from the last response. @return void
[ "Dump", "the", "content", "from", "the", "last", "response", "." ]
69d436c1a6b59d4a1062171441c49fcae9f4f2c9
https://github.com/laravel/browser-kit-testing/blob/69d436c1a6b59d4a1062171441c49fcae9f4f2c9/src/Concerns/MakesHttpRequests.php#L880-L891
train
yohang/Finite
src/Finite/Bundle/FiniteBundle/DependencyInjection/FiniteFiniteExtension.php
FiniteFiniteExtension.removeDisabledCallbacks
protected function removeDisabledCallbacks(array $config) { if (!isset($config['callbacks'])) { return $config; } foreach (array('before', 'after') as $position) { foreach ($config['callbacks'][$position] as $i => $callback) { if ($callback['disabled']) { unset($config['callbacks'][$position][$i]); } unset($config['callbacks'][$position][$i]['disabled']); } } return $config; }
php
protected function removeDisabledCallbacks(array $config) { if (!isset($config['callbacks'])) { return $config; } foreach (array('before', 'after') as $position) { foreach ($config['callbacks'][$position] as $i => $callback) { if ($callback['disabled']) { unset($config['callbacks'][$position][$i]); } unset($config['callbacks'][$position][$i]['disabled']); } } return $config; }
[ "protected", "function", "removeDisabledCallbacks", "(", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'callbacks'", "]", ")", ")", "{", "return", "$", "config", ";", "}", "foreach", "(", "array", "(", "'before'", ...
Remove callback entries where index 'disabled' is set to true. @param array $config @return array
[ "Remove", "callback", "entries", "where", "index", "disabled", "is", "set", "to", "true", "." ]
8f06be8c08875e04f8ad25e4c9c8f49b6f24e0d1
https://github.com/yohang/Finite/blob/8f06be8c08875e04f8ad25e4c9c8f49b6f24e0d1/src/Finite/Bundle/FiniteBundle/DependencyInjection/FiniteFiniteExtension.php#L65-L81
train
yohang/Finite
src/Finite/StateMachine/StateMachine.php
StateMachine.findInitialState
protected function findInitialState() { foreach ($this->states as $state) { if (State::TYPE_INITIAL === $state->getType()) { return $state->getName(); } } throw new Exception\StateException(sprintf( 'No initial state found on object "%s" with graph "%s".', get_class($this->getObject()), $this->getGraph() )); }
php
protected function findInitialState() { foreach ($this->states as $state) { if (State::TYPE_INITIAL === $state->getType()) { return $state->getName(); } } throw new Exception\StateException(sprintf( 'No initial state found on object "%s" with graph "%s".', get_class($this->getObject()), $this->getGraph() )); }
[ "protected", "function", "findInitialState", "(", ")", "{", "foreach", "(", "$", "this", "->", "states", "as", "$", "state", ")", "{", "if", "(", "State", "::", "TYPE_INITIAL", "===", "$", "state", "->", "getType", "(", ")", ")", "{", "return", "$", ...
Find and return the Initial state if exists. @return string @throws Exception\StateException
[ "Find", "and", "return", "the", "Initial", "state", "if", "exists", "." ]
8f06be8c08875e04f8ad25e4c9c8f49b6f24e0d1
https://github.com/yohang/Finite/blob/8f06be8c08875e04f8ad25e4c9c8f49b6f24e0d1/src/Finite/StateMachine/StateMachine.php#L300-L313
train
yohang/Finite
src/Finite/StateMachine/StateMachine.php
StateMachine.dispatchTransitionEvent
private function dispatchTransitionEvent(TransitionInterface $transition, TransitionEvent $event, $transitionState) { $this->dispatcher->dispatch($transitionState, $event); $this->dispatcher->dispatch($transitionState.'.'.$transition->getName(), $event); if (null !== $this->getGraph()) { $this->dispatcher->dispatch($transitionState.'.'.$this->getGraph().'.'.$transition->getName(), $event); } }
php
private function dispatchTransitionEvent(TransitionInterface $transition, TransitionEvent $event, $transitionState) { $this->dispatcher->dispatch($transitionState, $event); $this->dispatcher->dispatch($transitionState.'.'.$transition->getName(), $event); if (null !== $this->getGraph()) { $this->dispatcher->dispatch($transitionState.'.'.$this->getGraph().'.'.$transition->getName(), $event); } }
[ "private", "function", "dispatchTransitionEvent", "(", "TransitionInterface", "$", "transition", ",", "TransitionEvent", "$", "event", ",", "$", "transitionState", ")", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "$", "transitionState", ",", "$", ...
Dispatches event for the transition @param TransitionInterface $transition @param TransitionEvent $event @param type $transitionState
[ "Dispatches", "event", "for", "the", "transition" ]
8f06be8c08875e04f8ad25e4c9c8f49b6f24e0d1
https://github.com/yohang/Finite/blob/8f06be8c08875e04f8ad25e4c9c8f49b6f24e0d1/src/Finite/StateMachine/StateMachine.php#L398-L405
train
thephpleague/container
src/ReflectionContainer.php
ReflectionContainer.call
public function call(callable $callable, array $args = []) { if (is_string($callable) && strpos($callable, '::') !== false) { $callable = explode('::', $callable); } if (is_array($callable)) { if (is_string($callable[0])) { $callable[0] = $this->getContainer()->get($callable[0]); } $reflection = new ReflectionMethod($callable[0], $callable[1]); if ($reflection->isStatic()) { $callable[0] = null; } return $reflection->invokeArgs($callable[0], $this->reflectArguments($reflection, $args)); } if (is_object($callable)) { $reflection = new ReflectionMethod($callable, '__invoke'); return $reflection->invokeArgs($callable, $this->reflectArguments($reflection, $args)); } $reflection = new ReflectionFunction($callable); return $reflection->invokeArgs($this->reflectArguments($reflection, $args)); }
php
public function call(callable $callable, array $args = []) { if (is_string($callable) && strpos($callable, '::') !== false) { $callable = explode('::', $callable); } if (is_array($callable)) { if (is_string($callable[0])) { $callable[0] = $this->getContainer()->get($callable[0]); } $reflection = new ReflectionMethod($callable[0], $callable[1]); if ($reflection->isStatic()) { $callable[0] = null; } return $reflection->invokeArgs($callable[0], $this->reflectArguments($reflection, $args)); } if (is_object($callable)) { $reflection = new ReflectionMethod($callable, '__invoke'); return $reflection->invokeArgs($callable, $this->reflectArguments($reflection, $args)); } $reflection = new ReflectionFunction($callable); return $reflection->invokeArgs($this->reflectArguments($reflection, $args)); }
[ "public", "function", "call", "(", "callable", "$", "callable", ",", "array", "$", "args", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "callable", ")", "&&", "strpos", "(", "$", "callable", ",", "'::'", ")", "!==", "false", ")", "{",...
Invoke a callable via the container. @param callable $callable @param array $args @return mixed
[ "Invoke", "a", "callable", "via", "the", "container", "." ]
087e9a98876efee4db878c8fd72e04c228cb8aa9
https://github.com/thephpleague/container/blob/087e9a98876efee4db878c8fd72e04c228cb8aa9/src/ReflectionContainer.php#L75-L104
train