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
mrclay/minify
lib/HTTP/Encoder.php
HTTP_Encoder.isBuggyIe
public static function isBuggyIe() { if (empty($_SERVER['HTTP_USER_AGENT'])) { return false; } $ua = $_SERVER['HTTP_USER_AGENT']; // quick escape for non-IEs if (0 !== strpos($ua, 'Mozilla/4.0 (compatible; MSIE ') || false !== strpos($ua, 'Opera')) { return false; } // no regex = faaast $version = (float)substr($ua, 30); return self::$encodeToIe6 ? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1'))) : ($version < 7); }
php
public static function isBuggyIe() { if (empty($_SERVER['HTTP_USER_AGENT'])) { return false; } $ua = $_SERVER['HTTP_USER_AGENT']; // quick escape for non-IEs if (0 !== strpos($ua, 'Mozilla/4.0 (compatible; MSIE ') || false !== strpos($ua, 'Opera')) { return false; } // no regex = faaast $version = (float)substr($ua, 30); return self::$encodeToIe6 ? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1'))) : ($version < 7); }
[ "public", "static", "function", "isBuggyIe", "(", ")", "{", "if", "(", "empty", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "ua", "=", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ";", "// quick escape for non-IEs", "if", "(", "0", "!==", "strpos", "(", "$", "ua", ",", "'Mozilla/4.0 (compatible; MSIE '", ")", "||", "false", "!==", "strpos", "(", "$", "ua", ",", "'Opera'", ")", ")", "{", "return", "false", ";", "}", "// no regex = faaast", "$", "version", "=", "(", "float", ")", "substr", "(", "$", "ua", ",", "30", ")", ";", "return", "self", "::", "$", "encodeToIe6", "?", "(", "$", "version", "<", "6", "||", "(", "$", "version", "==", "6", "&&", "false", "===", "strpos", "(", "$", "ua", ",", "'SV1'", ")", ")", ")", ":", "(", "$", "version", "<", "7", ")", ";", "}" ]
Is the browser an IE version earlier than 6 SP2? @return bool
[ "Is", "the", "browser", "an", "IE", "version", "earlier", "than", "6", "SP2?" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/HTTP/Encoder.php#L312-L329
train
mrclay/minify
lib/Minify/ScssCssSource.php
Minify_ScssCssSource.getCache
private function getCache() { // cache for single run // so that getLastModified and getContent in single request do not add additional cache roundtrips (i.e memcache) if (isset($this->parsed)) { return $this->parsed; } // check from cache first $cache = null; $cacheId = $this->getCacheId(); if ($this->cache->isValid($cacheId, 0)) { if ($cache = $this->cache->fetch($cacheId)) { $cache = unserialize($cache); } } $input = $cache ? $cache : $this->filepath; if ($this->cacheIsStale($cache)) { $cache = $this->compile($this->filepath); } if (!is_array($input) || $cache['updated'] > $input['updated']) { $this->cache->store($cacheId, serialize($cache)); } return $this->parsed = $cache; }
php
private function getCache() { // cache for single run // so that getLastModified and getContent in single request do not add additional cache roundtrips (i.e memcache) if (isset($this->parsed)) { return $this->parsed; } // check from cache first $cache = null; $cacheId = $this->getCacheId(); if ($this->cache->isValid($cacheId, 0)) { if ($cache = $this->cache->fetch($cacheId)) { $cache = unserialize($cache); } } $input = $cache ? $cache : $this->filepath; if ($this->cacheIsStale($cache)) { $cache = $this->compile($this->filepath); } if (!is_array($input) || $cache['updated'] > $input['updated']) { $this->cache->store($cacheId, serialize($cache)); } return $this->parsed = $cache; }
[ "private", "function", "getCache", "(", ")", "{", "// cache for single run", "// so that getLastModified and getContent in single request do not add additional cache roundtrips (i.e memcache)", "if", "(", "isset", "(", "$", "this", "->", "parsed", ")", ")", "{", "return", "$", "this", "->", "parsed", ";", "}", "// check from cache first", "$", "cache", "=", "null", ";", "$", "cacheId", "=", "$", "this", "->", "getCacheId", "(", ")", ";", "if", "(", "$", "this", "->", "cache", "->", "isValid", "(", "$", "cacheId", ",", "0", ")", ")", "{", "if", "(", "$", "cache", "=", "$", "this", "->", "cache", "->", "fetch", "(", "$", "cacheId", ")", ")", "{", "$", "cache", "=", "unserialize", "(", "$", "cache", ")", ";", "}", "}", "$", "input", "=", "$", "cache", "?", "$", "cache", ":", "$", "this", "->", "filepath", ";", "if", "(", "$", "this", "->", "cacheIsStale", "(", "$", "cache", ")", ")", "{", "$", "cache", "=", "$", "this", "->", "compile", "(", "$", "this", "->", "filepath", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "input", ")", "||", "$", "cache", "[", "'updated'", "]", ">", "$", "input", "[", "'updated'", "]", ")", "{", "$", "this", "->", "cache", "->", "store", "(", "$", "cacheId", ",", "serialize", "(", "$", "cache", ")", ")", ";", "}", "return", "$", "this", "->", "parsed", "=", "$", "cache", ";", "}" ]
Get SCSS cache object Runs the compilation if needed Implements Leafo\ScssPhp\Server logic because we need to get parsed files without parsing actual content @return array
[ "Get", "SCSS", "cache", "object" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/ScssCssSource.php#L82-L110
train
mrclay/minify
lib/Minify/HTML/Helper.php
Minify_HTML_Helper.getUri
public static function getUri($keyOrFiles, $opts = array()) { $opts = array_merge(array( // default options 'farExpires' => true, 'debug' => false, 'charset' => 'UTF-8', 'minAppUri' => '/min', 'rewriteWorks' => true, 'groupsConfigFile' => self::app()->groupsConfigPath, ), $opts); $h = new self; $h->minAppUri = $opts['minAppUri']; $h->rewriteWorks = $opts['rewriteWorks']; $h->groupsConfigFile = $opts['groupsConfigFile']; if (is_array($keyOrFiles)) { $h->setFiles($keyOrFiles, $opts['farExpires']); } else { $h->setGroup($keyOrFiles, $opts['farExpires']); } $uri = $h->getRawUri($opts['farExpires'], $opts['debug']); return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']); }
php
public static function getUri($keyOrFiles, $opts = array()) { $opts = array_merge(array( // default options 'farExpires' => true, 'debug' => false, 'charset' => 'UTF-8', 'minAppUri' => '/min', 'rewriteWorks' => true, 'groupsConfigFile' => self::app()->groupsConfigPath, ), $opts); $h = new self; $h->minAppUri = $opts['minAppUri']; $h->rewriteWorks = $opts['rewriteWorks']; $h->groupsConfigFile = $opts['groupsConfigFile']; if (is_array($keyOrFiles)) { $h->setFiles($keyOrFiles, $opts['farExpires']); } else { $h->setGroup($keyOrFiles, $opts['farExpires']); } $uri = $h->getRawUri($opts['farExpires'], $opts['debug']); return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']); }
[ "public", "static", "function", "getUri", "(", "$", "keyOrFiles", ",", "$", "opts", "=", "array", "(", ")", ")", "{", "$", "opts", "=", "array_merge", "(", "array", "(", "// default options", "'farExpires'", "=>", "true", ",", "'debug'", "=>", "false", ",", "'charset'", "=>", "'UTF-8'", ",", "'minAppUri'", "=>", "'/min'", ",", "'rewriteWorks'", "=>", "true", ",", "'groupsConfigFile'", "=>", "self", "::", "app", "(", ")", "->", "groupsConfigPath", ",", ")", ",", "$", "opts", ")", ";", "$", "h", "=", "new", "self", ";", "$", "h", "->", "minAppUri", "=", "$", "opts", "[", "'minAppUri'", "]", ";", "$", "h", "->", "rewriteWorks", "=", "$", "opts", "[", "'rewriteWorks'", "]", ";", "$", "h", "->", "groupsConfigFile", "=", "$", "opts", "[", "'groupsConfigFile'", "]", ";", "if", "(", "is_array", "(", "$", "keyOrFiles", ")", ")", "{", "$", "h", "->", "setFiles", "(", "$", "keyOrFiles", ",", "$", "opts", "[", "'farExpires'", "]", ")", ";", "}", "else", "{", "$", "h", "->", "setGroup", "(", "$", "keyOrFiles", ",", "$", "opts", "[", "'farExpires'", "]", ")", ";", "}", "$", "uri", "=", "$", "h", "->", "getRawUri", "(", "$", "opts", "[", "'farExpires'", "]", ",", "$", "opts", "[", "'debug'", "]", ")", ";", "return", "htmlspecialchars", "(", "$", "uri", ",", "ENT_QUOTES", ",", "$", "opts", "[", "'charset'", "]", ")", ";", "}" ]
Get an HTML-escaped Minify URI for a group or set of files @param string|array $keyOrFiles a group key or array of filepaths/URIs @param array $opts options: 'farExpires' : (default true) append a modified timestamp for cache revving 'debug' : (default false) append debug flag 'charset' : (default 'UTF-8') for htmlspecialchars 'minAppUri' : (default '/min') URI of min directory 'rewriteWorks' : (default true) does mod_rewrite work in min app? 'groupsConfigFile' : specify if different @return string
[ "Get", "an", "HTML", "-", "escaped", "Minify", "URI", "for", "a", "group", "or", "set", "of", "files" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/HTML/Helper.php#L32-L56
train
mrclay/minify
lib/Minify/HTML/Helper.php
Minify_HTML_Helper.getRawUri
public function getRawUri($farExpires = true, $debug = false) { $path = rtrim($this->minAppUri, '/') . '/'; if (! $this->rewriteWorks) { $path .= '?'; } if (null === $this->_groupKey) { // @todo: implement shortest uri $path = self::_getShortestUri($this->_filePaths, $path); } else { $path .= "g=" . $this->_groupKey; } if ($debug) { $path .= "&debug"; } elseif ($farExpires && $this->_lastModified) { $path .= "&" . $this->_lastModified; } return $path; }
php
public function getRawUri($farExpires = true, $debug = false) { $path = rtrim($this->minAppUri, '/') . '/'; if (! $this->rewriteWorks) { $path .= '?'; } if (null === $this->_groupKey) { // @todo: implement shortest uri $path = self::_getShortestUri($this->_filePaths, $path); } else { $path .= "g=" . $this->_groupKey; } if ($debug) { $path .= "&debug"; } elseif ($farExpires && $this->_lastModified) { $path .= "&" . $this->_lastModified; } return $path; }
[ "public", "function", "getRawUri", "(", "$", "farExpires", "=", "true", ",", "$", "debug", "=", "false", ")", "{", "$", "path", "=", "rtrim", "(", "$", "this", "->", "minAppUri", ",", "'/'", ")", ".", "'/'", ";", "if", "(", "!", "$", "this", "->", "rewriteWorks", ")", "{", "$", "path", ".=", "'?'", ";", "}", "if", "(", "null", "===", "$", "this", "->", "_groupKey", ")", "{", "// @todo: implement shortest uri", "$", "path", "=", "self", "::", "_getShortestUri", "(", "$", "this", "->", "_filePaths", ",", "$", "path", ")", ";", "}", "else", "{", "$", "path", ".=", "\"g=\"", ".", "$", "this", "->", "_groupKey", ";", "}", "if", "(", "$", "debug", ")", "{", "$", "path", ".=", "\"&debug\"", ";", "}", "elseif", "(", "$", "farExpires", "&&", "$", "this", "->", "_lastModified", ")", "{", "$", "path", ".=", "\"&\"", ".", "$", "this", "->", "_lastModified", ";", "}", "return", "$", "path", ";", "}" ]
Get non-HTML-escaped URI to minify the specified files @param bool $farExpires @param bool $debug @return string
[ "Get", "non", "-", "HTML", "-", "escaped", "URI", "to", "minify", "the", "specified", "files" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/HTML/Helper.php#L65-L84
train
mrclay/minify
lib/Minify/HTML/Helper.php
Minify_HTML_Helper.setFiles
public function setFiles($files, $checkLastModified = true) { $this->_groupKey = null; if ($checkLastModified) { $this->_lastModified = self::getLastModified($files); } // normalize paths like in /min/f=<paths> foreach ($files as $k => $file) { if (0 === strpos($file, '//')) { $file = substr($file, 2); } elseif (0 === strpos($file, '/') || 1 === strpos($file, ':\\')) { $file = substr($file, strlen(self::app()->env->getDocRoot()) + 1); } $file = strtr($file, '\\', '/'); $files[$k] = $file; } $this->_filePaths = $files; }
php
public function setFiles($files, $checkLastModified = true) { $this->_groupKey = null; if ($checkLastModified) { $this->_lastModified = self::getLastModified($files); } // normalize paths like in /min/f=<paths> foreach ($files as $k => $file) { if (0 === strpos($file, '//')) { $file = substr($file, 2); } elseif (0 === strpos($file, '/') || 1 === strpos($file, ':\\')) { $file = substr($file, strlen(self::app()->env->getDocRoot()) + 1); } $file = strtr($file, '\\', '/'); $files[$k] = $file; } $this->_filePaths = $files; }
[ "public", "function", "setFiles", "(", "$", "files", ",", "$", "checkLastModified", "=", "true", ")", "{", "$", "this", "->", "_groupKey", "=", "null", ";", "if", "(", "$", "checkLastModified", ")", "{", "$", "this", "->", "_lastModified", "=", "self", "::", "getLastModified", "(", "$", "files", ")", ";", "}", "// normalize paths like in /min/f=<paths>", "foreach", "(", "$", "files", "as", "$", "k", "=>", "$", "file", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "file", ",", "'//'", ")", ")", "{", "$", "file", "=", "substr", "(", "$", "file", ",", "2", ")", ";", "}", "elseif", "(", "0", "===", "strpos", "(", "$", "file", ",", "'/'", ")", "||", "1", "===", "strpos", "(", "$", "file", ",", "':\\\\'", ")", ")", "{", "$", "file", "=", "substr", "(", "$", "file", ",", "strlen", "(", "self", "::", "app", "(", ")", "->", "env", "->", "getDocRoot", "(", ")", ")", "+", "1", ")", ";", "}", "$", "file", "=", "strtr", "(", "$", "file", ",", "'\\\\'", ",", "'/'", ")", ";", "$", "files", "[", "$", "k", "]", "=", "$", "file", ";", "}", "$", "this", "->", "_filePaths", "=", "$", "files", ";", "}" ]
Set the files that will comprise the URI we're building @param array $files @param bool $checkLastModified
[ "Set", "the", "files", "that", "will", "comprise", "the", "URI", "we", "re", "building" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/HTML/Helper.php#L92-L109
train
mrclay/minify
lib/Minify/HTML/Helper.php
Minify_HTML_Helper.setGroup
public function setGroup($key, $checkLastModified = true) { $this->_groupKey = $key; if ($checkLastModified) { if (! $this->groupsConfigFile) { $this->groupsConfigFile = self::app()->groupsConfigPath; } if (is_file($this->groupsConfigFile)) { $gc = (require $this->groupsConfigFile); $keys = explode(',', $key); foreach ($keys as $key) { if (!isset($gc[$key])) { // this can happen if value is null // which could be solved with array_filter continue; } $this->_lastModified = self::getLastModified($gc[$key], $this->_lastModified); } } } }
php
public function setGroup($key, $checkLastModified = true) { $this->_groupKey = $key; if ($checkLastModified) { if (! $this->groupsConfigFile) { $this->groupsConfigFile = self::app()->groupsConfigPath; } if (is_file($this->groupsConfigFile)) { $gc = (require $this->groupsConfigFile); $keys = explode(',', $key); foreach ($keys as $key) { if (!isset($gc[$key])) { // this can happen if value is null // which could be solved with array_filter continue; } $this->_lastModified = self::getLastModified($gc[$key], $this->_lastModified); } } } }
[ "public", "function", "setGroup", "(", "$", "key", ",", "$", "checkLastModified", "=", "true", ")", "{", "$", "this", "->", "_groupKey", "=", "$", "key", ";", "if", "(", "$", "checkLastModified", ")", "{", "if", "(", "!", "$", "this", "->", "groupsConfigFile", ")", "{", "$", "this", "->", "groupsConfigFile", "=", "self", "::", "app", "(", ")", "->", "groupsConfigPath", ";", "}", "if", "(", "is_file", "(", "$", "this", "->", "groupsConfigFile", ")", ")", "{", "$", "gc", "=", "(", "require", "$", "this", "->", "groupsConfigFile", ")", ";", "$", "keys", "=", "explode", "(", "','", ",", "$", "key", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "gc", "[", "$", "key", "]", ")", ")", "{", "// this can happen if value is null", "// which could be solved with array_filter", "continue", ";", "}", "$", "this", "->", "_lastModified", "=", "self", "::", "getLastModified", "(", "$", "gc", "[", "$", "key", "]", ",", "$", "this", "->", "_lastModified", ")", ";", "}", "}", "}", "}" ]
Set the group of files that will comprise the URI we're building @param string $key @param bool $checkLastModified
[ "Set", "the", "group", "of", "files", "that", "will", "comprise", "the", "URI", "we", "re", "building" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/HTML/Helper.php#L117-L138
train
mrclay/minify
lib/Minify/HTML/Helper.php
Minify_HTML_Helper._getCommonCharAtPos
protected static function _getCommonCharAtPos($arr, $pos) { if (!isset($arr[0][$pos])) { return ''; } $c = $arr[0][$pos]; $l = count($arr); if ($l === 1) { return $c; } for ($i = 1; $i < $l; ++$i) { if ($arr[$i][$pos] !== $c) { return ''; } } return $c; }
php
protected static function _getCommonCharAtPos($arr, $pos) { if (!isset($arr[0][$pos])) { return ''; } $c = $arr[0][$pos]; $l = count($arr); if ($l === 1) { return $c; } for ($i = 1; $i < $l; ++$i) { if ($arr[$i][$pos] !== $c) { return ''; } } return $c; }
[ "protected", "static", "function", "_getCommonCharAtPos", "(", "$", "arr", ",", "$", "pos", ")", "{", "if", "(", "!", "isset", "(", "$", "arr", "[", "0", "]", "[", "$", "pos", "]", ")", ")", "{", "return", "''", ";", "}", "$", "c", "=", "$", "arr", "[", "0", "]", "[", "$", "pos", "]", ";", "$", "l", "=", "count", "(", "$", "arr", ")", ";", "if", "(", "$", "l", "===", "1", ")", "{", "return", "$", "c", ";", "}", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "$", "l", ";", "++", "$", "i", ")", "{", "if", "(", "$", "arr", "[", "$", "i", "]", "[", "$", "pos", "]", "!==", "$", "c", ")", "{", "return", "''", ";", "}", "}", "return", "$", "c", ";", "}" ]
In a given array of strings, find the character they all have at a particular index @param array $arr array of strings @param int $pos index to check @return mixed a common char or '' if any do not match
[ "In", "a", "given", "array", "of", "strings", "find", "the", "character", "they", "all", "have", "at", "a", "particular", "index" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/HTML/Helper.php#L193-L210
train
mrclay/minify
lib/Minify.php
Minify.getDefaultOptions
public function getDefaultOptions() { return array( 'isPublic' => true, 'encodeOutput' => function_exists('gzdeflate'), 'encodeMethod' => null, // determine later 'encodeLevel' => 9, 'minifiers' => array( Minify::TYPE_JS => array('JSMin\\JSMin', 'minify'), Minify::TYPE_CSS => array('Minify_CSSmin', 'minify'), Minify::TYPE_HTML => array('Minify_HTML', 'minify'), ), 'minifierOptions' => array(), // no minifier options 'contentTypeCharset' => 'utf-8', 'maxAge' => 1800, // 30 minutes 'rewriteCssUris' => true, 'bubbleCssImports' => false, 'quiet' => false, // serve() will send headers and output 'debug' => false, 'concatOnly' => false, // if you override these, the response codes MUST be directly after // the first space. 'badRequestHeader' => 'HTTP/1.0 400 Bad Request', 'errorHeader' => 'HTTP/1.0 500 Internal Server Error', // callback function to see/modify content of all sources 'postprocessor' => null, // file to require to load preprocessor 'postprocessorRequire' => null, /** * If this string is not empty AND the serve() option 'bubbleCssImports' is * NOT set, then serve() will check CSS files for @import declarations that * appear too late in the combined stylesheet. If found, serve() will prepend * the output with this warning. */ 'importWarning' => "/* See https://github.com/mrclay/minify/blob/master/docs/CommonProblems.wiki.md#imports-can-appear-in-invalid-locations-in-combined-css-files */\n" ); }
php
public function getDefaultOptions() { return array( 'isPublic' => true, 'encodeOutput' => function_exists('gzdeflate'), 'encodeMethod' => null, // determine later 'encodeLevel' => 9, 'minifiers' => array( Minify::TYPE_JS => array('JSMin\\JSMin', 'minify'), Minify::TYPE_CSS => array('Minify_CSSmin', 'minify'), Minify::TYPE_HTML => array('Minify_HTML', 'minify'), ), 'minifierOptions' => array(), // no minifier options 'contentTypeCharset' => 'utf-8', 'maxAge' => 1800, // 30 minutes 'rewriteCssUris' => true, 'bubbleCssImports' => false, 'quiet' => false, // serve() will send headers and output 'debug' => false, 'concatOnly' => false, // if you override these, the response codes MUST be directly after // the first space. 'badRequestHeader' => 'HTTP/1.0 400 Bad Request', 'errorHeader' => 'HTTP/1.0 500 Internal Server Error', // callback function to see/modify content of all sources 'postprocessor' => null, // file to require to load preprocessor 'postprocessorRequire' => null, /** * If this string is not empty AND the serve() option 'bubbleCssImports' is * NOT set, then serve() will check CSS files for @import declarations that * appear too late in the combined stylesheet. If found, serve() will prepend * the output with this warning. */ 'importWarning' => "/* See https://github.com/mrclay/minify/blob/master/docs/CommonProblems.wiki.md#imports-can-appear-in-invalid-locations-in-combined-css-files */\n" ); }
[ "public", "function", "getDefaultOptions", "(", ")", "{", "return", "array", "(", "'isPublic'", "=>", "true", ",", "'encodeOutput'", "=>", "function_exists", "(", "'gzdeflate'", ")", ",", "'encodeMethod'", "=>", "null", ",", "// determine later", "'encodeLevel'", "=>", "9", ",", "'minifiers'", "=>", "array", "(", "Minify", "::", "TYPE_JS", "=>", "array", "(", "'JSMin\\\\JSMin'", ",", "'minify'", ")", ",", "Minify", "::", "TYPE_CSS", "=>", "array", "(", "'Minify_CSSmin'", ",", "'minify'", ")", ",", "Minify", "::", "TYPE_HTML", "=>", "array", "(", "'Minify_HTML'", ",", "'minify'", ")", ",", ")", ",", "'minifierOptions'", "=>", "array", "(", ")", ",", "// no minifier options", "'contentTypeCharset'", "=>", "'utf-8'", ",", "'maxAge'", "=>", "1800", ",", "// 30 minutes", "'rewriteCssUris'", "=>", "true", ",", "'bubbleCssImports'", "=>", "false", ",", "'quiet'", "=>", "false", ",", "// serve() will send headers and output", "'debug'", "=>", "false", ",", "'concatOnly'", "=>", "false", ",", "// if you override these, the response codes MUST be directly after", "// the first space.", "'badRequestHeader'", "=>", "'HTTP/1.0 400 Bad Request'", ",", "'errorHeader'", "=>", "'HTTP/1.0 500 Internal Server Error'", ",", "// callback function to see/modify content of all sources", "'postprocessor'", "=>", "null", ",", "// file to require to load preprocessor", "'postprocessorRequire'", "=>", "null", ",", "/**\n * If this string is not empty AND the serve() option 'bubbleCssImports' is\n * NOT set, then serve() will check CSS files for @import declarations that\n * appear too late in the combined stylesheet. If found, serve() will prepend\n * the output with this warning.\n */", "'importWarning'", "=>", "\"/* See https://github.com/mrclay/minify/blob/master/docs/CommonProblems.wiki.md#imports-can-appear-in-invalid-locations-in-combined-css-files */\\n\"", ")", ";", "}" ]
Get default Minify options. @return array options for Minify
[ "Get", "default", "Minify", "options", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify.php#L99-L140
train
mrclay/minify
lib/Minify.php
Minify.combine
public function combine($sources, $options = array()) { $tmpCache = $this->cache; $this->cache = new Minify_Cache_Null(); $env = new Minify_Env(); $sourceFactory = new Minify_Source_Factory($env, array( 'checkAllowDirs' => false, ), $this->cache); $controller = new Minify_Controller_Files($env, $sourceFactory, $this->logger); $options = array_merge($options, array( 'files' => (array)$sources, 'quiet' => true, 'encodeMethod' => '', 'lastModifiedTime' => 0, )); $out = $this->serve($controller, $options); $this->cache = $tmpCache; return $out['content']; }
php
public function combine($sources, $options = array()) { $tmpCache = $this->cache; $this->cache = new Minify_Cache_Null(); $env = new Minify_Env(); $sourceFactory = new Minify_Source_Factory($env, array( 'checkAllowDirs' => false, ), $this->cache); $controller = new Minify_Controller_Files($env, $sourceFactory, $this->logger); $options = array_merge($options, array( 'files' => (array)$sources, 'quiet' => true, 'encodeMethod' => '', 'lastModifiedTime' => 0, )); $out = $this->serve($controller, $options); $this->cache = $tmpCache; return $out['content']; }
[ "public", "function", "combine", "(", "$", "sources", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "tmpCache", "=", "$", "this", "->", "cache", ";", "$", "this", "->", "cache", "=", "new", "Minify_Cache_Null", "(", ")", ";", "$", "env", "=", "new", "Minify_Env", "(", ")", ";", "$", "sourceFactory", "=", "new", "Minify_Source_Factory", "(", "$", "env", ",", "array", "(", "'checkAllowDirs'", "=>", "false", ",", ")", ",", "$", "this", "->", "cache", ")", ";", "$", "controller", "=", "new", "Minify_Controller_Files", "(", "$", "env", ",", "$", "sourceFactory", ",", "$", "this", "->", "logger", ")", ";", "$", "options", "=", "array_merge", "(", "$", "options", ",", "array", "(", "'files'", "=>", "(", "array", ")", "$", "sources", ",", "'quiet'", "=>", "true", ",", "'encodeMethod'", "=>", "''", ",", "'lastModifiedTime'", "=>", "0", ",", ")", ")", ";", "$", "out", "=", "$", "this", "->", "serve", "(", "$", "controller", ",", "$", "options", ")", ";", "$", "this", "->", "cache", "=", "$", "tmpCache", ";", "return", "$", "out", "[", "'content'", "]", ";", "}" ]
Return combined minified content for a set of sources No internal caching will be used and the content will not be HTTP encoded. @param array $sources array of filepaths and/or Minify_Source objects @param array $options (optional) array of options for serve. @return string
[ "Return", "combined", "minified", "content", "for", "a", "set", "of", "sources" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify.php#L435-L457
train
mrclay/minify
lib/Minify.php
Minify.errorExit
public function errorExit($header, $url = '', $msgHtml = '') { $url = htmlspecialchars($url, ENT_QUOTES); list(,$h1) = explode(' ', $header, 2); $h1 = htmlspecialchars($h1); // FastCGI environments require 3rd arg to header() to be set list(, $code) = explode(' ', $header, 3); header($header, true, $code); header('Content-Type: text/html; charset=utf-8'); echo "<h1>$h1</h1>"; if ($msgHtml) { echo $msgHtml; } if ($url) { echo "<p>Please see <a href='$url'>$url</a>.</p>"; } exit; }
php
public function errorExit($header, $url = '', $msgHtml = '') { $url = htmlspecialchars($url, ENT_QUOTES); list(,$h1) = explode(' ', $header, 2); $h1 = htmlspecialchars($h1); // FastCGI environments require 3rd arg to header() to be set list(, $code) = explode(' ', $header, 3); header($header, true, $code); header('Content-Type: text/html; charset=utf-8'); echo "<h1>$h1</h1>"; if ($msgHtml) { echo $msgHtml; } if ($url) { echo "<p>Please see <a href='$url'>$url</a>.</p>"; } exit; }
[ "public", "function", "errorExit", "(", "$", "header", ",", "$", "url", "=", "''", ",", "$", "msgHtml", "=", "''", ")", "{", "$", "url", "=", "htmlspecialchars", "(", "$", "url", ",", "ENT_QUOTES", ")", ";", "list", "(", ",", "$", "h1", ")", "=", "explode", "(", "' '", ",", "$", "header", ",", "2", ")", ";", "$", "h1", "=", "htmlspecialchars", "(", "$", "h1", ")", ";", "// FastCGI environments require 3rd arg to header() to be set", "list", "(", ",", "$", "code", ")", "=", "explode", "(", "' '", ",", "$", "header", ",", "3", ")", ";", "header", "(", "$", "header", ",", "true", ",", "$", "code", ")", ";", "header", "(", "'Content-Type: text/html; charset=utf-8'", ")", ";", "echo", "\"<h1>$h1</h1>\"", ";", "if", "(", "$", "msgHtml", ")", "{", "echo", "$", "msgHtml", ";", "}", "if", "(", "$", "url", ")", "{", "echo", "\"<p>Please see <a href='$url'>$url</a>.</p>\"", ";", "}", "exit", ";", "}" ]
Show an error page @param string $header Full header. E.g. 'HTTP/1.0 500 Internal Server Error' @param string $url URL to direct the user to @param string $msgHtml HTML message for the client @return void @internal This is not part of the public API and is subject to change @access private
[ "Show", "an", "error", "page" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify.php#L470-L487
train
mrclay/minify
lib/Minify.php
Minify.nullMinifier
public static function nullMinifier($content) { if (isset($content[0]) && $content[0] === "\xef") { $content = substr($content, 3); } $content = str_replace("\r\n", "\n", $content); return trim($content); }
php
public static function nullMinifier($content) { if (isset($content[0]) && $content[0] === "\xef") { $content = substr($content, 3); } $content = str_replace("\r\n", "\n", $content); return trim($content); }
[ "public", "static", "function", "nullMinifier", "(", "$", "content", ")", "{", "if", "(", "isset", "(", "$", "content", "[", "0", "]", ")", "&&", "$", "content", "[", "0", "]", "===", "\"\\xef\"", ")", "{", "$", "content", "=", "substr", "(", "$", "content", ",", "3", ")", ";", "}", "$", "content", "=", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ",", "$", "content", ")", ";", "return", "trim", "(", "$", "content", ")", ";", "}" ]
Default minifier for .min or -min JS files. @param string $content @return string
[ "Default", "minifier", "for", ".", "min", "or", "-", "min", "JS", "files", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify.php#L495-L503
train
mrclay/minify
lib/Minify.php
Minify.setupUriRewrites
protected function setupUriRewrites() { foreach ($this->sources as $key => $source) { $file = $this->env->normalizePath($source->getFilePath()); $minifyOptions = $source->getMinifierOptions(); if ($file && !isset($minifyOptions['currentDir']) && !isset($minifyOptions['prependRelativePath'])) { $minifyOptions['currentDir'] = dirname($file); $source->setMinifierOptions($minifyOptions); } } }
php
protected function setupUriRewrites() { foreach ($this->sources as $key => $source) { $file = $this->env->normalizePath($source->getFilePath()); $minifyOptions = $source->getMinifierOptions(); if ($file && !isset($minifyOptions['currentDir']) && !isset($minifyOptions['prependRelativePath'])) { $minifyOptions['currentDir'] = dirname($file); $source->setMinifierOptions($minifyOptions); } } }
[ "protected", "function", "setupUriRewrites", "(", ")", "{", "foreach", "(", "$", "this", "->", "sources", "as", "$", "key", "=>", "$", "source", ")", "{", "$", "file", "=", "$", "this", "->", "env", "->", "normalizePath", "(", "$", "source", "->", "getFilePath", "(", ")", ")", ";", "$", "minifyOptions", "=", "$", "source", "->", "getMinifierOptions", "(", ")", ";", "if", "(", "$", "file", "&&", "!", "isset", "(", "$", "minifyOptions", "[", "'currentDir'", "]", ")", "&&", "!", "isset", "(", "$", "minifyOptions", "[", "'prependRelativePath'", "]", ")", ")", "{", "$", "minifyOptions", "[", "'currentDir'", "]", "=", "dirname", "(", "$", "file", ")", ";", "$", "source", "->", "setMinifierOptions", "(", "$", "minifyOptions", ")", ";", "}", "}", "}" ]
Setup CSS sources for URI rewriting
[ "Setup", "CSS", "sources", "for", "URI", "rewriting" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify.php#L508-L521
train
mrclay/minify
lib/Minify.php
Minify.setupDebug
protected function setupDebug() { foreach ($this->sources as $source) { $source->setMinifier(array('Minify_Lines', 'minify')); $id = $source->getId(); $source->setMinifierOptions(array( 'id' => (is_file($id) ? basename($id) : $id), )); } }
php
protected function setupDebug() { foreach ($this->sources as $source) { $source->setMinifier(array('Minify_Lines', 'minify')); $id = $source->getId(); $source->setMinifierOptions(array( 'id' => (is_file($id) ? basename($id) : $id), )); } }
[ "protected", "function", "setupDebug", "(", ")", "{", "foreach", "(", "$", "this", "->", "sources", "as", "$", "source", ")", "{", "$", "source", "->", "setMinifier", "(", "array", "(", "'Minify_Lines'", ",", "'minify'", ")", ")", ";", "$", "id", "=", "$", "source", "->", "getId", "(", ")", ";", "$", "source", "->", "setMinifierOptions", "(", "array", "(", "'id'", "=>", "(", "is_file", "(", "$", "id", ")", "?", "basename", "(", "$", "id", ")", ":", "$", "id", ")", ",", ")", ")", ";", "}", "}" ]
Set up sources to use Minify_Lines
[ "Set", "up", "sources", "to", "use", "Minify_Lines" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify.php#L526-L535
train
mrclay/minify
lib/Minify.php
Minify.combineMinify
protected function combineMinify() { $type = $this->options['contentType']; // ease readability // when combining scripts, make sure all statements separated and // trailing single line comment is terminated $implodeSeparator = ($type === self::TYPE_JS) ? "\n;" : ''; // allow the user to pass a particular array of options to each // minifier (designated by type). source objects may still override // these if (isset($this->options['minifierOptions'][$type])) { $defaultOptions = $this->options['minifierOptions'][$type]; } else { $defaultOptions = array(); } // if minifier not set, default is no minification. source objects // may still override this if (isset($this->options['minifiers'][$type])) { $defaultMinifier = $this->options['minifiers'][$type]; } else { $defaultMinifier = false; } // process groups of sources with identical minifiers/options $content = array(); $i = 0; $l = count($this->sources); $groupToProcessTogether = array(); $lastMinifier = null; $lastOptions = null; do { // get next source $source = null; if ($i < $l) { $source = $this->sources[$i]; $sourceContent = $source->getContent(); // allow the source to override our minifier and options $minifier = $source->getMinifier(); if (!$minifier) { $minifier = $defaultMinifier; } $options = array_merge($defaultOptions, $source->getMinifierOptions()); } // do we need to process our group right now? if ($i > 0 // yes, we have at least the first group populated && ( ! $source // yes, we ran out of sources || $type === self::TYPE_CSS // yes, to process CSS individually (avoiding PCRE bugs/limits) || $minifier !== $lastMinifier // yes, minifier changed || $options !== $lastOptions)) { // yes, options changed // minify previous sources with last settings $imploded = implode($implodeSeparator, $groupToProcessTogether); $groupToProcessTogether = array(); if ($lastMinifier) { try { $content[] = call_user_func($lastMinifier, $imploded, $lastOptions); } catch (Exception $e) { throw new Exception("Exception in minifier: " . $e->getMessage()); } } else { $content[] = $imploded; } } // add content to the group if ($source) { $groupToProcessTogether[] = $sourceContent; $lastMinifier = $minifier; $lastOptions = $options; } $i++; } while ($source); $content = implode($implodeSeparator, $content); if ($type === self::TYPE_CSS && false !== strpos($content, '@import')) { $content = $this->handleCssImports($content); } // do any post-processing (esp. for editing build URIs) if ($this->options['postprocessorRequire']) { require_once $this->options['postprocessorRequire']; } if ($this->options['postprocessor']) { $content = call_user_func($this->options['postprocessor'], $content, $type); } return $content; }
php
protected function combineMinify() { $type = $this->options['contentType']; // ease readability // when combining scripts, make sure all statements separated and // trailing single line comment is terminated $implodeSeparator = ($type === self::TYPE_JS) ? "\n;" : ''; // allow the user to pass a particular array of options to each // minifier (designated by type). source objects may still override // these if (isset($this->options['minifierOptions'][$type])) { $defaultOptions = $this->options['minifierOptions'][$type]; } else { $defaultOptions = array(); } // if minifier not set, default is no minification. source objects // may still override this if (isset($this->options['minifiers'][$type])) { $defaultMinifier = $this->options['minifiers'][$type]; } else { $defaultMinifier = false; } // process groups of sources with identical minifiers/options $content = array(); $i = 0; $l = count($this->sources); $groupToProcessTogether = array(); $lastMinifier = null; $lastOptions = null; do { // get next source $source = null; if ($i < $l) { $source = $this->sources[$i]; $sourceContent = $source->getContent(); // allow the source to override our minifier and options $minifier = $source->getMinifier(); if (!$minifier) { $minifier = $defaultMinifier; } $options = array_merge($defaultOptions, $source->getMinifierOptions()); } // do we need to process our group right now? if ($i > 0 // yes, we have at least the first group populated && ( ! $source // yes, we ran out of sources || $type === self::TYPE_CSS // yes, to process CSS individually (avoiding PCRE bugs/limits) || $minifier !== $lastMinifier // yes, minifier changed || $options !== $lastOptions)) { // yes, options changed // minify previous sources with last settings $imploded = implode($implodeSeparator, $groupToProcessTogether); $groupToProcessTogether = array(); if ($lastMinifier) { try { $content[] = call_user_func($lastMinifier, $imploded, $lastOptions); } catch (Exception $e) { throw new Exception("Exception in minifier: " . $e->getMessage()); } } else { $content[] = $imploded; } } // add content to the group if ($source) { $groupToProcessTogether[] = $sourceContent; $lastMinifier = $minifier; $lastOptions = $options; } $i++; } while ($source); $content = implode($implodeSeparator, $content); if ($type === self::TYPE_CSS && false !== strpos($content, '@import')) { $content = $this->handleCssImports($content); } // do any post-processing (esp. for editing build URIs) if ($this->options['postprocessorRequire']) { require_once $this->options['postprocessorRequire']; } if ($this->options['postprocessor']) { $content = call_user_func($this->options['postprocessor'], $content, $type); } return $content; }
[ "protected", "function", "combineMinify", "(", ")", "{", "$", "type", "=", "$", "this", "->", "options", "[", "'contentType'", "]", ";", "// ease readability", "// when combining scripts, make sure all statements separated and", "// trailing single line comment is terminated", "$", "implodeSeparator", "=", "(", "$", "type", "===", "self", "::", "TYPE_JS", ")", "?", "\"\\n;\"", ":", "''", ";", "// allow the user to pass a particular array of options to each", "// minifier (designated by type). source objects may still override", "// these", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'minifierOptions'", "]", "[", "$", "type", "]", ")", ")", "{", "$", "defaultOptions", "=", "$", "this", "->", "options", "[", "'minifierOptions'", "]", "[", "$", "type", "]", ";", "}", "else", "{", "$", "defaultOptions", "=", "array", "(", ")", ";", "}", "// if minifier not set, default is no minification. source objects", "// may still override this", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'minifiers'", "]", "[", "$", "type", "]", ")", ")", "{", "$", "defaultMinifier", "=", "$", "this", "->", "options", "[", "'minifiers'", "]", "[", "$", "type", "]", ";", "}", "else", "{", "$", "defaultMinifier", "=", "false", ";", "}", "// process groups of sources with identical minifiers/options", "$", "content", "=", "array", "(", ")", ";", "$", "i", "=", "0", ";", "$", "l", "=", "count", "(", "$", "this", "->", "sources", ")", ";", "$", "groupToProcessTogether", "=", "array", "(", ")", ";", "$", "lastMinifier", "=", "null", ";", "$", "lastOptions", "=", "null", ";", "do", "{", "// get next source", "$", "source", "=", "null", ";", "if", "(", "$", "i", "<", "$", "l", ")", "{", "$", "source", "=", "$", "this", "->", "sources", "[", "$", "i", "]", ";", "$", "sourceContent", "=", "$", "source", "->", "getContent", "(", ")", ";", "// allow the source to override our minifier and options", "$", "minifier", "=", "$", "source", "->", "getMinifier", "(", ")", ";", "if", "(", "!", "$", "minifier", ")", "{", "$", "minifier", "=", "$", "defaultMinifier", ";", "}", "$", "options", "=", "array_merge", "(", "$", "defaultOptions", ",", "$", "source", "->", "getMinifierOptions", "(", ")", ")", ";", "}", "// do we need to process our group right now?", "if", "(", "$", "i", ">", "0", "// yes, we have at least the first group populated", "&&", "(", "!", "$", "source", "// yes, we ran out of sources", "||", "$", "type", "===", "self", "::", "TYPE_CSS", "// yes, to process CSS individually (avoiding PCRE bugs/limits)", "||", "$", "minifier", "!==", "$", "lastMinifier", "// yes, minifier changed", "||", "$", "options", "!==", "$", "lastOptions", ")", ")", "{", "// yes, options changed", "// minify previous sources with last settings", "$", "imploded", "=", "implode", "(", "$", "implodeSeparator", ",", "$", "groupToProcessTogether", ")", ";", "$", "groupToProcessTogether", "=", "array", "(", ")", ";", "if", "(", "$", "lastMinifier", ")", "{", "try", "{", "$", "content", "[", "]", "=", "call_user_func", "(", "$", "lastMinifier", ",", "$", "imploded", ",", "$", "lastOptions", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "\"Exception in minifier: \"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "else", "{", "$", "content", "[", "]", "=", "$", "imploded", ";", "}", "}", "// add content to the group", "if", "(", "$", "source", ")", "{", "$", "groupToProcessTogether", "[", "]", "=", "$", "sourceContent", ";", "$", "lastMinifier", "=", "$", "minifier", ";", "$", "lastOptions", "=", "$", "options", ";", "}", "$", "i", "++", ";", "}", "while", "(", "$", "source", ")", ";", "$", "content", "=", "implode", "(", "$", "implodeSeparator", ",", "$", "content", ")", ";", "if", "(", "$", "type", "===", "self", "::", "TYPE_CSS", "&&", "false", "!==", "strpos", "(", "$", "content", ",", "'@import'", ")", ")", "{", "$", "content", "=", "$", "this", "->", "handleCssImports", "(", "$", "content", ")", ";", "}", "// do any post-processing (esp. for editing build URIs)", "if", "(", "$", "this", "->", "options", "[", "'postprocessorRequire'", "]", ")", "{", "require_once", "$", "this", "->", "options", "[", "'postprocessorRequire'", "]", ";", "}", "if", "(", "$", "this", "->", "options", "[", "'postprocessor'", "]", ")", "{", "$", "content", "=", "call_user_func", "(", "$", "this", "->", "options", "[", "'postprocessor'", "]", ",", "$", "content", ",", "$", "type", ")", ";", "}", "return", "$", "content", ";", "}" ]
Combines sources and minifies the result. @return string @throws Exception
[ "Combines", "sources", "and", "minifies", "the", "result", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify.php#L544-L634
train
mrclay/minify
lib/Minify.php
Minify._getCacheId
protected function _getCacheId($prefix = 'minify') { $name = preg_replace('/[^a-zA-Z0-9\\.=_,]/', '', $this->selectionId); $name = preg_replace('/\\.+/', '.', $name); $name = substr($name, 0, 100 - 34 - strlen($prefix)); $md5 = md5(serialize(array( Minify_SourceSet::getDigest($this->sources), $this->options['minifiers'], $this->options['minifierOptions'], $this->options['postprocessor'], $this->options['bubbleCssImports'], Minify::VERSION, ))); return "{$prefix}_{$name}_{$md5}"; }
php
protected function _getCacheId($prefix = 'minify') { $name = preg_replace('/[^a-zA-Z0-9\\.=_,]/', '', $this->selectionId); $name = preg_replace('/\\.+/', '.', $name); $name = substr($name, 0, 100 - 34 - strlen($prefix)); $md5 = md5(serialize(array( Minify_SourceSet::getDigest($this->sources), $this->options['minifiers'], $this->options['minifierOptions'], $this->options['postprocessor'], $this->options['bubbleCssImports'], Minify::VERSION, ))); return "{$prefix}_{$name}_{$md5}"; }
[ "protected", "function", "_getCacheId", "(", "$", "prefix", "=", "'minify'", ")", "{", "$", "name", "=", "preg_replace", "(", "'/[^a-zA-Z0-9\\\\.=_,]/'", ",", "''", ",", "$", "this", "->", "selectionId", ")", ";", "$", "name", "=", "preg_replace", "(", "'/\\\\.+/'", ",", "'.'", ",", "$", "name", ")", ";", "$", "name", "=", "substr", "(", "$", "name", ",", "0", ",", "100", "-", "34", "-", "strlen", "(", "$", "prefix", ")", ")", ";", "$", "md5", "=", "md5", "(", "serialize", "(", "array", "(", "Minify_SourceSet", "::", "getDigest", "(", "$", "this", "->", "sources", ")", ",", "$", "this", "->", "options", "[", "'minifiers'", "]", ",", "$", "this", "->", "options", "[", "'minifierOptions'", "]", ",", "$", "this", "->", "options", "[", "'postprocessor'", "]", ",", "$", "this", "->", "options", "[", "'bubbleCssImports'", "]", ",", "Minify", "::", "VERSION", ",", ")", ")", ")", ";", "return", "\"{$prefix}_{$name}_{$md5}\"", ";", "}" ]
Make a unique cache id for for this request. Any settings that could affect output are taken into consideration @param string $prefix @return string
[ "Make", "a", "unique", "cache", "id", "for", "for", "this", "request", "." ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify.php#L645-L660
train
mrclay/minify
lib/Minify/JS/ClosureCompiler.php
Minify_JS_ClosureCompiler.min
public function min($js) { $postBody = $this->buildPostBody($js); if ($this->maxBytes > 0) { $bytes = (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) ? mb_strlen($postBody, '8bit') : strlen($postBody); if ($bytes > $this->maxBytes) { throw new Minify_JS_ClosureCompiler_Exception( 'POST content larger than ' . $this->maxBytes . ' bytes' ); } } $response = $this->getResponse($postBody); if (preg_match('/^Error\(\d\d?\):/', $response)) { if (is_callable($this->fallbackMinifier)) { // use fallback $response = "/* Received errors from Closure Compiler API:\n$response" . "\n(Using fallback minifier)\n*/\n"; $response .= call_user_func($this->fallbackMinifier, $js); } else { throw new Minify_JS_ClosureCompiler_Exception($response); } } if ($response === '') { $errors = $this->getResponse($this->buildPostBody($js, true)); throw new Minify_JS_ClosureCompiler_Exception($errors); } return $response; }
php
public function min($js) { $postBody = $this->buildPostBody($js); if ($this->maxBytes > 0) { $bytes = (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) ? mb_strlen($postBody, '8bit') : strlen($postBody); if ($bytes > $this->maxBytes) { throw new Minify_JS_ClosureCompiler_Exception( 'POST content larger than ' . $this->maxBytes . ' bytes' ); } } $response = $this->getResponse($postBody); if (preg_match('/^Error\(\d\d?\):/', $response)) { if (is_callable($this->fallbackMinifier)) { // use fallback $response = "/* Received errors from Closure Compiler API:\n$response" . "\n(Using fallback minifier)\n*/\n"; $response .= call_user_func($this->fallbackMinifier, $js); } else { throw new Minify_JS_ClosureCompiler_Exception($response); } } if ($response === '') { $errors = $this->getResponse($this->buildPostBody($js, true)); throw new Minify_JS_ClosureCompiler_Exception($errors); } return $response; }
[ "public", "function", "min", "(", "$", "js", ")", "{", "$", "postBody", "=", "$", "this", "->", "buildPostBody", "(", "$", "js", ")", ";", "if", "(", "$", "this", "->", "maxBytes", ">", "0", ")", "{", "$", "bytes", "=", "(", "function_exists", "(", "'mb_strlen'", ")", "&&", "(", "(", "int", ")", "ini_get", "(", "'mbstring.func_overload'", ")", "&", "2", ")", ")", "?", "mb_strlen", "(", "$", "postBody", ",", "'8bit'", ")", ":", "strlen", "(", "$", "postBody", ")", ";", "if", "(", "$", "bytes", ">", "$", "this", "->", "maxBytes", ")", "{", "throw", "new", "Minify_JS_ClosureCompiler_Exception", "(", "'POST content larger than '", ".", "$", "this", "->", "maxBytes", ".", "' bytes'", ")", ";", "}", "}", "$", "response", "=", "$", "this", "->", "getResponse", "(", "$", "postBody", ")", ";", "if", "(", "preg_match", "(", "'/^Error\\(\\d\\d?\\):/'", ",", "$", "response", ")", ")", "{", "if", "(", "is_callable", "(", "$", "this", "->", "fallbackMinifier", ")", ")", "{", "// use fallback", "$", "response", "=", "\"/* Received errors from Closure Compiler API:\\n$response\"", ".", "\"\\n(Using fallback minifier)\\n*/\\n\"", ";", "$", "response", ".=", "call_user_func", "(", "$", "this", "->", "fallbackMinifier", ",", "$", "js", ")", ";", "}", "else", "{", "throw", "new", "Minify_JS_ClosureCompiler_Exception", "(", "$", "response", ")", ";", "}", "}", "if", "(", "$", "response", "===", "''", ")", "{", "$", "errors", "=", "$", "this", "->", "getResponse", "(", "$", "this", "->", "buildPostBody", "(", "$", "js", ",", "true", ")", ")", ";", "throw", "new", "Minify_JS_ClosureCompiler_Exception", "(", "$", "errors", ")", ";", "}", "return", "$", "response", ";", "}" ]
Call the service to perform the minification @param string $js JavaScript code @return string @throws Minify_JS_ClosureCompiler_Exception
[ "Call", "the", "service", "to", "perform", "the", "minification" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/JS/ClosureCompiler.php#L126-L160
train
mrclay/minify
lib/Minify/JS/ClosureCompiler.php
Minify_JS_ClosureCompiler.getResponse
protected function getResponse($postBody) { $allowUrlFopen = preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen')); if ($allowUrlFopen) { $contents = file_get_contents($this->serviceUrl, false, stream_context_create(array( 'http' => array( 'method' => 'POST', 'compilation_level' => 'SIMPLE', 'output_format' => 'text', 'output_info' => 'compiled_code', 'header' => "Content-type: application/x-www-form-urlencoded\r\nConnection: close\r\n", 'content' => $postBody, 'max_redirects' => 0, 'timeout' => 15, ) ))); } elseif (defined('CURLOPT_POST')) { $ch = curl_init($this->serviceUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded')); curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); $contents = curl_exec($ch); curl_close($ch); } else { throw new Minify_JS_ClosureCompiler_Exception( "Could not make HTTP request: allow_url_open is false and cURL not available" ); } if (false === $contents) { throw new Minify_JS_ClosureCompiler_Exception( "No HTTP response from server" ); } return trim($contents); }
php
protected function getResponse($postBody) { $allowUrlFopen = preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen')); if ($allowUrlFopen) { $contents = file_get_contents($this->serviceUrl, false, stream_context_create(array( 'http' => array( 'method' => 'POST', 'compilation_level' => 'SIMPLE', 'output_format' => 'text', 'output_info' => 'compiled_code', 'header' => "Content-type: application/x-www-form-urlencoded\r\nConnection: close\r\n", 'content' => $postBody, 'max_redirects' => 0, 'timeout' => 15, ) ))); } elseif (defined('CURLOPT_POST')) { $ch = curl_init($this->serviceUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded')); curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); $contents = curl_exec($ch); curl_close($ch); } else { throw new Minify_JS_ClosureCompiler_Exception( "Could not make HTTP request: allow_url_open is false and cURL not available" ); } if (false === $contents) { throw new Minify_JS_ClosureCompiler_Exception( "No HTTP response from server" ); } return trim($contents); }
[ "protected", "function", "getResponse", "(", "$", "postBody", ")", "{", "$", "allowUrlFopen", "=", "preg_match", "(", "'/1|yes|on|true/i'", ",", "ini_get", "(", "'allow_url_fopen'", ")", ")", ";", "if", "(", "$", "allowUrlFopen", ")", "{", "$", "contents", "=", "file_get_contents", "(", "$", "this", "->", "serviceUrl", ",", "false", ",", "stream_context_create", "(", "array", "(", "'http'", "=>", "array", "(", "'method'", "=>", "'POST'", ",", "'compilation_level'", "=>", "'SIMPLE'", ",", "'output_format'", "=>", "'text'", ",", "'output_info'", "=>", "'compiled_code'", ",", "'header'", "=>", "\"Content-type: application/x-www-form-urlencoded\\r\\nConnection: close\\r\\n\"", ",", "'content'", "=>", "$", "postBody", ",", "'max_redirects'", "=>", "0", ",", "'timeout'", "=>", "15", ",", ")", ")", ")", ")", ";", "}", "elseif", "(", "defined", "(", "'CURLOPT_POST'", ")", ")", "{", "$", "ch", "=", "curl_init", "(", "$", "this", "->", "serviceUrl", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEADER", ",", "array", "(", "'Content-type: application/x-www-form-urlencoded'", ")", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "postBody", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_FOLLOWLOCATION", ",", "false", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CONNECTTIMEOUT", ",", "15", ")", ";", "$", "contents", "=", "curl_exec", "(", "$", "ch", ")", ";", "curl_close", "(", "$", "ch", ")", ";", "}", "else", "{", "throw", "new", "Minify_JS_ClosureCompiler_Exception", "(", "\"Could not make HTTP request: allow_url_open is false and cURL not available\"", ")", ";", "}", "if", "(", "false", "===", "$", "contents", ")", "{", "throw", "new", "Minify_JS_ClosureCompiler_Exception", "(", "\"No HTTP response from server\"", ")", ";", "}", "return", "trim", "(", "$", "contents", ")", ";", "}" ]
Get the response for a given POST body @param string $postBody @return string @throws Minify_JS_ClosureCompiler_Exception
[ "Get", "the", "response", "for", "a", "given", "POST", "body" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/JS/ClosureCompiler.php#L169-L209
train
mrclay/minify
lib/Minify/JS/ClosureCompiler.php
Minify_JS_ClosureCompiler.buildPostBody
protected function buildPostBody($js, $returnErrors = false) { return http_build_query( array_merge( self::$DEFAULT_OPTIONS, $this->additionalOptions, array( 'js_code' => $js, 'output_info' => ($returnErrors ? 'errors' : 'compiled_code') ) ), null, '&' ); }
php
protected function buildPostBody($js, $returnErrors = false) { return http_build_query( array_merge( self::$DEFAULT_OPTIONS, $this->additionalOptions, array( 'js_code' => $js, 'output_info' => ($returnErrors ? 'errors' : 'compiled_code') ) ), null, '&' ); }
[ "protected", "function", "buildPostBody", "(", "$", "js", ",", "$", "returnErrors", "=", "false", ")", "{", "return", "http_build_query", "(", "array_merge", "(", "self", "::", "$", "DEFAULT_OPTIONS", ",", "$", "this", "->", "additionalOptions", ",", "array", "(", "'js_code'", "=>", "$", "js", ",", "'output_info'", "=>", "(", "$", "returnErrors", "?", "'errors'", ":", "'compiled_code'", ")", ")", ")", ",", "null", ",", "'&'", ")", ";", "}" ]
Build a POST request body @param string $js JavaScript code @param bool $returnErrors @return string
[ "Build", "a", "POST", "request", "body" ]
258e495451c03adf57e1df81c2f0ef0c25b2f40d
https://github.com/mrclay/minify/blob/258e495451c03adf57e1df81c2f0ef0c25b2f40d/lib/Minify/JS/ClosureCompiler.php#L218-L232
train
laravel/dusk
src/Console/ChromeDriverCommand.php
ChromeDriverCommand.extract
protected function extract($archive) { $zip = new ZipArchive; $zip->open($archive); $zip->extractTo($this->directory); $binary = $zip->getNameIndex(0); $zip->close(); unlink($archive); return $binary; }
php
protected function extract($archive) { $zip = new ZipArchive; $zip->open($archive); $zip->extractTo($this->directory); $binary = $zip->getNameIndex(0); $zip->close(); unlink($archive); return $binary; }
[ "protected", "function", "extract", "(", "$", "archive", ")", "{", "$", "zip", "=", "new", "ZipArchive", ";", "$", "zip", "->", "open", "(", "$", "archive", ")", ";", "$", "zip", "->", "extractTo", "(", "$", "this", "->", "directory", ")", ";", "$", "binary", "=", "$", "zip", "->", "getNameIndex", "(", "0", ")", ";", "$", "zip", "->", "close", "(", ")", ";", "unlink", "(", "$", "archive", ")", ";", "return", "$", "binary", ";", "}" ]
Extract the ChromeDriver binary from the archive and delete the archive. @param string $archive @return string
[ "Extract", "the", "ChromeDriver", "binary", "from", "the", "archive", "and", "delete", "the", "archive", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Console/ChromeDriverCommand.php#L197-L212
train
laravel/dusk
src/Console/ChromeDriverCommand.php
ChromeDriverCommand.rename
protected function rename($binary, $os) { $newName = str_replace('chromedriver', 'chromedriver-'.$os, $binary); rename($this->directory.$binary, $this->directory.$newName); chmod($this->directory.$newName, 0755); }
php
protected function rename($binary, $os) { $newName = str_replace('chromedriver', 'chromedriver-'.$os, $binary); rename($this->directory.$binary, $this->directory.$newName); chmod($this->directory.$newName, 0755); }
[ "protected", "function", "rename", "(", "$", "binary", ",", "$", "os", ")", "{", "$", "newName", "=", "str_replace", "(", "'chromedriver'", ",", "'chromedriver-'", ".", "$", "os", ",", "$", "binary", ")", ";", "rename", "(", "$", "this", "->", "directory", ".", "$", "binary", ",", "$", "this", "->", "directory", ".", "$", "newName", ")", ";", "chmod", "(", "$", "this", "->", "directory", ".", "$", "newName", ",", "0755", ")", ";", "}" ]
Rename the ChromeDriver binary and make it executable. @param string $binary @param string $os @return void
[ "Rename", "the", "ChromeDriver", "binary", "and", "make", "it", "executable", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Console/ChromeDriverCommand.php#L221-L228
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.whenAvailable
public function whenAvailable($selector, Closure $callback, $seconds = null) { return $this->waitFor($selector, $seconds)->with($selector, $callback); }
php
public function whenAvailable($selector, Closure $callback, $seconds = null) { return $this->waitFor($selector, $seconds)->with($selector, $callback); }
[ "public", "function", "whenAvailable", "(", "$", "selector", ",", "Closure", "$", "callback", ",", "$", "seconds", "=", "null", ")", "{", "return", "$", "this", "->", "waitFor", "(", "$", "selector", ",", "$", "seconds", ")", "->", "with", "(", "$", "selector", ",", "$", "callback", ")", ";", "}" ]
Execute the given callback in a scoped browser once the selector is available. @param string $selector @param Closure $callback @param int $seconds @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Execute", "the", "given", "callback", "in", "a", "scoped", "browser", "once", "the", "selector", "is", "available", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L25-L28
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitFor
public function waitFor($selector, $seconds = null) { $message = $this->formatTimeOutMessage('Waited %s seconds for selector', $selector); return $this->waitUsing($seconds, 100, function () use ($selector) { return $this->resolver->findOrFail($selector)->isDisplayed(); }, $message); }
php
public function waitFor($selector, $seconds = null) { $message = $this->formatTimeOutMessage('Waited %s seconds for selector', $selector); return $this->waitUsing($seconds, 100, function () use ($selector) { return $this->resolver->findOrFail($selector)->isDisplayed(); }, $message); }
[ "public", "function", "waitFor", "(", "$", "selector", ",", "$", "seconds", "=", "null", ")", "{", "$", "message", "=", "$", "this", "->", "formatTimeOutMessage", "(", "'Waited %s seconds for selector'", ",", "$", "selector", ")", ";", "return", "$", "this", "->", "waitUsing", "(", "$", "seconds", ",", "100", ",", "function", "(", ")", "use", "(", "$", "selector", ")", "{", "return", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", "->", "isDisplayed", "(", ")", ";", "}", ",", "$", "message", ")", ";", "}" ]
Wait for the given selector to be visible. @param string $selector @param int $seconds @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Wait", "for", "the", "given", "selector", "to", "be", "visible", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L38-L45
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitUntilMissing
public function waitUntilMissing($selector, $seconds = null) { $message = $this->formatTimeOutMessage('Waited %s seconds for removal of selector', $selector); return $this->waitUsing($seconds, 100, function () use ($selector) { try { $missing = ! $this->resolver->findOrFail($selector)->isDisplayed(); } catch (NoSuchElementException $e) { $missing = true; } return $missing; }, $message); }
php
public function waitUntilMissing($selector, $seconds = null) { $message = $this->formatTimeOutMessage('Waited %s seconds for removal of selector', $selector); return $this->waitUsing($seconds, 100, function () use ($selector) { try { $missing = ! $this->resolver->findOrFail($selector)->isDisplayed(); } catch (NoSuchElementException $e) { $missing = true; } return $missing; }, $message); }
[ "public", "function", "waitUntilMissing", "(", "$", "selector", ",", "$", "seconds", "=", "null", ")", "{", "$", "message", "=", "$", "this", "->", "formatTimeOutMessage", "(", "'Waited %s seconds for removal of selector'", ",", "$", "selector", ")", ";", "return", "$", "this", "->", "waitUsing", "(", "$", "seconds", ",", "100", ",", "function", "(", ")", "use", "(", "$", "selector", ")", "{", "try", "{", "$", "missing", "=", "!", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", "->", "isDisplayed", "(", ")", ";", "}", "catch", "(", "NoSuchElementException", "$", "e", ")", "{", "$", "missing", "=", "true", ";", "}", "return", "$", "missing", ";", "}", ",", "$", "message", ")", ";", "}" ]
Wait for the given selector to be removed. @param string $selector @param int $seconds @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Wait", "for", "the", "given", "selector", "to", "be", "removed", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L55-L68
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitForText
public function waitForText($text, $seconds = null) { $text = Arr::wrap($text); $message = $this->formatTimeOutMessage('Waited %s seconds for text', implode("', '", $text)); return $this->waitUsing($seconds, 100, function () use ($text) { return Str::contains($this->resolver->findOrFail('')->getText(), $text); }, $message); }
php
public function waitForText($text, $seconds = null) { $text = Arr::wrap($text); $message = $this->formatTimeOutMessage('Waited %s seconds for text', implode("', '", $text)); return $this->waitUsing($seconds, 100, function () use ($text) { return Str::contains($this->resolver->findOrFail('')->getText(), $text); }, $message); }
[ "public", "function", "waitForText", "(", "$", "text", ",", "$", "seconds", "=", "null", ")", "{", "$", "text", "=", "Arr", "::", "wrap", "(", "$", "text", ")", ";", "$", "message", "=", "$", "this", "->", "formatTimeOutMessage", "(", "'Waited %s seconds for text'", ",", "implode", "(", "\"', '\"", ",", "$", "text", ")", ")", ";", "return", "$", "this", "->", "waitUsing", "(", "$", "seconds", ",", "100", ",", "function", "(", ")", "use", "(", "$", "text", ")", "{", "return", "Str", "::", "contains", "(", "$", "this", "->", "resolver", "->", "findOrFail", "(", "''", ")", "->", "getText", "(", ")", ",", "$", "text", ")", ";", "}", ",", "$", "message", ")", ";", "}" ]
Wait for the given text to be visible. @param array|string $text @param int $seconds @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Wait", "for", "the", "given", "text", "to", "be", "visible", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L78-L87
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitForLink
public function waitForLink($link, $seconds = null) { $message = $this->formatTimeOutMessage('Waited %s seconds for link', $link); return $this->waitUsing($seconds, 100, function () use ($link) { return $this->seeLink($link); }, $message); }
php
public function waitForLink($link, $seconds = null) { $message = $this->formatTimeOutMessage('Waited %s seconds for link', $link); return $this->waitUsing($seconds, 100, function () use ($link) { return $this->seeLink($link); }, $message); }
[ "public", "function", "waitForLink", "(", "$", "link", ",", "$", "seconds", "=", "null", ")", "{", "$", "message", "=", "$", "this", "->", "formatTimeOutMessage", "(", "'Waited %s seconds for link'", ",", "$", "link", ")", ";", "return", "$", "this", "->", "waitUsing", "(", "$", "seconds", ",", "100", ",", "function", "(", ")", "use", "(", "$", "link", ")", "{", "return", "$", "this", "->", "seeLink", "(", "$", "link", ")", ";", "}", ",", "$", "message", ")", ";", "}" ]
Wait for the given link to be visible. @param string $link @param int $seconds @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Wait", "for", "the", "given", "link", "to", "be", "visible", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L97-L104
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitForLocation
public function waitForLocation($path, $seconds = null) { $message = $this->formatTimeOutMessage('Waited %s seconds for location', $path); return $this->waitUntil("window.location.pathname == '{$path}'", $seconds, $message); }
php
public function waitForLocation($path, $seconds = null) { $message = $this->formatTimeOutMessage('Waited %s seconds for location', $path); return $this->waitUntil("window.location.pathname == '{$path}'", $seconds, $message); }
[ "public", "function", "waitForLocation", "(", "$", "path", ",", "$", "seconds", "=", "null", ")", "{", "$", "message", "=", "$", "this", "->", "formatTimeOutMessage", "(", "'Waited %s seconds for location'", ",", "$", "path", ")", ";", "return", "$", "this", "->", "waitUntil", "(", "\"window.location.pathname == '{$path}'\"", ",", "$", "seconds", ",", "$", "message", ")", ";", "}" ]
Wait for the given location. @param string $path @param int $seconds @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Wait", "for", "the", "given", "location", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L114-L119
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitForRoute
public function waitForRoute($route, $parameters = [], $seconds = null) { return $this->waitForLocation(route($route, $parameters, false), $seconds); }
php
public function waitForRoute($route, $parameters = [], $seconds = null) { return $this->waitForLocation(route($route, $parameters, false), $seconds); }
[ "public", "function", "waitForRoute", "(", "$", "route", ",", "$", "parameters", "=", "[", "]", ",", "$", "seconds", "=", "null", ")", "{", "return", "$", "this", "->", "waitForLocation", "(", "route", "(", "$", "route", ",", "$", "parameters", ",", "false", ")", ",", "$", "seconds", ")", ";", "}" ]
Wait for the given location using a named route. @param string $route @param array $parameters @param int $seconds @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Wait", "for", "the", "given", "location", "using", "a", "named", "route", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L130-L133
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitUntil
public function waitUntil($script, $seconds = null, $message = null) { if (! Str::startsWith($script, 'return ')) { $script = 'return '.$script; } if (! Str::endsWith($script, ';')) { $script = $script.';'; } return $this->waitUsing($seconds, 100, function () use ($script) { return $this->driver->executeScript($script); }, $message); }
php
public function waitUntil($script, $seconds = null, $message = null) { if (! Str::startsWith($script, 'return ')) { $script = 'return '.$script; } if (! Str::endsWith($script, ';')) { $script = $script.';'; } return $this->waitUsing($seconds, 100, function () use ($script) { return $this->driver->executeScript($script); }, $message); }
[ "public", "function", "waitUntil", "(", "$", "script", ",", "$", "seconds", "=", "null", ",", "$", "message", "=", "null", ")", "{", "if", "(", "!", "Str", "::", "startsWith", "(", "$", "script", ",", "'return '", ")", ")", "{", "$", "script", "=", "'return '", ".", "$", "script", ";", "}", "if", "(", "!", "Str", "::", "endsWith", "(", "$", "script", ",", "';'", ")", ")", "{", "$", "script", "=", "$", "script", ".", "';'", ";", "}", "return", "$", "this", "->", "waitUsing", "(", "$", "seconds", ",", "100", ",", "function", "(", ")", "use", "(", "$", "script", ")", "{", "return", "$", "this", "->", "driver", "->", "executeScript", "(", "$", "script", ")", ";", "}", ",", "$", "message", ")", ";", "}" ]
Wait until the given script returns true. @param string $script @param int $seconds @param string $message @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Wait", "until", "the", "given", "script", "returns", "true", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L144-L157
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitUntilVue
public function waitUntilVue($key, $value, $componentSelector = null, $seconds = null) { $this->waitUsing($seconds, 100, function () use ($key, $value, $componentSelector) { return $value == $this->vueAttribute($componentSelector, $key); }); return $this; }
php
public function waitUntilVue($key, $value, $componentSelector = null, $seconds = null) { $this->waitUsing($seconds, 100, function () use ($key, $value, $componentSelector) { return $value == $this->vueAttribute($componentSelector, $key); }); return $this; }
[ "public", "function", "waitUntilVue", "(", "$", "key", ",", "$", "value", ",", "$", "componentSelector", "=", "null", ",", "$", "seconds", "=", "null", ")", "{", "$", "this", "->", "waitUsing", "(", "$", "seconds", ",", "100", ",", "function", "(", ")", "use", "(", "$", "key", ",", "$", "value", ",", "$", "componentSelector", ")", "{", "return", "$", "value", "==", "$", "this", "->", "vueAttribute", "(", "$", "componentSelector", ",", "$", "key", ")", ";", "}", ")", ";", "return", "$", "this", ";", "}" ]
Wait until the Vue component's attribute at the given key has the given value. @param string $key @param string $value @param string|null $componentSelector @return $this
[ "Wait", "until", "the", "Vue", "component", "s", "attribute", "at", "the", "given", "key", "has", "the", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L167-L174
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitForDialog
public function waitForDialog($seconds = null) { $seconds = is_null($seconds) ? static::$waitSeconds : $seconds; $this->driver->wait($seconds, 100)->until( WebDriverExpectedCondition::alertIsPresent(), "Waited {$seconds} seconds for dialog." ); return $this; }
php
public function waitForDialog($seconds = null) { $seconds = is_null($seconds) ? static::$waitSeconds : $seconds; $this->driver->wait($seconds, 100)->until( WebDriverExpectedCondition::alertIsPresent(), "Waited {$seconds} seconds for dialog." ); return $this; }
[ "public", "function", "waitForDialog", "(", "$", "seconds", "=", "null", ")", "{", "$", "seconds", "=", "is_null", "(", "$", "seconds", ")", "?", "static", "::", "$", "waitSeconds", ":", "$", "seconds", ";", "$", "this", "->", "driver", "->", "wait", "(", "$", "seconds", ",", "100", ")", "->", "until", "(", "WebDriverExpectedCondition", "::", "alertIsPresent", "(", ")", ",", "\"Waited {$seconds} seconds for dialog.\"", ")", ";", "return", "$", "this", ";", "}" ]
Wait for a JavaScript dialog to open. @param int $seconds @return $this
[ "Wait", "for", "a", "JavaScript", "dialog", "to", "open", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L199-L208
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitForReload
public function waitForReload($callback = null, $seconds = null) { $token = Str::random(); $this->driver->executeScript("window['{$token}'] = {};"); if ($callback) { $callback($this); } return $this->waitUsing($seconds, 100, function () use ($token) { return $this->driver->executeScript("return typeof window['{$token}'] === 'undefined';"); }, 'Waited %s seconds for page reload.'); }
php
public function waitForReload($callback = null, $seconds = null) { $token = Str::random(); $this->driver->executeScript("window['{$token}'] = {};"); if ($callback) { $callback($this); } return $this->waitUsing($seconds, 100, function () use ($token) { return $this->driver->executeScript("return typeof window['{$token}'] === 'undefined';"); }, 'Waited %s seconds for page reload.'); }
[ "public", "function", "waitForReload", "(", "$", "callback", "=", "null", ",", "$", "seconds", "=", "null", ")", "{", "$", "token", "=", "Str", "::", "random", "(", ")", ";", "$", "this", "->", "driver", "->", "executeScript", "(", "\"window['{$token}'] = {};\"", ")", ";", "if", "(", "$", "callback", ")", "{", "$", "callback", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "waitUsing", "(", "$", "seconds", ",", "100", ",", "function", "(", ")", "use", "(", "$", "token", ")", "{", "return", "$", "this", "->", "driver", "->", "executeScript", "(", "\"return typeof window['{$token}'] === 'undefined';\"", ")", ";", "}", ",", "'Waited %s seconds for page reload.'", ")", ";", "}" ]
Wait for the current page to reload. @param Closure $callback @param int $seconds @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Wait", "for", "the", "current", "page", "to", "reload", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L218-L231
train
laravel/dusk
src/Concerns/WaitsForElements.php
WaitsForElements.waitUsing
public function waitUsing($seconds, $interval, Closure $callback, $message = null) { $seconds = is_null($seconds) ? static::$waitSeconds : $seconds; $this->pause($interval); $started = Carbon::now(); while (true) { try { if ($callback()) { break; } } catch (Exception $e) { // } if ($started->lt(Carbon::now()->subSeconds($seconds))) { throw new TimeOutException($message ? sprintf($message, $seconds) : "Waited {$seconds} seconds for callback." ); } $this->pause($interval); } return $this; }
php
public function waitUsing($seconds, $interval, Closure $callback, $message = null) { $seconds = is_null($seconds) ? static::$waitSeconds : $seconds; $this->pause($interval); $started = Carbon::now(); while (true) { try { if ($callback()) { break; } } catch (Exception $e) { // } if ($started->lt(Carbon::now()->subSeconds($seconds))) { throw new TimeOutException($message ? sprintf($message, $seconds) : "Waited {$seconds} seconds for callback." ); } $this->pause($interval); } return $this; }
[ "public", "function", "waitUsing", "(", "$", "seconds", ",", "$", "interval", ",", "Closure", "$", "callback", ",", "$", "message", "=", "null", ")", "{", "$", "seconds", "=", "is_null", "(", "$", "seconds", ")", "?", "static", "::", "$", "waitSeconds", ":", "$", "seconds", ";", "$", "this", "->", "pause", "(", "$", "interval", ")", ";", "$", "started", "=", "Carbon", "::", "now", "(", ")", ";", "while", "(", "true", ")", "{", "try", "{", "if", "(", "$", "callback", "(", ")", ")", "{", "break", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "//", "}", "if", "(", "$", "started", "->", "lt", "(", "Carbon", "::", "now", "(", ")", "->", "subSeconds", "(", "$", "seconds", ")", ")", ")", "{", "throw", "new", "TimeOutException", "(", "$", "message", "?", "sprintf", "(", "$", "message", ",", "$", "seconds", ")", ":", "\"Waited {$seconds} seconds for callback.\"", ")", ";", "}", "$", "this", "->", "pause", "(", "$", "interval", ")", ";", "}", "return", "$", "this", ";", "}" ]
Wait for the given callback to be true. @param int $seconds @param int $interval @param Closure $callback @param string|null $message @return $this @throws \Facebook\WebDriver\Exception\TimeOutException
[ "Wait", "for", "the", "given", "callback", "to", "be", "true", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/WaitsForElements.php#L243-L271
train
laravel/dusk
src/Concerns/InteractsWithAuthentication.php
InteractsWithAuthentication.loginAs
public function loginAs($userId, $guard = null) { $userId = method_exists($userId, 'getKey') ? $userId->getKey() : $userId; return $this->visit(rtrim('/_dusk/login/'.$userId.'/'.$guard, '/')); }
php
public function loginAs($userId, $guard = null) { $userId = method_exists($userId, 'getKey') ? $userId->getKey() : $userId; return $this->visit(rtrim('/_dusk/login/'.$userId.'/'.$guard, '/')); }
[ "public", "function", "loginAs", "(", "$", "userId", ",", "$", "guard", "=", "null", ")", "{", "$", "userId", "=", "method_exists", "(", "$", "userId", ",", "'getKey'", ")", "?", "$", "userId", "->", "getKey", "(", ")", ":", "$", "userId", ";", "return", "$", "this", "->", "visit", "(", "rtrim", "(", "'/_dusk/login/'", ".", "$", "userId", ".", "'/'", ".", "$", "guard", ",", "'/'", ")", ")", ";", "}" ]
Log into the application using a given user ID or email. @param object|string $userId @param string $guard @return $this
[ "Log", "into", "the", "application", "using", "a", "given", "user", "ID", "or", "email", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithAuthentication.php#L27-L32
train
laravel/dusk
src/Dusk.php
Dusk.duskEnvironment
protected static function duskEnvironment($options) { if (! isset($options['environments'])) { return false; } if (is_string($options['environments'])) { $options['environments'] = [$options['environments']]; } if (! is_array($options['environments'])) { throw new InvalidArgumentException('Dusk environments must be listed as an array.'); } return app()->environment(...$options['environments']); }
php
protected static function duskEnvironment($options) { if (! isset($options['environments'])) { return false; } if (is_string($options['environments'])) { $options['environments'] = [$options['environments']]; } if (! is_array($options['environments'])) { throw new InvalidArgumentException('Dusk environments must be listed as an array.'); } return app()->environment(...$options['environments']); }
[ "protected", "static", "function", "duskEnvironment", "(", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'environments'", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "is_string", "(", "$", "options", "[", "'environments'", "]", ")", ")", "{", "$", "options", "[", "'environments'", "]", "=", "[", "$", "options", "[", "'environments'", "]", "]", ";", "}", "if", "(", "!", "is_array", "(", "$", "options", "[", "'environments'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Dusk environments must be listed as an array.'", ")", ";", "}", "return", "app", "(", ")", "->", "environment", "(", "...", "$", "options", "[", "'environments'", "]", ")", ";", "}" ]
Determine if Dusk may run in this environment. @param array $options @return bool
[ "Determine", "if", "Dusk", "may", "run", "in", "this", "environment", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Dusk.php#L28-L43
train
laravel/dusk
src/Concerns/InteractsWithMouse.php
InteractsWithMouse.moveMouse
public function moveMouse($xOffset, $yOffset) { (new WebDriverActions($this->driver))->moveByOffset( $xOffset, $yOffset )->perform(); return $this; }
php
public function moveMouse($xOffset, $yOffset) { (new WebDriverActions($this->driver))->moveByOffset( $xOffset, $yOffset )->perform(); return $this; }
[ "public", "function", "moveMouse", "(", "$", "xOffset", ",", "$", "yOffset", ")", "{", "(", "new", "WebDriverActions", "(", "$", "this", "->", "driver", ")", ")", "->", "moveByOffset", "(", "$", "xOffset", ",", "$", "yOffset", ")", "->", "perform", "(", ")", ";", "return", "$", "this", ";", "}" ]
Move the mouse by offset X and Y. @param int $xOffset @param int $yOffset @return $this
[ "Move", "the", "mouse", "by", "offset", "X", "and", "Y", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithMouse.php#L16-L23
train
laravel/dusk
src/Concerns/InteractsWithMouse.php
InteractsWithMouse.mouseover
public function mouseover($selector) { $element = $this->resolver->findOrFail($selector); $this->driver->getMouse()->mouseMove($element->getCoordinates()); return $this; }
php
public function mouseover($selector) { $element = $this->resolver->findOrFail($selector); $this->driver->getMouse()->mouseMove($element->getCoordinates()); return $this; }
[ "public", "function", "mouseover", "(", "$", "selector", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", ";", "$", "this", "->", "driver", "->", "getMouse", "(", ")", "->", "mouseMove", "(", "$", "element", "->", "getCoordinates", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Move the mouse over the given selector. @param string $selector @return $this
[ "Move", "the", "mouse", "over", "the", "given", "selector", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithMouse.php#L31-L38
train
laravel/dusk
src/Concerns/InteractsWithMouse.php
InteractsWithMouse.click
public function click($selector = null) { if (is_null($selector)) { (new WebDriverActions($this->driver))->click()->perform(); } else { $this->resolver->findOrFail($selector)->click(); } return $this; }
php
public function click($selector = null) { if (is_null($selector)) { (new WebDriverActions($this->driver))->click()->perform(); } else { $this->resolver->findOrFail($selector)->click(); } return $this; }
[ "public", "function", "click", "(", "$", "selector", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "selector", ")", ")", "{", "(", "new", "WebDriverActions", "(", "$", "this", "->", "driver", ")", ")", "->", "click", "(", ")", "->", "perform", "(", ")", ";", "}", "else", "{", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", "->", "click", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Click the element at the given selector. @param string|null $selector @return $this
[ "Click", "the", "element", "at", "the", "given", "selector", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithMouse.php#L46-L55
train
laravel/dusk
src/Concerns/InteractsWithMouse.php
InteractsWithMouse.rightClick
public function rightClick($selector = null) { if (is_null($selector)) { (new WebDriverActions($this->driver))->contextClick()->perform(); } else { (new WebDriverActions($this->driver))->contextClick( $this->resolver->findOrFail($selector) )->perform(); } return $this; }
php
public function rightClick($selector = null) { if (is_null($selector)) { (new WebDriverActions($this->driver))->contextClick()->perform(); } else { (new WebDriverActions($this->driver))->contextClick( $this->resolver->findOrFail($selector) )->perform(); } return $this; }
[ "public", "function", "rightClick", "(", "$", "selector", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "selector", ")", ")", "{", "(", "new", "WebDriverActions", "(", "$", "this", "->", "driver", ")", ")", "->", "contextClick", "(", ")", "->", "perform", "(", ")", ";", "}", "else", "{", "(", "new", "WebDriverActions", "(", "$", "this", "->", "driver", ")", ")", "->", "contextClick", "(", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", ")", "->", "perform", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Right click the element at the given selector. @param string|null $selector @return $this
[ "Right", "click", "the", "element", "at", "the", "given", "selector", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithMouse.php#L87-L98
train
laravel/dusk
src/Concerns/ProvidesBrowser.php
ProvidesBrowser.browse
public function browse(Closure $callback) { $browsers = $this->createBrowsersFor($callback); try { $callback(...$browsers->all()); } catch (Exception $e) { $this->captureFailuresFor($browsers); throw $e; } catch (Throwable $e) { $this->captureFailuresFor($browsers); throw $e; } finally { $this->storeConsoleLogsFor($browsers); static::$browsers = $this->closeAllButPrimary($browsers); } }
php
public function browse(Closure $callback) { $browsers = $this->createBrowsersFor($callback); try { $callback(...$browsers->all()); } catch (Exception $e) { $this->captureFailuresFor($browsers); throw $e; } catch (Throwable $e) { $this->captureFailuresFor($browsers); throw $e; } finally { $this->storeConsoleLogsFor($browsers); static::$browsers = $this->closeAllButPrimary($browsers); } }
[ "public", "function", "browse", "(", "Closure", "$", "callback", ")", "{", "$", "browsers", "=", "$", "this", "->", "createBrowsersFor", "(", "$", "callback", ")", ";", "try", "{", "$", "callback", "(", "...", "$", "browsers", "->", "all", "(", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "captureFailuresFor", "(", "$", "browsers", ")", ";", "throw", "$", "e", ";", "}", "catch", "(", "Throwable", "$", "e", ")", "{", "$", "this", "->", "captureFailuresFor", "(", "$", "browsers", ")", ";", "throw", "$", "e", ";", "}", "finally", "{", "$", "this", "->", "storeConsoleLogsFor", "(", "$", "browsers", ")", ";", "static", "::", "$", "browsers", "=", "$", "this", "->", "closeAllButPrimary", "(", "$", "browsers", ")", ";", "}", "}" ]
Create a new browser instance. @param \Closure $callback @return \Laravel\Dusk\Browser|void @throws \Exception @throws \Throwable
[ "Create", "a", "new", "browser", "instance", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/ProvidesBrowser.php#L62-L81
train
laravel/dusk
src/Concerns/ProvidesBrowser.php
ProvidesBrowser.createBrowsersFor
protected function createBrowsersFor(Closure $callback) { if (count(static::$browsers) === 0) { static::$browsers = collect([$this->newBrowser($this->createWebDriver())]); } $additional = $this->browsersNeededFor($callback) - 1; for ($i = 0; $i < $additional; $i++) { static::$browsers->push($this->newBrowser($this->createWebDriver())); } return static::$browsers; }
php
protected function createBrowsersFor(Closure $callback) { if (count(static::$browsers) === 0) { static::$browsers = collect([$this->newBrowser($this->createWebDriver())]); } $additional = $this->browsersNeededFor($callback) - 1; for ($i = 0; $i < $additional; $i++) { static::$browsers->push($this->newBrowser($this->createWebDriver())); } return static::$browsers; }
[ "protected", "function", "createBrowsersFor", "(", "Closure", "$", "callback", ")", "{", "if", "(", "count", "(", "static", "::", "$", "browsers", ")", "===", "0", ")", "{", "static", "::", "$", "browsers", "=", "collect", "(", "[", "$", "this", "->", "newBrowser", "(", "$", "this", "->", "createWebDriver", "(", ")", ")", "]", ")", ";", "}", "$", "additional", "=", "$", "this", "->", "browsersNeededFor", "(", "$", "callback", ")", "-", "1", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "additional", ";", "$", "i", "++", ")", "{", "static", "::", "$", "browsers", "->", "push", "(", "$", "this", "->", "newBrowser", "(", "$", "this", "->", "createWebDriver", "(", ")", ")", ")", ";", "}", "return", "static", "::", "$", "browsers", ";", "}" ]
Create the browser instances needed for the given callback. @param \Closure $callback @return array @throws \ReflectionException
[ "Create", "the", "browser", "instances", "needed", "for", "the", "given", "callback", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/ProvidesBrowser.php#L90-L103
train
laravel/dusk
src/Concerns/ProvidesBrowser.php
ProvidesBrowser.captureFailuresFor
protected function captureFailuresFor($browsers) { $browsers->each(function ($browser, $key) { $name = str_replace('\\', '_', get_class($this)).'_'.$this->getName(false); $browser->screenshot('failure-'.$name.'-'.$key); }); }
php
protected function captureFailuresFor($browsers) { $browsers->each(function ($browser, $key) { $name = str_replace('\\', '_', get_class($this)).'_'.$this->getName(false); $browser->screenshot('failure-'.$name.'-'.$key); }); }
[ "protected", "function", "captureFailuresFor", "(", "$", "browsers", ")", "{", "$", "browsers", "->", "each", "(", "function", "(", "$", "browser", ",", "$", "key", ")", "{", "$", "name", "=", "str_replace", "(", "'\\\\'", ",", "'_'", ",", "get_class", "(", "$", "this", ")", ")", ".", "'_'", ".", "$", "this", "->", "getName", "(", "false", ")", ";", "$", "browser", "->", "screenshot", "(", "'failure-'", ".", "$", "name", ".", "'-'", ".", "$", "key", ")", ";", "}", ")", ";", "}" ]
Capture failure screenshots for each browser. @param \Illuminate\Support\Collection $browsers @return void
[ "Capture", "failure", "screenshots", "for", "each", "browser", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/ProvidesBrowser.php#L134-L141
train
laravel/dusk
src/Concerns/ProvidesBrowser.php
ProvidesBrowser.storeConsoleLogsFor
protected function storeConsoleLogsFor($browsers) { $browsers->each(function ($browser, $key) { $name = str_replace('\\', '_', get_class($this)).'_'.$this->getName(false); $browser->storeConsoleLog($name.'-'.$key); }); }
php
protected function storeConsoleLogsFor($browsers) { $browsers->each(function ($browser, $key) { $name = str_replace('\\', '_', get_class($this)).'_'.$this->getName(false); $browser->storeConsoleLog($name.'-'.$key); }); }
[ "protected", "function", "storeConsoleLogsFor", "(", "$", "browsers", ")", "{", "$", "browsers", "->", "each", "(", "function", "(", "$", "browser", ",", "$", "key", ")", "{", "$", "name", "=", "str_replace", "(", "'\\\\'", ",", "'_'", ",", "get_class", "(", "$", "this", ")", ")", ".", "'_'", ".", "$", "this", "->", "getName", "(", "false", ")", ";", "$", "browser", "->", "storeConsoleLog", "(", "$", "name", ".", "'-'", ".", "$", "key", ")", ";", "}", ")", ";", "}" ]
Store the console output for the given browsers. @param \Illuminate\Support\Collection $browsers @return void
[ "Store", "the", "console", "output", "for", "the", "given", "browsers", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/ProvidesBrowser.php#L149-L156
train
laravel/dusk
src/Chrome/ChromeProcess.php
ChromeProcess.toProcess
public function toProcess(array $arguments = []) { if ($this->driver) { return $this->process($arguments); } if ($this->onWindows()) { $this->driver = realpath(__DIR__.'/../../bin/chromedriver-win.exe'); } elseif ($this->onMac()) { $this->driver = realpath(__DIR__.'/../../bin/chromedriver-mac'); } else { $this->driver = realpath(__DIR__.'/../../bin/chromedriver-linux'); } return $this->process($arguments); }
php
public function toProcess(array $arguments = []) { if ($this->driver) { return $this->process($arguments); } if ($this->onWindows()) { $this->driver = realpath(__DIR__.'/../../bin/chromedriver-win.exe'); } elseif ($this->onMac()) { $this->driver = realpath(__DIR__.'/../../bin/chromedriver-mac'); } else { $this->driver = realpath(__DIR__.'/../../bin/chromedriver-linux'); } return $this->process($arguments); }
[ "public", "function", "toProcess", "(", "array", "$", "arguments", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "driver", ")", "{", "return", "$", "this", "->", "process", "(", "$", "arguments", ")", ";", "}", "if", "(", "$", "this", "->", "onWindows", "(", ")", ")", "{", "$", "this", "->", "driver", "=", "realpath", "(", "__DIR__", ".", "'/../../bin/chromedriver-win.exe'", ")", ";", "}", "elseif", "(", "$", "this", "->", "onMac", "(", ")", ")", "{", "$", "this", "->", "driver", "=", "realpath", "(", "__DIR__", ".", "'/../../bin/chromedriver-mac'", ")", ";", "}", "else", "{", "$", "this", "->", "driver", "=", "realpath", "(", "__DIR__", ".", "'/../../bin/chromedriver-linux'", ")", ";", "}", "return", "$", "this", "->", "process", "(", "$", "arguments", ")", ";", "}" ]
Build the process to run Chromedriver. @param array $arguments @return \Symfony\Component\Process\Process
[ "Build", "the", "process", "to", "run", "Chromedriver", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Chrome/ChromeProcess.php#L39-L54
train
laravel/dusk
src/Chrome/ChromeProcess.php
ChromeProcess.process
protected function process(array $arguments = []) { return new Process( array_merge([realpath($this->driver)], $arguments), null, $this->chromeEnvironment() ); }
php
protected function process(array $arguments = []) { return new Process( array_merge([realpath($this->driver)], $arguments), null, $this->chromeEnvironment() ); }
[ "protected", "function", "process", "(", "array", "$", "arguments", "=", "[", "]", ")", "{", "return", "new", "Process", "(", "array_merge", "(", "[", "realpath", "(", "$", "this", "->", "driver", ")", "]", ",", "$", "arguments", ")", ",", "null", ",", "$", "this", "->", "chromeEnvironment", "(", ")", ")", ";", "}" ]
Build the Chromedriver with Symfony Process. @param array $arguments @return \Symfony\Component\Process\Process
[ "Build", "the", "Chromedriver", "with", "Symfony", "Process", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Chrome/ChromeProcess.php#L62-L67
train
laravel/dusk
src/Console/DuskCommand.php
DuskCommand.phpunitArguments
protected function phpunitArguments($options) { $options = array_values(array_filter($options, function ($option) { return ! Str::startsWith($option, '--env='); })); if (! file_exists($file = base_path('phpunit.dusk.xml'))) { $file = base_path('phpunit.dusk.xml.dist'); } return array_merge(['-c', $file], $options); }
php
protected function phpunitArguments($options) { $options = array_values(array_filter($options, function ($option) { return ! Str::startsWith($option, '--env='); })); if (! file_exists($file = base_path('phpunit.dusk.xml'))) { $file = base_path('phpunit.dusk.xml.dist'); } return array_merge(['-c', $file], $options); }
[ "protected", "function", "phpunitArguments", "(", "$", "options", ")", "{", "$", "options", "=", "array_values", "(", "array_filter", "(", "$", "options", ",", "function", "(", "$", "option", ")", "{", "return", "!", "Str", "::", "startsWith", "(", "$", "option", ",", "'--env='", ")", ";", "}", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", "=", "base_path", "(", "'phpunit.dusk.xml'", ")", ")", ")", "{", "$", "file", "=", "base_path", "(", "'phpunit.dusk.xml.dist'", ")", ";", "}", "return", "array_merge", "(", "[", "'-c'", ",", "$", "file", "]", ",", "$", "options", ")", ";", "}" ]
Get the array of arguments for running PHPUnit. @param array $options @return array
[ "Get", "the", "array", "of", "arguments", "for", "running", "PHPUnit", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Console/DuskCommand.php#L97-L108
train
laravel/dusk
src/Console/DuskCommand.php
DuskCommand.purgeScreenshots
protected function purgeScreenshots() { $path = base_path('tests/Browser/screenshots'); if (! is_dir($path)) { return; } $files = Finder::create()->files() ->in($path) ->name('failure-*'); foreach ($files as $file) { @unlink($file->getRealPath()); } }
php
protected function purgeScreenshots() { $path = base_path('tests/Browser/screenshots'); if (! is_dir($path)) { return; } $files = Finder::create()->files() ->in($path) ->name('failure-*'); foreach ($files as $file) { @unlink($file->getRealPath()); } }
[ "protected", "function", "purgeScreenshots", "(", ")", "{", "$", "path", "=", "base_path", "(", "'tests/Browser/screenshots'", ")", ";", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "return", ";", "}", "$", "files", "=", "Finder", "::", "create", "(", ")", "->", "files", "(", ")", "->", "in", "(", "$", "path", ")", "->", "name", "(", "'failure-*'", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "@", "unlink", "(", "$", "file", "->", "getRealPath", "(", ")", ")", ";", "}", "}" ]
Purge the failure screenshots. @return void
[ "Purge", "the", "failure", "screenshots", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Console/DuskCommand.php#L115-L130
train
laravel/dusk
src/Console/DuskCommand.php
DuskCommand.withDuskEnvironment
protected function withDuskEnvironment($callback) { if (file_exists(base_path($this->duskFile()))) { if (file_get_contents(base_path('.env')) !== file_get_contents(base_path($this->duskFile()))) { $this->backupEnvironment(); } $this->refreshEnvironment(); } $this->writeConfiguration(); return tap($callback(), function () { $this->removeConfiguration(); if (file_exists(base_path($this->duskFile())) && file_exists(base_path('.env.backup'))) { $this->restoreEnvironment(); } }); }
php
protected function withDuskEnvironment($callback) { if (file_exists(base_path($this->duskFile()))) { if (file_get_contents(base_path('.env')) !== file_get_contents(base_path($this->duskFile()))) { $this->backupEnvironment(); } $this->refreshEnvironment(); } $this->writeConfiguration(); return tap($callback(), function () { $this->removeConfiguration(); if (file_exists(base_path($this->duskFile())) && file_exists(base_path('.env.backup'))) { $this->restoreEnvironment(); } }); }
[ "protected", "function", "withDuskEnvironment", "(", "$", "callback", ")", "{", "if", "(", "file_exists", "(", "base_path", "(", "$", "this", "->", "duskFile", "(", ")", ")", ")", ")", "{", "if", "(", "file_get_contents", "(", "base_path", "(", "'.env'", ")", ")", "!==", "file_get_contents", "(", "base_path", "(", "$", "this", "->", "duskFile", "(", ")", ")", ")", ")", "{", "$", "this", "->", "backupEnvironment", "(", ")", ";", "}", "$", "this", "->", "refreshEnvironment", "(", ")", ";", "}", "$", "this", "->", "writeConfiguration", "(", ")", ";", "return", "tap", "(", "$", "callback", "(", ")", ",", "function", "(", ")", "{", "$", "this", "->", "removeConfiguration", "(", ")", ";", "if", "(", "file_exists", "(", "base_path", "(", "$", "this", "->", "duskFile", "(", ")", ")", ")", "&&", "file_exists", "(", "base_path", "(", "'.env.backup'", ")", ")", ")", "{", "$", "this", "->", "restoreEnvironment", "(", ")", ";", "}", "}", ")", ";", "}" ]
Run the given callback with the Dusk configuration files. @param \Closure $callback @return mixed
[ "Run", "the", "given", "callback", "with", "the", "Dusk", "configuration", "files", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Console/DuskCommand.php#L160-L179
train
laravel/dusk
src/Console/DuskCommand.php
DuskCommand.refreshEnvironment
protected function refreshEnvironment() { // BC fix to support Dotenv ^2.2 if (! method_exists(Dotenv::class, 'create')) { (new Dotenv(base_path()))->overload(); return; } Dotenv::create(base_path())->overload(); }
php
protected function refreshEnvironment() { // BC fix to support Dotenv ^2.2 if (! method_exists(Dotenv::class, 'create')) { (new Dotenv(base_path()))->overload(); return; } Dotenv::create(base_path())->overload(); }
[ "protected", "function", "refreshEnvironment", "(", ")", "{", "// BC fix to support Dotenv ^2.2", "if", "(", "!", "method_exists", "(", "Dotenv", "::", "class", ",", "'create'", ")", ")", "{", "(", "new", "Dotenv", "(", "base_path", "(", ")", ")", ")", "->", "overload", "(", ")", ";", "return", ";", "}", "Dotenv", "::", "create", "(", "base_path", "(", ")", ")", "->", "overload", "(", ")", ";", "}" ]
Refresh the current environment variables. @return void
[ "Refresh", "the", "current", "environment", "variables", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Console/DuskCommand.php#L210-L220
train
laravel/dusk
src/Console/DuskCommand.php
DuskCommand.writeConfiguration
protected function writeConfiguration() { if (! file_exists($file = base_path('phpunit.dusk.xml')) && ! file_exists(base_path('phpunit.dusk.xml.dist'))) { copy(realpath(__DIR__.'/../../stubs/phpunit.xml'), $file); return; } $this->hasPhpUnitConfiguration = true; }
php
protected function writeConfiguration() { if (! file_exists($file = base_path('phpunit.dusk.xml')) && ! file_exists(base_path('phpunit.dusk.xml.dist'))) { copy(realpath(__DIR__.'/../../stubs/phpunit.xml'), $file); return; } $this->hasPhpUnitConfiguration = true; }
[ "protected", "function", "writeConfiguration", "(", ")", "{", "if", "(", "!", "file_exists", "(", "$", "file", "=", "base_path", "(", "'phpunit.dusk.xml'", ")", ")", "&&", "!", "file_exists", "(", "base_path", "(", "'phpunit.dusk.xml.dist'", ")", ")", ")", "{", "copy", "(", "realpath", "(", "__DIR__", ".", "'/../../stubs/phpunit.xml'", ")", ",", "$", "file", ")", ";", "return", ";", "}", "$", "this", "->", "hasPhpUnitConfiguration", "=", "true", ";", "}" ]
Write the Dusk PHPUnit configuration. @return void
[ "Write", "the", "Dusk", "PHPUnit", "configuration", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Console/DuskCommand.php#L227-L237
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertTitleContains
public function assertTitleContains($title) { PHPUnit::assertTrue( Str::contains($this->driver->getTitle(), $title), "Did not see expected value [{$title}] within title [{$this->driver->getTitle()}]." ); return $this; }
php
public function assertTitleContains($title) { PHPUnit::assertTrue( Str::contains($this->driver->getTitle(), $title), "Did not see expected value [{$title}] within title [{$this->driver->getTitle()}]." ); return $this; }
[ "public", "function", "assertTitleContains", "(", "$", "title", ")", "{", "PHPUnit", "::", "assertTrue", "(", "Str", "::", "contains", "(", "$", "this", "->", "driver", "->", "getTitle", "(", ")", ",", "$", "title", ")", ",", "\"Did not see expected value [{$title}] within title [{$this->driver->getTitle()}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the page title contains the given value. @param string $title @return $this
[ "Assert", "that", "the", "page", "title", "contains", "the", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L34-L42
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertHasCookie
public function assertHasCookie($name, $decrypt = true) { $cookie = $decrypt ? $this->cookie($name) : $this->plainCookie($name); PHPUnit::assertTrue( ! is_null($cookie), "Did not find expected cookie [{$name}]." ); return $this; }
php
public function assertHasCookie($name, $decrypt = true) { $cookie = $decrypt ? $this->cookie($name) : $this->plainCookie($name); PHPUnit::assertTrue( ! is_null($cookie), "Did not find expected cookie [{$name}]." ); return $this; }
[ "public", "function", "assertHasCookie", "(", "$", "name", ",", "$", "decrypt", "=", "true", ")", "{", "$", "cookie", "=", "$", "decrypt", "?", "$", "this", "->", "cookie", "(", "$", "name", ")", ":", "$", "this", "->", "plainCookie", "(", "$", "name", ")", ";", "PHPUnit", "::", "assertTrue", "(", "!", "is_null", "(", "$", "cookie", ")", ",", "\"Did not find expected cookie [{$name}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given cookie is present. @param string $name @param bool $decrypt @return $this
[ "Assert", "that", "the", "given", "cookie", "is", "present", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L51-L61
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertCookieValue
public function assertCookieValue($name, $value, $decrypt = true) { $actual = $decrypt ? $this->cookie($name) : $this->plainCookie($name); PHPUnit::assertEquals( $value, $actual, "Cookie [{$name}] had value [{$actual}], but expected [{$value}]." ); return $this; }
php
public function assertCookieValue($name, $value, $decrypt = true) { $actual = $decrypt ? $this->cookie($name) : $this->plainCookie($name); PHPUnit::assertEquals( $value, $actual, "Cookie [{$name}] had value [{$actual}], but expected [{$value}]." ); return $this; }
[ "public", "function", "assertCookieValue", "(", "$", "name", ",", "$", "value", ",", "$", "decrypt", "=", "true", ")", "{", "$", "actual", "=", "$", "decrypt", "?", "$", "this", "->", "cookie", "(", "$", "name", ")", ":", "$", "this", "->", "plainCookie", "(", "$", "name", ")", ";", "PHPUnit", "::", "assertEquals", "(", "$", "value", ",", "$", "actual", ",", "\"Cookie [{$name}] had value [{$actual}], but expected [{$value}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that an encrypted cookie has a given value. @param string $name @param string $value @param bool $decrypt @return $this
[ "Assert", "that", "an", "encrypted", "cookie", "has", "a", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L112-L122
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertSeeIn
public function assertSeeIn($selector, $text) { $fullSelector = $this->resolver->format($selector); $element = $this->resolver->findOrFail($selector); PHPUnit::assertTrue( Str::contains($element->getText(), $text), "Did not see expected text [{$text}] within element [{$fullSelector}]." ); return $this; }
php
public function assertSeeIn($selector, $text) { $fullSelector = $this->resolver->format($selector); $element = $this->resolver->findOrFail($selector); PHPUnit::assertTrue( Str::contains($element->getText(), $text), "Did not see expected text [{$text}] within element [{$fullSelector}]." ); return $this; }
[ "public", "function", "assertSeeIn", "(", "$", "selector", ",", "$", "text", ")", "{", "$", "fullSelector", "=", "$", "this", "->", "resolver", "->", "format", "(", "$", "selector", ")", ";", "$", "element", "=", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", ";", "PHPUnit", "::", "assertTrue", "(", "Str", "::", "contains", "(", "$", "element", "->", "getText", "(", ")", ",", "$", "text", ")", ",", "\"Did not see expected text [{$text}] within element [{$fullSelector}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given text appears within the given selector. @param string $selector @param string $text @return $this
[ "Assert", "that", "the", "given", "text", "appears", "within", "the", "given", "selector", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L165-L177
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertDontSeeIn
public function assertDontSeeIn($selector, $text) { $fullSelector = $this->resolver->format($selector); $element = $this->resolver->findOrFail($selector); PHPUnit::assertFalse( Str::contains($element->getText(), $text), "Saw unexpected text [{$text}] within element [{$fullSelector}]." ); return $this; }
php
public function assertDontSeeIn($selector, $text) { $fullSelector = $this->resolver->format($selector); $element = $this->resolver->findOrFail($selector); PHPUnit::assertFalse( Str::contains($element->getText(), $text), "Saw unexpected text [{$text}] within element [{$fullSelector}]." ); return $this; }
[ "public", "function", "assertDontSeeIn", "(", "$", "selector", ",", "$", "text", ")", "{", "$", "fullSelector", "=", "$", "this", "->", "resolver", "->", "format", "(", "$", "selector", ")", ";", "$", "element", "=", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", ";", "PHPUnit", "::", "assertFalse", "(", "Str", "::", "contains", "(", "$", "element", "->", "getText", "(", ")", ",", "$", "text", ")", ",", "\"Saw unexpected text [{$text}] within element [{$fullSelector}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given text does not appear within the given selector. @param string $selector @param string $text @return $this
[ "Assert", "that", "the", "given", "text", "does", "not", "appear", "within", "the", "given", "selector", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L186-L198
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertSourceHas
public function assertSourceHas($code) { PHPUnit::assertTrue( Str::contains($this->driver->getPageSource(), $code), "Did not find expected source code [{$code}]" ); return $this; }
php
public function assertSourceHas($code) { PHPUnit::assertTrue( Str::contains($this->driver->getPageSource(), $code), "Did not find expected source code [{$code}]" ); return $this; }
[ "public", "function", "assertSourceHas", "(", "$", "code", ")", "{", "PHPUnit", "::", "assertTrue", "(", "Str", "::", "contains", "(", "$", "this", "->", "driver", "->", "getPageSource", "(", ")", ",", "$", "code", ")", ",", "\"Did not find expected source code [{$code}]\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given source code is present on the page. @param string $code @return $this
[ "Assert", "that", "the", "given", "source", "code", "is", "present", "on", "the", "page", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L206-L214
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertSourceMissing
public function assertSourceMissing($code) { PHPUnit::assertFalse( Str::contains($this->driver->getPageSource(), $code), "Found unexpected source code [{$code}]" ); return $this; }
php
public function assertSourceMissing($code) { PHPUnit::assertFalse( Str::contains($this->driver->getPageSource(), $code), "Found unexpected source code [{$code}]" ); return $this; }
[ "public", "function", "assertSourceMissing", "(", "$", "code", ")", "{", "PHPUnit", "::", "assertFalse", "(", "Str", "::", "contains", "(", "$", "this", "->", "driver", "->", "getPageSource", "(", ")", ",", "$", "code", ")", ",", "\"Found unexpected source code [{$code}]\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given source code is not present on the page. @param string $code @return $this
[ "Assert", "that", "the", "given", "source", "code", "is", "not", "present", "on", "the", "page", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L222-L230
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertSeeLink
public function assertSeeLink($link) { if ($this->resolver->prefix) { $message = "Did not see expected link [{$link}] within [{$this->resolver->prefix}]."; } else { $message = "Did not see expected link [{$link}]."; } PHPUnit::assertTrue( $this->seeLink($link), $message ); return $this; }
php
public function assertSeeLink($link) { if ($this->resolver->prefix) { $message = "Did not see expected link [{$link}] within [{$this->resolver->prefix}]."; } else { $message = "Did not see expected link [{$link}]."; } PHPUnit::assertTrue( $this->seeLink($link), $message ); return $this; }
[ "public", "function", "assertSeeLink", "(", "$", "link", ")", "{", "if", "(", "$", "this", "->", "resolver", "->", "prefix", ")", "{", "$", "message", "=", "\"Did not see expected link [{$link}] within [{$this->resolver->prefix}].\"", ";", "}", "else", "{", "$", "message", "=", "\"Did not see expected link [{$link}].\"", ";", "}", "PHPUnit", "::", "assertTrue", "(", "$", "this", "->", "seeLink", "(", "$", "link", ")", ",", "$", "message", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given link is visible. @param string $link @return $this
[ "Assert", "that", "the", "given", "link", "is", "visible", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L238-L252
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertDontSeeLink
public function assertDontSeeLink($link) { if ($this->resolver->prefix) { $message = "Saw unexpected link [{$link}] within [{$this->resolver->prefix}]."; } else { $message = "Saw unexpected link [{$link}]."; } PHPUnit::assertFalse( $this->seeLink($link), $message ); return $this; }
php
public function assertDontSeeLink($link) { if ($this->resolver->prefix) { $message = "Saw unexpected link [{$link}] within [{$this->resolver->prefix}]."; } else { $message = "Saw unexpected link [{$link}]."; } PHPUnit::assertFalse( $this->seeLink($link), $message ); return $this; }
[ "public", "function", "assertDontSeeLink", "(", "$", "link", ")", "{", "if", "(", "$", "this", "->", "resolver", "->", "prefix", ")", "{", "$", "message", "=", "\"Saw unexpected link [{$link}] within [{$this->resolver->prefix}].\"", ";", "}", "else", "{", "$", "message", "=", "\"Saw unexpected link [{$link}].\"", ";", "}", "PHPUnit", "::", "assertFalse", "(", "$", "this", "->", "seeLink", "(", "$", "link", ")", ",", "$", "message", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given link is not visible. @param string $link @return $this
[ "Assert", "that", "the", "given", "link", "is", "not", "visible", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L260-L274
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.seeLink
public function seeLink($link) { $this->ensurejQueryIsAvailable(); $selector = addslashes(trim($this->resolver->format("a:contains('{$link}')"))); $script = <<<JS var link = jQuery.find("{$selector}"); return link.length > 0 && jQuery(link).is(':visible'); JS; return $this->driver->executeScript($script); }
php
public function seeLink($link) { $this->ensurejQueryIsAvailable(); $selector = addslashes(trim($this->resolver->format("a:contains('{$link}')"))); $script = <<<JS var link = jQuery.find("{$selector}"); return link.length > 0 && jQuery(link).is(':visible'); JS; return $this->driver->executeScript($script); }
[ "public", "function", "seeLink", "(", "$", "link", ")", "{", "$", "this", "->", "ensurejQueryIsAvailable", "(", ")", ";", "$", "selector", "=", "addslashes", "(", "trim", "(", "$", "this", "->", "resolver", "->", "format", "(", "\"a:contains('{$link}')\"", ")", ")", ")", ";", "$", "script", "=", " <<<JS\n var link = jQuery.find(\"{$selector}\");\n return link.length > 0 && jQuery(link).is(':visible');\nJS", ";", "return", "$", "this", "->", "driver", "->", "executeScript", "(", "$", "script", ")", ";", "}" ]
Determine if the given link is visible. @param string $link @return bool
[ "Determine", "if", "the", "given", "link", "is", "visible", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L282-L294
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertInputValue
public function assertInputValue($field, $value) { PHPUnit::assertEquals( $value, $this->inputValue($field), "Expected value [{$value}] for the [{$field}] input does not equal the actual value [{$this->inputValue($field)}]." ); return $this; }
php
public function assertInputValue($field, $value) { PHPUnit::assertEquals( $value, $this->inputValue($field), "Expected value [{$value}] for the [{$field}] input does not equal the actual value [{$this->inputValue($field)}]." ); return $this; }
[ "public", "function", "assertInputValue", "(", "$", "field", ",", "$", "value", ")", "{", "PHPUnit", "::", "assertEquals", "(", "$", "value", ",", "$", "this", "->", "inputValue", "(", "$", "field", ")", ",", "\"Expected value [{$value}] for the [{$field}] input does not equal the actual value [{$this->inputValue($field)}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given input or text area contains the given value. @param string $field @param string $value @return $this
[ "Assert", "that", "the", "given", "input", "or", "text", "area", "contains", "the", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L303-L311
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertInputValueIsNot
public function assertInputValueIsNot($field, $value) { PHPUnit::assertNotEquals( $value, $this->inputValue($field), "Value [{$value}] for the [{$field}] input should not equal the actual value." ); return $this; }
php
public function assertInputValueIsNot($field, $value) { PHPUnit::assertNotEquals( $value, $this->inputValue($field), "Value [{$value}] for the [{$field}] input should not equal the actual value." ); return $this; }
[ "public", "function", "assertInputValueIsNot", "(", "$", "field", ",", "$", "value", ")", "{", "PHPUnit", "::", "assertNotEquals", "(", "$", "value", ",", "$", "this", "->", "inputValue", "(", "$", "field", ")", ",", "\"Value [{$value}] for the [{$field}] input should not equal the actual value.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given input or text area does not contain the given value. @param string $field @param string $value @return $this
[ "Assert", "that", "the", "given", "input", "or", "text", "area", "does", "not", "contain", "the", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L320-L328
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.inputValue
public function inputValue($field) { $element = $this->resolver->resolveForTyping($field); return in_array($element->getTagName(), ['input', 'textarea']) ? $element->getAttribute('value') : $element->getText(); }
php
public function inputValue($field) { $element = $this->resolver->resolveForTyping($field); return in_array($element->getTagName(), ['input', 'textarea']) ? $element->getAttribute('value') : $element->getText(); }
[ "public", "function", "inputValue", "(", "$", "field", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForTyping", "(", "$", "field", ")", ";", "return", "in_array", "(", "$", "element", "->", "getTagName", "(", ")", ",", "[", "'input'", ",", "'textarea'", "]", ")", "?", "$", "element", "->", "getAttribute", "(", "'value'", ")", ":", "$", "element", "->", "getText", "(", ")", ";", "}" ]
Get the value of the given input or text area field. @param string $field @return string
[ "Get", "the", "value", "of", "the", "given", "input", "or", "text", "area", "field", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L336-L343
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertChecked
public function assertChecked($field, $value = null) { $element = $this->resolver->resolveForChecking($field, $value); PHPUnit::assertTrue( $element->isSelected(), "Expected checkbox [{$field}] to be checked, but it wasn't." ); return $this; }
php
public function assertChecked($field, $value = null) { $element = $this->resolver->resolveForChecking($field, $value); PHPUnit::assertTrue( $element->isSelected(), "Expected checkbox [{$field}] to be checked, but it wasn't." ); return $this; }
[ "public", "function", "assertChecked", "(", "$", "field", ",", "$", "value", "=", "null", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForChecking", "(", "$", "field", ",", "$", "value", ")", ";", "PHPUnit", "::", "assertTrue", "(", "$", "element", "->", "isSelected", "(", ")", ",", "\"Expected checkbox [{$field}] to be checked, but it wasn't.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given checkbox field is checked. @param string $field @param string $value @return $this
[ "Assert", "that", "the", "given", "checkbox", "field", "is", "checked", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L352-L362
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertNotChecked
public function assertNotChecked($field, $value = null) { $element = $this->resolver->resolveForChecking($field, $value); PHPUnit::assertFalse( $element->isSelected(), "Checkbox [{$field}] was unexpectedly checked." ); return $this; }
php
public function assertNotChecked($field, $value = null) { $element = $this->resolver->resolveForChecking($field, $value); PHPUnit::assertFalse( $element->isSelected(), "Checkbox [{$field}] was unexpectedly checked." ); return $this; }
[ "public", "function", "assertNotChecked", "(", "$", "field", ",", "$", "value", "=", "null", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForChecking", "(", "$", "field", ",", "$", "value", ")", ";", "PHPUnit", "::", "assertFalse", "(", "$", "element", "->", "isSelected", "(", ")", ",", "\"Checkbox [{$field}] was unexpectedly checked.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given checkbox field is not checked. @param string $field @param string $value @return $this
[ "Assert", "that", "the", "given", "checkbox", "field", "is", "not", "checked", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L371-L381
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertRadioSelected
public function assertRadioSelected($field, $value) { $element = $this->resolver->resolveForRadioSelection($field, $value); PHPUnit::assertTrue( $element->isSelected(), "Expected radio [{$field}] to be selected, but it wasn't." ); return $this; }
php
public function assertRadioSelected($field, $value) { $element = $this->resolver->resolveForRadioSelection($field, $value); PHPUnit::assertTrue( $element->isSelected(), "Expected radio [{$field}] to be selected, but it wasn't." ); return $this; }
[ "public", "function", "assertRadioSelected", "(", "$", "field", ",", "$", "value", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForRadioSelection", "(", "$", "field", ",", "$", "value", ")", ";", "PHPUnit", "::", "assertTrue", "(", "$", "element", "->", "isSelected", "(", ")", ",", "\"Expected radio [{$field}] to be selected, but it wasn't.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given radio field is selected. @param string $field @param string $value @return $this
[ "Assert", "that", "the", "given", "radio", "field", "is", "selected", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L390-L400
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertRadioNotSelected
public function assertRadioNotSelected($field, $value = null) { $element = $this->resolver->resolveForRadioSelection($field, $value); PHPUnit::assertFalse( $element->isSelected(), "Radio [{$field}] was unexpectedly selected." ); return $this; }
php
public function assertRadioNotSelected($field, $value = null) { $element = $this->resolver->resolveForRadioSelection($field, $value); PHPUnit::assertFalse( $element->isSelected(), "Radio [{$field}] was unexpectedly selected." ); return $this; }
[ "public", "function", "assertRadioNotSelected", "(", "$", "field", ",", "$", "value", "=", "null", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForRadioSelection", "(", "$", "field", ",", "$", "value", ")", ";", "PHPUnit", "::", "assertFalse", "(", "$", "element", "->", "isSelected", "(", ")", ",", "\"Radio [{$field}] was unexpectedly selected.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given radio field is not selected. @param string $field @param string $value @return $this
[ "Assert", "that", "the", "given", "radio", "field", "is", "not", "selected", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L409-L419
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertSelected
public function assertSelected($field, $value) { PHPUnit::assertTrue( $this->selected($field, $value), "Expected value [{$value}] to be selected for [{$field}], but it wasn't." ); return $this; }
php
public function assertSelected($field, $value) { PHPUnit::assertTrue( $this->selected($field, $value), "Expected value [{$value}] to be selected for [{$field}], but it wasn't." ); return $this; }
[ "public", "function", "assertSelected", "(", "$", "field", ",", "$", "value", ")", "{", "PHPUnit", "::", "assertTrue", "(", "$", "this", "->", "selected", "(", "$", "field", ",", "$", "value", ")", ",", "\"Expected value [{$value}] to be selected for [{$field}], but it wasn't.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given select field has the given value selected. @param string $field @param string $value @return $this
[ "Assert", "that", "the", "given", "select", "field", "has", "the", "given", "value", "selected", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L428-L436
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertNotSelected
public function assertNotSelected($field, $value) { PHPUnit::assertFalse( $this->selected($field, $value), "Unexpected value [{$value}] selected for [{$field}]." ); return $this; }
php
public function assertNotSelected($field, $value) { PHPUnit::assertFalse( $this->selected($field, $value), "Unexpected value [{$value}] selected for [{$field}]." ); return $this; }
[ "public", "function", "assertNotSelected", "(", "$", "field", ",", "$", "value", ")", "{", "PHPUnit", "::", "assertFalse", "(", "$", "this", "->", "selected", "(", "$", "field", ",", "$", "value", ")", ",", "\"Unexpected value [{$value}] selected for [{$field}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given select field does not have the given value selected. @param string $field @param string $value @return $this
[ "Assert", "that", "the", "given", "select", "field", "does", "not", "have", "the", "given", "value", "selected", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L445-L453
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertSelectHasOptions
public function assertSelectHasOptions($field, array $values) { $options = $this->resolver->resolveSelectOptions($field, $values); $options = collect($options)->unique(function (RemoteWebElement $option) { return $option->getAttribute('value'); })->all(); PHPUnit::assertCount( count($values), $options, 'Expected options ['.implode(',', $values)."] for selection field [{$field}] to be available." ); return $this; }
php
public function assertSelectHasOptions($field, array $values) { $options = $this->resolver->resolveSelectOptions($field, $values); $options = collect($options)->unique(function (RemoteWebElement $option) { return $option->getAttribute('value'); })->all(); PHPUnit::assertCount( count($values), $options, 'Expected options ['.implode(',', $values)."] for selection field [{$field}] to be available." ); return $this; }
[ "public", "function", "assertSelectHasOptions", "(", "$", "field", ",", "array", "$", "values", ")", "{", "$", "options", "=", "$", "this", "->", "resolver", "->", "resolveSelectOptions", "(", "$", "field", ",", "$", "values", ")", ";", "$", "options", "=", "collect", "(", "$", "options", ")", "->", "unique", "(", "function", "(", "RemoteWebElement", "$", "option", ")", "{", "return", "$", "option", "->", "getAttribute", "(", "'value'", ")", ";", "}", ")", "->", "all", "(", ")", ";", "PHPUnit", "::", "assertCount", "(", "count", "(", "$", "values", ")", ",", "$", "options", ",", "'Expected options ['", ".", "implode", "(", "','", ",", "$", "values", ")", ".", "\"] for selection field [{$field}] to be available.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given array of values are available to be selected. @param string $field @param array $values @return $this
[ "Assert", "that", "the", "given", "array", "of", "values", "are", "available", "to", "be", "selected", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L462-L476
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertSelectMissingOptions
public function assertSelectMissingOptions($field, array $values) { PHPUnit::assertCount( 0, $this->resolver->resolveSelectOptions($field, $values), 'Unexpected options ['.implode(',', $values)."] for selection field [{$field}]." ); return $this; }
php
public function assertSelectMissingOptions($field, array $values) { PHPUnit::assertCount( 0, $this->resolver->resolveSelectOptions($field, $values), 'Unexpected options ['.implode(',', $values)."] for selection field [{$field}]." ); return $this; }
[ "public", "function", "assertSelectMissingOptions", "(", "$", "field", ",", "array", "$", "values", ")", "{", "PHPUnit", "::", "assertCount", "(", "0", ",", "$", "this", "->", "resolver", "->", "resolveSelectOptions", "(", "$", "field", ",", "$", "values", ")", ",", "'Unexpected options ['", ".", "implode", "(", "','", ",", "$", "values", ")", ".", "\"] for selection field [{$field}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given array of values are not available to be selected. @param string $field @param array $values @return $this
[ "Assert", "that", "the", "given", "array", "of", "values", "are", "not", "available", "to", "be", "selected", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L485-L493
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.selected
public function selected($field, $value) { $options = $this->resolver->resolveSelectOptions($field, (array) $value); return collect($options)->contains(function (RemoteWebElement $option) { return $option->isSelected(); }); }
php
public function selected($field, $value) { $options = $this->resolver->resolveSelectOptions($field, (array) $value); return collect($options)->contains(function (RemoteWebElement $option) { return $option->isSelected(); }); }
[ "public", "function", "selected", "(", "$", "field", ",", "$", "value", ")", "{", "$", "options", "=", "$", "this", "->", "resolver", "->", "resolveSelectOptions", "(", "$", "field", ",", "(", "array", ")", "$", "value", ")", ";", "return", "collect", "(", "$", "options", ")", "->", "contains", "(", "function", "(", "RemoteWebElement", "$", "option", ")", "{", "return", "$", "option", "->", "isSelected", "(", ")", ";", "}", ")", ";", "}" ]
Determine if the given value is selected for the given select field. @param string $field @param string $value @return bool
[ "Determine", "if", "the", "given", "value", "is", "selected", "for", "the", "given", "select", "field", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L526-L533
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertValue
public function assertValue($selector, $value) { $actual = $this->resolver->findOrFail($selector)->getAttribute('value'); PHPUnit::assertEquals($value, $actual); return $this; }
php
public function assertValue($selector, $value) { $actual = $this->resolver->findOrFail($selector)->getAttribute('value'); PHPUnit::assertEquals($value, $actual); return $this; }
[ "public", "function", "assertValue", "(", "$", "selector", ",", "$", "value", ")", "{", "$", "actual", "=", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", "->", "getAttribute", "(", "'value'", ")", ";", "PHPUnit", "::", "assertEquals", "(", "$", "value", ",", "$", "actual", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the element at the given selector has the given value. @param string $selector @param string $value @return $this
[ "Assert", "that", "the", "element", "at", "the", "given", "selector", "has", "the", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L542-L549
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertVisible
public function assertVisible($selector) { $fullSelector = $this->resolver->format($selector); PHPUnit::assertTrue( $this->resolver->findOrFail($selector)->isDisplayed(), "Element [{$fullSelector}] is not visible." ); return $this; }
php
public function assertVisible($selector) { $fullSelector = $this->resolver->format($selector); PHPUnit::assertTrue( $this->resolver->findOrFail($selector)->isDisplayed(), "Element [{$fullSelector}] is not visible." ); return $this; }
[ "public", "function", "assertVisible", "(", "$", "selector", ")", "{", "$", "fullSelector", "=", "$", "this", "->", "resolver", "->", "format", "(", "$", "selector", ")", ";", "PHPUnit", "::", "assertTrue", "(", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", "->", "isDisplayed", "(", ")", ",", "\"Element [{$fullSelector}] is not visible.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the element with the given selector is visible. @param string $selector @return $this
[ "Assert", "that", "the", "element", "with", "the", "given", "selector", "is", "visible", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L557-L567
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertPresent
public function assertPresent($selector) { $fullSelector = $this->resolver->format($selector); PHPUnit::assertTrue( ! is_null($this->resolver->find($selector)), "Element [{$fullSelector}] is not present." ); return $this; }
php
public function assertPresent($selector) { $fullSelector = $this->resolver->format($selector); PHPUnit::assertTrue( ! is_null($this->resolver->find($selector)), "Element [{$fullSelector}] is not present." ); return $this; }
[ "public", "function", "assertPresent", "(", "$", "selector", ")", "{", "$", "fullSelector", "=", "$", "this", "->", "resolver", "->", "format", "(", "$", "selector", ")", ";", "PHPUnit", "::", "assertTrue", "(", "!", "is_null", "(", "$", "this", "->", "resolver", "->", "find", "(", "$", "selector", ")", ")", ",", "\"Element [{$fullSelector}] is not present.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the element with the given selector is present in the DOM. @param string $selector @return $this
[ "Assert", "that", "the", "element", "with", "the", "given", "selector", "is", "present", "in", "the", "DOM", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L575-L585
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertMissing
public function assertMissing($selector) { $fullSelector = $this->resolver->format($selector); try { $missing = ! $this->resolver->findOrFail($selector)->isDisplayed(); } catch (NoSuchElementException $e) { $missing = true; } PHPUnit::assertTrue($missing, "Saw unexpected element [{$fullSelector}]."); return $this; }
php
public function assertMissing($selector) { $fullSelector = $this->resolver->format($selector); try { $missing = ! $this->resolver->findOrFail($selector)->isDisplayed(); } catch (NoSuchElementException $e) { $missing = true; } PHPUnit::assertTrue($missing, "Saw unexpected element [{$fullSelector}]."); return $this; }
[ "public", "function", "assertMissing", "(", "$", "selector", ")", "{", "$", "fullSelector", "=", "$", "this", "->", "resolver", "->", "format", "(", "$", "selector", ")", ";", "try", "{", "$", "missing", "=", "!", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", "->", "isDisplayed", "(", ")", ";", "}", "catch", "(", "NoSuchElementException", "$", "e", ")", "{", "$", "missing", "=", "true", ";", "}", "PHPUnit", "::", "assertTrue", "(", "$", "missing", ",", "\"Saw unexpected element [{$fullSelector}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the element with the given selector is not on the page. @param string $selector @return $this
[ "Assert", "that", "the", "element", "with", "the", "given", "selector", "is", "not", "on", "the", "page", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L593-L606
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertDialogOpened
public function assertDialogOpened($message) { $actualMessage = $this->driver->switchTo()->alert()->getText(); PHPUnit::assertEquals( $message, $actualMessage, "Expected dialog message [{$message}] does not equal actual message [{$actualMessage}]." ); return $this; }
php
public function assertDialogOpened($message) { $actualMessage = $this->driver->switchTo()->alert()->getText(); PHPUnit::assertEquals( $message, $actualMessage, "Expected dialog message [{$message}] does not equal actual message [{$actualMessage}]." ); return $this; }
[ "public", "function", "assertDialogOpened", "(", "$", "message", ")", "{", "$", "actualMessage", "=", "$", "this", "->", "driver", "->", "switchTo", "(", ")", "->", "alert", "(", ")", "->", "getText", "(", ")", ";", "PHPUnit", "::", "assertEquals", "(", "$", "message", ",", "$", "actualMessage", ",", "\"Expected dialog message [{$message}] does not equal actual message [{$actualMessage}].\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that a JavaScript dialog with given message has been opened. @param string $message @return $this
[ "Assert", "that", "a", "JavaScript", "dialog", "with", "given", "message", "has", "been", "opened", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L614-L624
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertEnabled
public function assertEnabled($field) { $element = $this->resolver->resolveForField($field); PHPUnit::assertTrue( $element->isEnabled(), "Expected element [{$field}] to be enabled, but it wasn't." ); return $this; }
php
public function assertEnabled($field) { $element = $this->resolver->resolveForField($field); PHPUnit::assertTrue( $element->isEnabled(), "Expected element [{$field}] to be enabled, but it wasn't." ); return $this; }
[ "public", "function", "assertEnabled", "(", "$", "field", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForField", "(", "$", "field", ")", ";", "PHPUnit", "::", "assertTrue", "(", "$", "element", "->", "isEnabled", "(", ")", ",", "\"Expected element [{$field}] to be enabled, but it wasn't.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given field is enabled. @param string $field @return $this
[ "Assert", "that", "the", "given", "field", "is", "enabled", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L632-L642
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertDisabled
public function assertDisabled($field) { $element = $this->resolver->resolveForField($field); PHPUnit::assertFalse( $element->isEnabled(), "Expected element [{$field}] to be disabled, but it wasn't." ); return $this; }
php
public function assertDisabled($field) { $element = $this->resolver->resolveForField($field); PHPUnit::assertFalse( $element->isEnabled(), "Expected element [{$field}] to be disabled, but it wasn't." ); return $this; }
[ "public", "function", "assertDisabled", "(", "$", "field", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForField", "(", "$", "field", ")", ";", "PHPUnit", "::", "assertFalse", "(", "$", "element", "->", "isEnabled", "(", ")", ",", "\"Expected element [{$field}] to be disabled, but it wasn't.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given field is disabled. @param string $field @return $this
[ "Assert", "that", "the", "given", "field", "is", "disabled", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L650-L660
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertFocused
public function assertFocused($field) { $element = $this->resolver->resolveForField($field); PHPUnit::assertTrue( $this->driver->switchTo()->activeElement()->equals($element), "Expected element [{$field}] to be focused, but it wasn't." ); return $this; }
php
public function assertFocused($field) { $element = $this->resolver->resolveForField($field); PHPUnit::assertTrue( $this->driver->switchTo()->activeElement()->equals($element), "Expected element [{$field}] to be focused, but it wasn't." ); return $this; }
[ "public", "function", "assertFocused", "(", "$", "field", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForField", "(", "$", "field", ")", ";", "PHPUnit", "::", "assertTrue", "(", "$", "this", "->", "driver", "->", "switchTo", "(", ")", "->", "activeElement", "(", ")", "->", "equals", "(", "$", "element", ")", ",", "\"Expected element [{$field}] to be focused, but it wasn't.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given field is focused. @param string $field @return $this
[ "Assert", "that", "the", "given", "field", "is", "focused", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L668-L678
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertNotFocused
public function assertNotFocused($field) { $element = $this->resolver->resolveForField($field); PHPUnit::assertFalse( $this->driver->switchTo()->activeElement()->equals($element), "Expected element [{$field}] not to be focused, but it was." ); return $this; }
php
public function assertNotFocused($field) { $element = $this->resolver->resolveForField($field); PHPUnit::assertFalse( $this->driver->switchTo()->activeElement()->equals($element), "Expected element [{$field}] not to be focused, but it was." ); return $this; }
[ "public", "function", "assertNotFocused", "(", "$", "field", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForField", "(", "$", "field", ")", ";", "PHPUnit", "::", "assertFalse", "(", "$", "this", "->", "driver", "->", "switchTo", "(", ")", "->", "activeElement", "(", ")", "->", "equals", "(", "$", "element", ")", ",", "\"Expected element [{$field}] not to be focused, but it was.\"", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the given field is not focused. @param string $field @return $this
[ "Assert", "that", "the", "given", "field", "is", "not", "focused", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L686-L696
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertVue
public function assertVue($key, $value, $componentSelector = null) { PHPUnit::assertEquals($value, $this->vueAttribute($componentSelector, $key)); return $this; }
php
public function assertVue($key, $value, $componentSelector = null) { PHPUnit::assertEquals($value, $this->vueAttribute($componentSelector, $key)); return $this; }
[ "public", "function", "assertVue", "(", "$", "key", ",", "$", "value", ",", "$", "componentSelector", "=", "null", ")", "{", "PHPUnit", "::", "assertEquals", "(", "$", "value", ",", "$", "this", "->", "vueAttribute", "(", "$", "componentSelector", ",", "$", "key", ")", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the Vue component's attribute at the given key has the given value. @param string $key @param string $value @param string|null $componentSelector @return $this
[ "Assert", "that", "the", "Vue", "component", "s", "attribute", "at", "the", "given", "key", "has", "the", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L706-L711
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertVueIsNot
public function assertVueIsNot($key, $value, $componentSelector = null) { PHPUnit::assertNotEquals($value, $this->vueAttribute($componentSelector, $key)); return $this; }
php
public function assertVueIsNot($key, $value, $componentSelector = null) { PHPUnit::assertNotEquals($value, $this->vueAttribute($componentSelector, $key)); return $this; }
[ "public", "function", "assertVueIsNot", "(", "$", "key", ",", "$", "value", ",", "$", "componentSelector", "=", "null", ")", "{", "PHPUnit", "::", "assertNotEquals", "(", "$", "value", ",", "$", "this", "->", "vueAttribute", "(", "$", "componentSelector", ",", "$", "key", ")", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the Vue component's attribute at the given key does not have the given value. @param string $key @param string $value @param string|null $componentSelector @return $this
[ "Assert", "that", "the", "Vue", "component", "s", "attribute", "at", "the", "given", "key", "does", "not", "have", "the", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L722-L727
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertVueContains
public function assertVueContains($key, $value, $componentSelector = null) { $attribute = $this->vueAttribute($componentSelector, $key); PHPUnit::assertIsArray($attribute, "The attribute for key [$key] is not an array."); PHPUnit::assertContains($value, $attribute); return $this; }
php
public function assertVueContains($key, $value, $componentSelector = null) { $attribute = $this->vueAttribute($componentSelector, $key); PHPUnit::assertIsArray($attribute, "The attribute for key [$key] is not an array."); PHPUnit::assertContains($value, $attribute); return $this; }
[ "public", "function", "assertVueContains", "(", "$", "key", ",", "$", "value", ",", "$", "componentSelector", "=", "null", ")", "{", "$", "attribute", "=", "$", "this", "->", "vueAttribute", "(", "$", "componentSelector", ",", "$", "key", ")", ";", "PHPUnit", "::", "assertIsArray", "(", "$", "attribute", ",", "\"The attribute for key [$key] is not an array.\"", ")", ";", "PHPUnit", "::", "assertContains", "(", "$", "value", ",", "$", "attribute", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the Vue component's attribute at the given key is an array that contains the given value. @param string $key @param string $value @param string|null $componentSelector @return $this
[ "Assert", "that", "the", "Vue", "component", "s", "attribute", "at", "the", "given", "key", "is", "an", "array", "that", "contains", "the", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L738-L746
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.assertVueDoesNotContain
public function assertVueDoesNotContain($key, $value, $componentSelector = null) { $attribute = $this->vueAttribute($componentSelector, $key); PHPUnit::assertIsArray($attribute, "The attribute for key [$key] is not an array."); PHPUnit::assertNotContains($value, $attribute); return $this; }
php
public function assertVueDoesNotContain($key, $value, $componentSelector = null) { $attribute = $this->vueAttribute($componentSelector, $key); PHPUnit::assertIsArray($attribute, "The attribute for key [$key] is not an array."); PHPUnit::assertNotContains($value, $attribute); return $this; }
[ "public", "function", "assertVueDoesNotContain", "(", "$", "key", ",", "$", "value", ",", "$", "componentSelector", "=", "null", ")", "{", "$", "attribute", "=", "$", "this", "->", "vueAttribute", "(", "$", "componentSelector", ",", "$", "key", ")", ";", "PHPUnit", "::", "assertIsArray", "(", "$", "attribute", ",", "\"The attribute for key [$key] is not an array.\"", ")", ";", "PHPUnit", "::", "assertNotContains", "(", "$", "value", ",", "$", "attribute", ")", ";", "return", "$", "this", ";", "}" ]
Assert that the Vue component's attribute at the given key is an array that does not contain the given value. @param string $key @param string $value @param string|null $componentSelector @return $this
[ "Assert", "that", "the", "Vue", "component", "s", "attribute", "at", "the", "given", "key", "is", "an", "array", "that", "does", "not", "contain", "the", "given", "value", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L757-L765
train
laravel/dusk
src/Concerns/MakesAssertions.php
MakesAssertions.vueAttribute
public function vueAttribute($componentSelector, $key) { $fullSelector = $this->resolver->format($componentSelector); return $this->driver->executeScript( "return document.querySelector('".$fullSelector."').__vue__.".$key ); }
php
public function vueAttribute($componentSelector, $key) { $fullSelector = $this->resolver->format($componentSelector); return $this->driver->executeScript( "return document.querySelector('".$fullSelector."').__vue__.".$key ); }
[ "public", "function", "vueAttribute", "(", "$", "componentSelector", ",", "$", "key", ")", "{", "$", "fullSelector", "=", "$", "this", "->", "resolver", "->", "format", "(", "$", "componentSelector", ")", ";", "return", "$", "this", "->", "driver", "->", "executeScript", "(", "\"return document.querySelector('\"", ".", "$", "fullSelector", ".", "\"').__vue__.\"", ".", "$", "key", ")", ";", "}" ]
Retrieve the value of the Vue component's attribute at the given key. @param string $componentSelector @param string $key @return mixed
[ "Retrieve", "the", "value", "of", "the", "Vue", "component", "s", "attribute", "at", "the", "given", "key", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/MakesAssertions.php#L774-L781
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.clickLink
public function clickLink($link, $element = 'a') { $this->ensurejQueryIsAvailable(); $selector = addslashes(trim($this->resolver->format("{$element}:contains({$link}):visible"))); $this->driver->executeScript("jQuery.find(\"{$selector}\")[0].click();"); return $this; }
php
public function clickLink($link, $element = 'a') { $this->ensurejQueryIsAvailable(); $selector = addslashes(trim($this->resolver->format("{$element}:contains({$link}):visible"))); $this->driver->executeScript("jQuery.find(\"{$selector}\")[0].click();"); return $this; }
[ "public", "function", "clickLink", "(", "$", "link", ",", "$", "element", "=", "'a'", ")", "{", "$", "this", "->", "ensurejQueryIsAvailable", "(", ")", ";", "$", "selector", "=", "addslashes", "(", "trim", "(", "$", "this", "->", "resolver", "->", "format", "(", "\"{$element}:contains({$link}):visible\"", ")", ")", ")", ";", "$", "this", "->", "driver", "->", "executeScript", "(", "\"jQuery.find(\\\"{$selector}\\\")[0].click();\"", ")", ";", "return", "$", "this", ";", "}" ]
Click the link with the given text. @param string $link @param string $element @return $this
[ "Click", "the", "link", "with", "the", "given", "text", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L42-L51
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.value
public function value($selector, $value = null) { if (is_null($value)) { return $this->resolver->findOrFail($selector)->getAttribute('value'); } $selector = $this->resolver->format($selector); $this->driver->executeScript( "document.querySelector('{$selector}').value = '{$value}';" ); return $this; }
php
public function value($selector, $value = null) { if (is_null($value)) { return $this->resolver->findOrFail($selector)->getAttribute('value'); } $selector = $this->resolver->format($selector); $this->driver->executeScript( "document.querySelector('{$selector}').value = '{$value}';" ); return $this; }
[ "public", "function", "value", "(", "$", "selector", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", "->", "getAttribute", "(", "'value'", ")", ";", "}", "$", "selector", "=", "$", "this", "->", "resolver", "->", "format", "(", "$", "selector", ")", ";", "$", "this", "->", "driver", "->", "executeScript", "(", "\"document.querySelector('{$selector}').value = '{$value}';\"", ")", ";", "return", "$", "this", ";", "}" ]
Directly get or set the value attribute of an input field. @param string $selector @param string|null $value @return $this
[ "Directly", "get", "or", "set", "the", "value", "attribute", "of", "an", "input", "field", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L60-L73
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.keys
public function keys($selector, ...$keys) { $this->resolver->findOrFail($selector)->sendKeys($this->parseKeys($keys)); return $this; }
php
public function keys($selector, ...$keys) { $this->resolver->findOrFail($selector)->sendKeys($this->parseKeys($keys)); return $this; }
[ "public", "function", "keys", "(", "$", "selector", ",", "...", "$", "keys", ")", "{", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", "->", "sendKeys", "(", "$", "this", "->", "parseKeys", "(", "$", "keys", ")", ")", ";", "return", "$", "this", ";", "}" ]
Send the given keys to the element matching the given selector. @param string $selector @param dynamic $keys @return $this
[ "Send", "the", "given", "keys", "to", "the", "element", "matching", "the", "given", "selector", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L105-L110
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.parseKeys
protected function parseKeys($keys) { return collect($keys)->map(function ($key) { if (is_string($key) && Str::startsWith($key, '{') && Str::endsWith($key, '}')) { $key = constant(WebDriverKeys::class.'::'.strtoupper(trim($key, '{}'))); } if (is_array($key) && Str::startsWith($key[0], '{')) { $key[0] = constant(WebDriverKeys::class.'::'.strtoupper(trim($key[0], '{}'))); } return $key; })->all(); }
php
protected function parseKeys($keys) { return collect($keys)->map(function ($key) { if (is_string($key) && Str::startsWith($key, '{') && Str::endsWith($key, '}')) { $key = constant(WebDriverKeys::class.'::'.strtoupper(trim($key, '{}'))); } if (is_array($key) && Str::startsWith($key[0], '{')) { $key[0] = constant(WebDriverKeys::class.'::'.strtoupper(trim($key[0], '{}'))); } return $key; })->all(); }
[ "protected", "function", "parseKeys", "(", "$", "keys", ")", "{", "return", "collect", "(", "$", "keys", ")", "->", "map", "(", "function", "(", "$", "key", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", "&&", "Str", "::", "startsWith", "(", "$", "key", ",", "'{'", ")", "&&", "Str", "::", "endsWith", "(", "$", "key", ",", "'}'", ")", ")", "{", "$", "key", "=", "constant", "(", "WebDriverKeys", "::", "class", ".", "'::'", ".", "strtoupper", "(", "trim", "(", "$", "key", ",", "'{}'", ")", ")", ")", ";", "}", "if", "(", "is_array", "(", "$", "key", ")", "&&", "Str", "::", "startsWith", "(", "$", "key", "[", "0", "]", ",", "'{'", ")", ")", "{", "$", "key", "[", "0", "]", "=", "constant", "(", "WebDriverKeys", "::", "class", ".", "'::'", ".", "strtoupper", "(", "trim", "(", "$", "key", "[", "0", "]", ",", "'{}'", ")", ")", ")", ";", "}", "return", "$", "key", ";", "}", ")", "->", "all", "(", ")", ";", "}" ]
Parse the keys before sending to the keyboard. @param array $keys @return array
[ "Parse", "the", "keys", "before", "sending", "to", "the", "keyboard", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L118-L131
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.type
public function type($field, $value) { $this->resolver->resolveForTyping($field)->clear()->sendKeys($value); return $this; }
php
public function type($field, $value) { $this->resolver->resolveForTyping($field)->clear()->sendKeys($value); return $this; }
[ "public", "function", "type", "(", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "resolver", "->", "resolveForTyping", "(", "$", "field", ")", "->", "clear", "(", ")", "->", "sendKeys", "(", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Type the given value in the given field. @param string $field @param string $value @return $this
[ "Type", "the", "given", "value", "in", "the", "given", "field", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L140-L145
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.append
public function append($field, $value) { $this->resolver->resolveForTyping($field)->sendKeys($value); return $this; }
php
public function append($field, $value) { $this->resolver->resolveForTyping($field)->sendKeys($value); return $this; }
[ "public", "function", "append", "(", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "resolver", "->", "resolveForTyping", "(", "$", "field", ")", "->", "sendKeys", "(", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Type the given value in the given field without clearing it. @param string $field @param string $value @return $this
[ "Type", "the", "given", "value", "in", "the", "given", "field", "without", "clearing", "it", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L154-L159
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.select
public function select($field, $value = null) { $element = $this->resolver->resolveForSelection($field); $options = $element->findElements(WebDriverBy::cssSelector('option:not([disabled])')); if (is_null($value)) { $options[array_rand($options)]->click(); } else { foreach ($options as $option) { if ((string) $option->getAttribute('value') === (string) $value) { $option->click(); break; } } } return $this; }
php
public function select($field, $value = null) { $element = $this->resolver->resolveForSelection($field); $options = $element->findElements(WebDriverBy::cssSelector('option:not([disabled])')); if (is_null($value)) { $options[array_rand($options)]->click(); } else { foreach ($options as $option) { if ((string) $option->getAttribute('value') === (string) $value) { $option->click(); break; } } } return $this; }
[ "public", "function", "select", "(", "$", "field", ",", "$", "value", "=", "null", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForSelection", "(", "$", "field", ")", ";", "$", "options", "=", "$", "element", "->", "findElements", "(", "WebDriverBy", "::", "cssSelector", "(", "'option:not([disabled])'", ")", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "options", "[", "array_rand", "(", "$", "options", ")", "]", "->", "click", "(", ")", ";", "}", "else", "{", "foreach", "(", "$", "options", "as", "$", "option", ")", "{", "if", "(", "(", "string", ")", "$", "option", "->", "getAttribute", "(", "'value'", ")", "===", "(", "string", ")", "$", "value", ")", "{", "$", "option", "->", "click", "(", ")", ";", "break", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Select the given value or random value of a drop-down field. @param string $field @param string $value @return $this
[ "Select", "the", "given", "value", "or", "random", "value", "of", "a", "drop", "-", "down", "field", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L181-L200
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.radio
public function radio($field, $value) { $this->resolver->resolveForRadioSelection($field, $value)->click(); return $this; }
php
public function radio($field, $value) { $this->resolver->resolveForRadioSelection($field, $value)->click(); return $this; }
[ "public", "function", "radio", "(", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "resolver", "->", "resolveForRadioSelection", "(", "$", "field", ",", "$", "value", ")", "->", "click", "(", ")", ";", "return", "$", "this", ";", "}" ]
Select the given value of a radio button field. @param string $field @param string $value @return $this
[ "Select", "the", "given", "value", "of", "a", "radio", "button", "field", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L209-L214
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.check
public function check($field, $value = null) { $element = $this->resolver->resolveForChecking($field, $value); if (! $element->isSelected()) { $element->click(); } return $this; }
php
public function check($field, $value = null) { $element = $this->resolver->resolveForChecking($field, $value); if (! $element->isSelected()) { $element->click(); } return $this; }
[ "public", "function", "check", "(", "$", "field", ",", "$", "value", "=", "null", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForChecking", "(", "$", "field", ",", "$", "value", ")", ";", "if", "(", "!", "$", "element", "->", "isSelected", "(", ")", ")", "{", "$", "element", "->", "click", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Check the given checkbox. @param string $field @param string $value @return $this
[ "Check", "the", "given", "checkbox", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L223-L232
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.attach
public function attach($field, $path) { $element = $this->resolver->resolveForAttachment($field); $element->setFileDetector(new LocalFileDetector)->sendKeys($path); return $this; }
php
public function attach($field, $path) { $element = $this->resolver->resolveForAttachment($field); $element->setFileDetector(new LocalFileDetector)->sendKeys($path); return $this; }
[ "public", "function", "attach", "(", "$", "field", ",", "$", "path", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForAttachment", "(", "$", "field", ")", ";", "$", "element", "->", "setFileDetector", "(", "new", "LocalFileDetector", ")", "->", "sendKeys", "(", "$", "path", ")", ";", "return", "$", "this", ";", "}" ]
Attach the given file to the field. @param string $field @param string $path @return $this
[ "Attach", "the", "given", "file", "to", "the", "field", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L259-L266
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.pressAndWaitFor
public function pressAndWaitFor($button, $seconds = 5) { $element = $this->resolver->resolveForButtonPress($button); $element->click(); return $this->waitUsing($seconds, 100, function () use ($element) { return $element->isEnabled(); }); }
php
public function pressAndWaitFor($button, $seconds = 5) { $element = $this->resolver->resolveForButtonPress($button); $element->click(); return $this->waitUsing($seconds, 100, function () use ($element) { return $element->isEnabled(); }); }
[ "public", "function", "pressAndWaitFor", "(", "$", "button", ",", "$", "seconds", "=", "5", ")", "{", "$", "element", "=", "$", "this", "->", "resolver", "->", "resolveForButtonPress", "(", "$", "button", ")", ";", "$", "element", "->", "click", "(", ")", ";", "return", "$", "this", "->", "waitUsing", "(", "$", "seconds", ",", "100", ",", "function", "(", ")", "use", "(", "$", "element", ")", "{", "return", "$", "element", "->", "isEnabled", "(", ")", ";", "}", ")", ";", "}" ]
Press the button with the given text or name. @param string $button @param int $seconds @return $this
[ "Press", "the", "button", "with", "the", "given", "text", "or", "name", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L288-L297
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.drag
public function drag($from, $to) { (new WebDriverActions($this->driver))->dragAndDrop( $this->resolver->findOrFail($from), $this->resolver->findOrFail($to) )->perform(); return $this; }
php
public function drag($from, $to) { (new WebDriverActions($this->driver))->dragAndDrop( $this->resolver->findOrFail($from), $this->resolver->findOrFail($to) )->perform(); return $this; }
[ "public", "function", "drag", "(", "$", "from", ",", "$", "to", ")", "{", "(", "new", "WebDriverActions", "(", "$", "this", "->", "driver", ")", ")", "->", "dragAndDrop", "(", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "from", ")", ",", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "to", ")", ")", "->", "perform", "(", ")", ";", "return", "$", "this", ";", "}" ]
Drag an element to another element using selectors. @param string $from @param string $to @return $this
[ "Drag", "an", "element", "to", "another", "element", "using", "selectors", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L306-L313
train
laravel/dusk
src/Concerns/InteractsWithElements.php
InteractsWithElements.dragOffset
public function dragOffset($selector, $x = 0, $y = 0) { (new WebDriverActions($this->driver))->dragAndDropBy( $this->resolver->findOrFail($selector), $x, $y )->perform(); return $this; }
php
public function dragOffset($selector, $x = 0, $y = 0) { (new WebDriverActions($this->driver))->dragAndDropBy( $this->resolver->findOrFail($selector), $x, $y )->perform(); return $this; }
[ "public", "function", "dragOffset", "(", "$", "selector", ",", "$", "x", "=", "0", ",", "$", "y", "=", "0", ")", "{", "(", "new", "WebDriverActions", "(", "$", "this", "->", "driver", ")", ")", "->", "dragAndDropBy", "(", "$", "this", "->", "resolver", "->", "findOrFail", "(", "$", "selector", ")", ",", "$", "x", ",", "$", "y", ")", "->", "perform", "(", ")", ";", "return", "$", "this", ";", "}" ]
Drag an element by the given offset. @param string $selector @param int $x @param int $y @return $this
[ "Drag", "an", "element", "by", "the", "given", "offset", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Concerns/InteractsWithElements.php#L371-L378
train
laravel/dusk
src/Browser.php
Browser.onWithoutAssert
public function onWithoutAssert($page) { $this->page = $page; // Here we will set the page elements on the resolver instance, which will allow // the developer to access short-cuts for CSS selectors on the page which can // allow for more expressive navigation and interaction with all the pages. $this->resolver->pageElements(array_merge( $page::siteElements(), $page->elements() )); return $this; }
php
public function onWithoutAssert($page) { $this->page = $page; // Here we will set the page elements on the resolver instance, which will allow // the developer to access short-cuts for CSS selectors on the page which can // allow for more expressive navigation and interaction with all the pages. $this->resolver->pageElements(array_merge( $page::siteElements(), $page->elements() )); return $this; }
[ "public", "function", "onWithoutAssert", "(", "$", "page", ")", "{", "$", "this", "->", "page", "=", "$", "page", ";", "// Here we will set the page elements on the resolver instance, which will allow", "// the developer to access short-cuts for CSS selectors on the page which can", "// allow for more expressive navigation and interaction with all the pages.", "$", "this", "->", "resolver", "->", "pageElements", "(", "array_merge", "(", "$", "page", "::", "siteElements", "(", ")", ",", "$", "page", "->", "elements", "(", ")", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set the current page object without executing the assertions. @param mixed $page @return $this
[ "Set", "the", "current", "page", "object", "without", "executing", "the", "assertions", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Browser.php#L183-L195
train
laravel/dusk
src/Browser.php
Browser.resize
public function resize($width, $height) { $this->driver->manage()->window()->setSize( new WebDriverDimension($width, $height) ); return $this; }
php
public function resize($width, $height) { $this->driver->manage()->window()->setSize( new WebDriverDimension($width, $height) ); return $this; }
[ "public", "function", "resize", "(", "$", "width", ",", "$", "height", ")", "{", "$", "this", "->", "driver", "->", "manage", "(", ")", "->", "window", "(", ")", "->", "setSize", "(", "new", "WebDriverDimension", "(", "$", "width", ",", "$", "height", ")", ")", ";", "return", "$", "this", ";", "}" ]
Resize the browser window. @param int $width @param int $height @return $this
[ "Resize", "the", "browser", "window", "." ]
a6ac3e6489dc774445aa9459cdc332104591634a
https://github.com/laravel/dusk/blob/a6ac3e6489dc774445aa9459cdc332104591634a/src/Browser.php#L240-L247
train