idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
41,500 | public function dontSeeBinaryResponseEquals ( $ hash , $ algo = 'md5' ) { $ responseHash = hash ( $ algo , $ this -> connectionModule -> _getResponseContent ( ) ) ; $ this -> assertNotEquals ( $ hash , $ responseHash ) ; } | Checks if the hash of a binary response is not the same as provided . |
41,501 | protected function onReconfigure ( ) { parent :: onReconfigure ( ) ; $ this -> client -> resetApplication ( ) ; $ this -> configureClient ( $ this -> config ) ; $ this -> client -> startApp ( ) ; } | Module configuration changed inside a test . We always re - create the application . |
41,502 | protected function recreateClient ( ) { $ entryUrl = $ this -> config [ 'entryUrl' ] ; $ entryFile = $ this -> config [ 'entryScript' ] ? : basename ( $ entryUrl ) ; $ entryScript = $ this -> config [ 'entryScript' ] ? : parse_url ( $ entryUrl , PHP_URL_PATH ) ; $ this -> client = new Yii2Connector ( [ 'SCRIPT_FILENAME... | Instantiates the client based on module configuration |
41,503 | private function loadFixtures ( $ test ) { $ this -> debugSection ( 'Fixtures' , 'Loading fixtures' ) ; if ( empty ( $ this -> loadedFixtures ) && method_exists ( $ test , $ this -> _getConfig ( 'fixturesMethod' ) ) ) { $ connectionWatcher = new Yii2Connector \ ConnectionWatcher ( ) ; $ connectionWatcher -> start ( ) ;... | load fixtures before db transaction |
41,504 | public function amLoggedInAs ( $ user ) { try { $ this -> client -> findAndLoginUser ( $ user ) ; } catch ( ConfigurationException $ e ) { throw new ModuleException ( $ this , $ e -> getMessage ( ) ) ; } catch ( \ RuntimeException $ e ) { throw new ModuleException ( $ this , $ e -> getMessage ( ) ) ; } } | Authorizes user on a site without submitting login form . Use it for fast pragmatic authorization in functional tests . |
41,505 | public function seeRecord ( $ model , $ attributes = [ ] ) { $ record = $ this -> findRecord ( $ model , $ attributes ) ; if ( ! $ record ) { $ this -> fail ( "Couldn't find $model with " . json_encode ( $ attributes ) ) ; } $ this -> debugSection ( $ model , json_encode ( $ record ) ) ; } | Checks that record exists in database . |
41,506 | public function grabComponent ( $ component ) { try { return $ this -> client -> getComponent ( $ component ) ; } catch ( ConfigurationException $ e ) { throw new ModuleException ( $ this , $ e -> getMessage ( ) ) ; } } | Gets a component from Yii container . Throws exception if component is not available |
41,507 | public function seeEmailIsSent ( $ num = null ) { if ( $ num === null ) { $ this -> assertNotEmpty ( $ this -> grabSentEmails ( ) , 'emails were sent' ) ; return ; } $ this -> assertEquals ( $ num , count ( $ this -> grabSentEmails ( ) ) , 'number of sent emails is equal to ' . $ num ) ; } | Checks that email is sent . |
41,508 | public function setCookie ( $ name , $ val , array $ params = [ ] ) { parent :: setCookie ( $ name , $ this -> client -> hashCookieData ( $ name , $ val ) , $ params ) ; } | Sets a cookie and if validation is enabled signs it . |
41,509 | public function createAndSetCsrfCookie ( $ val ) { $ masked = $ this -> client -> maskToken ( $ val ) ; $ name = $ this -> client -> getCsrfParamName ( ) ; $ this -> setCookie ( $ name , $ val ) ; return [ $ name , $ masked ] ; } | This function creates the CSRF Cookie . |
41,510 | private function getRouteByName ( $ routeName ) { if ( isset ( $ this -> app -> router ) && $ this -> app -> router instanceof \ Laravel \ Lumen \ Routing \ Router ) { $ router = $ this -> app -> router ; } else { $ router = $ this -> app ; } foreach ( $ router -> getRoutes ( ) as $ route ) { if ( isset ( $ route [ 'ac... | Get the route for a route name . |
41,511 | public function amLoggedAs ( $ user , $ driver = null ) { if ( ! $ user instanceof Authenticatable ) { $ this -> fail ( 'The user passed to amLoggedAs() should be an instance of \\Illuminate\\Contracts\\Auth\\Authenticatable' ) ; } $ guard = $ auth = $ this -> app [ 'auth' ] ; if ( method_exists ( $ auth , 'driver' ) )... | Set the authenticated user for the next request . This will not persist between multiple requests . |
41,512 | public function seeRecord ( $ table , $ attributes = [ ] ) { if ( class_exists ( $ table ) ) { if ( ! $ this -> findModel ( $ table , $ attributes ) ) { $ this -> fail ( "Could not find $table with " . json_encode ( $ attributes ) ) ; } } elseif ( ! $ this -> findRecord ( $ table , $ attributes ) ) { $ this -> fail ( "... | Checks that record exists in database . You can pass the name of a database table or the class name of an Eloquent model as the first argument . |
41,513 | public function have ( $ model , $ attributes = [ ] , $ name = 'default' ) { try { return $ this -> modelFactory ( $ model , $ name ) -> create ( $ attributes ) ; } catch ( \ Exception $ e ) { $ this -> fail ( "Could not create model: \n\n" . get_class ( $ e ) . "\n\n" . $ e -> getMessage ( ) ) ; } } | Use Lumen s model factory to create a model . Can only be used with Lumen 5 . 1 and later . |
41,514 | protected function mergeOptions ( $ options ) { $ config = Configuration :: config ( ) ; $ baseOptions = array_merge ( $ this -> options , $ config [ 'settings' ] ) ; return array_merge ( $ baseOptions , $ options ) ; } | Merges given options with default values and current configuration |
41,515 | public function findAndLoginUser ( $ user ) { $ app = $ this -> getApplication ( ) ; if ( ! $ app -> has ( 'user' ) ) { throw new ConfigurationException ( 'The user component is not configured' ) ; } if ( $ user instanceof \ yii \ web \ IdentityInterface ) { $ identity = $ user ; } else { $ identityClass = $ app -> use... | Finds and logs in a user |
41,516 | private function getDomainRegex ( $ template ) { if ( preg_match ( '#https?://(.*)#' , $ template , $ matches ) ) { $ template = $ matches [ 1 ] ; } $ parameters = [ ] ; if ( strpos ( $ template , '<' ) !== false ) { $ template = preg_replace_callback ( '/<(?:\w+):?([^>]+)?>/u' , function ( $ matches ) use ( & $ parame... | Getting domain regex from rule host template |
41,517 | protected function encodeCookies ( YiiResponse $ response , Request $ request , Security $ security ) { if ( $ request -> enableCookieValidation ) { $ validationKey = $ request -> cookieValidationKey ; } foreach ( $ response -> getCookies ( ) as $ cookie ) { $ value = $ cookie -> value ; if ( $ cookie -> expire != 1 &&... | Encodes the cookies and adds them to the headers . |
41,518 | protected function mockMailer ( array $ config ) { $ allowedOptions = [ 'htmlLayout' , 'textLayout' , 'messageConfig' , 'messageClass' , 'useFileTransport' , 'fileTransportPath' , 'fileTransportCallback' , 'view' , 'viewPath' , ] ; $ mailerConfig = [ 'class' => TestMailer :: class , 'callback' => function ( MessageInte... | Replace mailer with in memory mailer |
41,519 | public function closeSession ( ) { if ( isset ( \ Yii :: $ app ) && \ Yii :: $ app -> has ( 'session' , true ) ) { \ Yii :: $ app -> session -> close ( ) ; } } | This functions closes the session of the application if the application exists and has a session . |
41,520 | protected function resetResponse ( Application $ app ) { $ method = $ this -> responseCleanMethod ; if ( ( $ app -> response -> hasEventHandlers ( \ yii \ web \ Response :: EVENT_BEFORE_SEND ) || $ app -> response -> hasEventHandlers ( \ yii \ web \ Response :: EVENT_AFTER_SEND ) || $ app -> response -> hasEventHandler... | Resets the applications response object . The method used depends on the module configuration . |
41,521 | protected function beforeRequest ( ) { if ( $ this -> recreateApplication ) { $ this -> resetApplication ( ) ; return ; } $ application = $ this -> getApplication ( ) ; $ this -> resetResponse ( $ application ) ; $ this -> resetRequest ( $ application ) ; $ definitions = $ application -> getComponents ( true ) ; foreac... | Called before each request preparation happens here . |
41,522 | public function getApplication ( ) { $ application = $ this -> application ; if ( $ application instanceof Closure ) { return $ application ( ) ; } elseif ( is_string ( $ application ) ) { return require $ application ; } return $ application ; } | Get Phalcon Application |
41,523 | public function _setConfig ( $ config ) { $ this -> config = $ this -> backupConfig = array_merge ( $ this -> config , $ config ) ; $ this -> validateConfig ( ) ; } | Allows to define initial module config . Can be used in _beforeSuite hook of Helpers or Extensions |
41,524 | public function _reconfigure ( $ config ) { $ this -> config = array_merge ( $ this -> backupConfig , $ config ) ; $ this -> onReconfigure ( ) ; $ this -> validateConfig ( ) ; } | Allows to redefine config for a specific test . Config is restored at the end of a test . |
41,525 | protected function validateConfig ( ) { $ fields = array_keys ( $ this -> config ) ; if ( array_intersect ( $ this -> requiredFields , $ fields ) != $ this -> requiredFields ) { throw new Exception \ ModuleConfigException ( get_class ( $ this ) , "\nOptions: " . implode ( ', ' , $ this -> requiredFields ) . " are requi... | Validates current config for required fields and required packages . |
41,526 | public function _getName ( ) { $ moduleName = '\\' . get_class ( $ this ) ; if ( strpos ( $ moduleName , ModuleContainer :: MODULE_NAMESPACE ) === 0 ) { return substr ( $ moduleName , strlen ( ModuleContainer :: MODULE_NAMESPACE ) ) ; } return $ moduleName ; } | Returns a module name for a Module a class name for Helper |
41,527 | protected function debugSection ( $ title , $ message ) { if ( is_array ( $ message ) or is_object ( $ message ) ) { $ message = stripslashes ( json_encode ( $ message ) ) ; } $ this -> debug ( "[$title] $message" ) ; } | Print debug message with a title |
41,528 | public function create ( $ moduleName , $ active = true ) { $ this -> active [ $ moduleName ] = $ active ; $ moduleClass = $ this -> getModuleClass ( $ moduleName ) ; if ( ! class_exists ( $ moduleClass ) ) { throw new ConfigurationException ( "Module $moduleName could not be found and loaded" ) ; } $ config = $ this -... | Create a module . |
41,529 | private function getActionsForModule ( $ module , $ config ) { $ reflectionClass = new \ ReflectionClass ( $ module ) ; $ methods = $ reflectionClass -> getMethods ( \ ReflectionMethod :: IS_PUBLIC ) ; $ configuredParts = null ; if ( $ module instanceof PartedModule && isset ( $ config [ 'part' ] ) ) { $ configuredPart... | Get the actions of a module . |
41,530 | private function includeMethodAsAction ( $ module , $ method , $ configuredParts = null ) { if ( $ module :: $ excludeActions && in_array ( $ method -> name , $ module :: $ excludeActions ) ) { return false ; } if ( $ module :: $ onlyActions && ! in_array ( $ method -> name , $ module :: $ onlyActions ) ) { return fals... | Should a method be included as an action? |
41,531 | public function getModule ( $ moduleName ) { if ( ! $ this -> hasModule ( $ moduleName ) ) { throw new ModuleException ( __CLASS__ , "Module $moduleName couldn't be connected" ) ; } return $ this -> modules [ $ moduleName ] ; } | Get a module from this ModuleContainer . |
41,532 | public function moduleForAction ( $ action ) { if ( ! isset ( $ this -> actions [ $ action ] ) ) { return null ; } return $ this -> modules [ $ this -> actions [ $ action ] ] ; } | Get the module for an action . |
41,533 | private function injectModuleDependencies ( $ moduleName , DependsOnModule $ module ) { $ this -> checkForMissingDependencies ( $ moduleName , $ module ) ; if ( ! method_exists ( $ module , '_inject' ) ) { throw new ModuleException ( $ module , 'Module requires method _inject to be defined to accept dependencies' ) ; }... | Inject the dependencies of a module . |
41,534 | private function checkForMissingDependencies ( $ moduleName , DependsOnModule $ module ) { $ dependencies = $ this -> getModuleDependencies ( $ module ) ; $ configuredDependenciesCount = count ( $ this -> getConfiguredDependencies ( $ moduleName ) ) ; if ( $ configuredDependenciesCount < count ( $ dependencies ) ) { $ ... | Check for missing dependencies . |
41,535 | private function getModuleDependencies ( DependsOnModule $ module ) { $ depends = $ module -> _depends ( ) ; if ( ! $ depends ) { return [ ] ; } if ( ! is_array ( $ depends ) ) { $ message = sprintf ( "Method _depends of module '%s' must return an array" , get_class ( $ module ) ) ; throw new ModuleException ( $ module... | Get the dependencies of a module . |
41,536 | private function getConfiguredDependencies ( $ moduleName ) { $ config = $ this -> getModuleConfig ( $ moduleName ) ; if ( ! isset ( $ config [ 'depends' ] ) ) { return [ ] ; } return is_array ( $ config [ 'depends' ] ) ? $ config [ 'depends' ] : [ $ config [ 'depends' ] ] ; } | Get the configured dependencies for a module . |
41,537 | private function getModuleConfig ( $ moduleName ) { $ config = isset ( $ this -> config [ 'modules' ] [ 'config' ] [ $ moduleName ] ) ? $ this -> config [ 'modules' ] [ 'config' ] [ $ moduleName ] : [ ] ; if ( ! isset ( $ this -> config [ 'modules' ] [ 'enabled' ] ) ) { return $ config ; } if ( ! is_array ( $ this -> c... | Get the configuration for a module . |
41,538 | public function validateConflicts ( ) { $ canConflict = [ ] ; foreach ( $ this -> modules as $ moduleName => $ module ) { $ parted = $ module instanceof PartedModule && $ module -> _getConfig ( 'part' ) ; if ( $ this -> active [ $ moduleName ] && ! $ parted ) { $ canConflict [ ] = $ module ; } } foreach ( $ canConflict... | Check if there are conflicting modules in this ModuleContainer . |
41,539 | private function validateConflict ( $ module , $ otherModule ) { if ( $ module === $ otherModule || ! $ module instanceof ConflictsWithModule ) { return ; } $ conflicts = $ this -> normalizeConflictSpecification ( $ module -> _conflicts ( ) ) ; if ( $ otherModule instanceof $ conflicts ) { throw new ModuleConflictExcep... | Check if the modules passed as arguments to this method conflict with each other . |
41,540 | public function amConnectedToDatabase ( $ databaseKey ) { if ( empty ( $ this -> getDatabases ( ) [ $ databaseKey ] ) && $ databaseKey != self :: DEFAULT_DATABASE ) { throw new ModuleConfigException ( __CLASS__ , "\nNo database $databaseKey in the key databases.\n" ) ; } $ this -> currentDatabase = $ databaseKey ; } | Make sure you are connected to the right database . |
41,541 | public function performInDatabase ( $ databaseKey , $ actions ) { $ backupDatabase = $ this -> currentDatabase ; $ this -> amConnectedToDatabase ( $ databaseKey ) ; if ( is_callable ( $ actions ) ) { $ actions ( $ this ) ; $ this -> amConnectedToDatabase ( $ backupDatabase ) ; return ; } if ( is_array ( $ actions ) ) {... | Can be used with a callback if you don t want to change the current database in your test . |
41,542 | public function haveInDatabase ( $ table , array $ data ) { $ lastInsertId = $ this -> _insertInDatabase ( $ table , $ data ) ; $ this -> addInsertedRow ( $ table , $ data , $ lastInsertId ) ; return $ lastInsertId ; } | Inserts an SQL record into a database . This record will be erased after the test . |
41,543 | public function seeNumRecords ( $ expectedNumber , $ table , array $ criteria = [ ] ) { $ actualNumber = $ this -> countInDatabase ( $ table , $ criteria ) ; $ this -> assertEquals ( $ expectedNumber , $ actualNumber , sprintf ( 'The number of found rows (%d) does not match expected number %d for criteria %s in table %... | Asserts that the given number of records were found in the database . |
41,544 | public function updateInDatabase ( $ table , array $ data , array $ criteria = [ ] ) { $ query = $ this -> _getDriver ( ) -> update ( $ table , $ data , $ criteria ) ; $ parameters = array_merge ( array_values ( $ data ) , array_values ( $ criteria ) ) ; $ this -> debugSection ( 'Query' , $ query ) ; if ( ! empty ( $ p... | Update an SQL record into a database . |
41,545 | public function _after ( TestInterface $ test ) { if ( empty ( $ this -> memcache ) ) { return ; } $ this -> memcache -> flush ( ) ; switch ( get_class ( $ this -> memcache ) ) { case 'Memcache' : $ this -> memcache -> close ( ) ; break ; case 'Memcached' : $ this -> memcache -> quit ( ) ; break ; } } | Code to run after each test . |
41,546 | public function grabValueFromMemcached ( $ key ) { $ value = $ this -> memcache -> get ( $ key ) ; $ this -> debugSection ( "Value" , $ value ) ; return $ value ; } | Grabs value from memcached by key . |
41,547 | public function seeInMemcached ( $ key , $ value = null ) { $ actual = $ this -> memcache -> get ( $ key ) ; $ this -> debugSection ( "Value" , $ actual ) ; if ( null === $ value ) { $ this -> assertNotFalse ( $ actual , "Cannot find key '$key' in Memcached" ) ; } else { $ this -> assertEquals ( $ value , $ actual , "C... | Checks item in Memcached exists and the same as expected . |
41,548 | public function dontSeeInMemcached ( $ key , $ value = null ) { $ actual = $ this -> memcache -> get ( $ key ) ; $ this -> debugSection ( "Value" , $ actual ) ; if ( null === $ value ) { $ this -> assertFalse ( $ actual , "The key '$key' exists in Memcached" ) ; } else { if ( false !== $ actual ) { $ this -> assertEqua... | Checks item in Memcached doesn t exist or is the same as expected . |
41,549 | public function setHeader ( $ name , $ value ) { if ( strval ( $ value ) === '' ) { $ this -> deleteHeader ( $ name ) ; } else { $ this -> requestOptions [ 'headers' ] [ $ name ] = $ value ; } } | Sets the request header to the passed value . The header will be sent along with the next request . |
41,550 | public function _after ( TestInterface $ test ) { $ this -> _closeConnection ( ) ; if ( $ this -> config [ 'cleanup' ] ) { if ( file_exists ( $ this -> config [ 'tmp' ] . '/ftp_data_file.tmp' ) ) { unlink ( $ this -> config [ 'tmp' ] . '/ftp_data_file.tmp' ) ; } } } | Close the FTP connection & Clear up |
41,551 | public function amInPath ( $ path ) { $ this -> _changeDirectory ( $ this -> path = $ this -> absolutizePath ( $ path ) . ( $ path == '/' ? '' : DIRECTORY_SEPARATOR ) ) ; $ this -> debug ( 'Moved to ' . $ this -> path ) ; } | Enters a directory on the ftp system - FTP root directory is used by default |
41,552 | private function _openFile ( $ filename ) { if ( ! is_dir ( $ this -> config [ 'tmp' ] ) || ! is_writeable ( $ this -> config [ 'tmp' ] ) ) { $ this -> fail ( 'tmp directory not found or is not writable' ) ; } $ tmp_file = $ this -> config [ 'tmp' ] . "/ftp_data_file.tmp" ; if ( $ this -> isSFTP ( ) ) { $ downloaded = ... | Download remote file to local tmp directory and open contents . |
41,553 | private function _writeToFile ( $ filename , $ contents ) { if ( ! is_dir ( $ this -> config [ 'tmp' ] ) || ! is_writeable ( $ this -> config [ 'tmp' ] ) ) { $ this -> fail ( 'tmp directory not found or is not writable' ) ; } $ tmp_file = $ this -> config [ 'tmp' ] . "/ftp_data_file.tmp" ; file_put_contents ( $ tmp_fil... | Write data to local tmp file and upload to server |
41,554 | private function makeDirectory ( $ path ) { if ( $ this -> isSFTP ( ) ) { $ created = @ $ this -> ftp -> mkdir ( $ path , true ) ; } else { $ created = @ ftp_mkdir ( $ this -> ftp , $ path ) ; } if ( ! $ created ) { $ this -> fail ( "couldn't make directory {$path}" ) ; } $ this -> debug ( "Make directory: {$path}" ) ;... | Make new directory on server |
41,555 | private function delete ( $ filename , $ isDir = false ) { if ( $ this -> isSFTP ( ) ) { $ deleted = @ $ this -> ftp -> delete ( $ filename , $ isDir ) ; } else { $ deleted = @ $ this -> ftpDelete ( $ filename ) ; } if ( ! $ deleted ) { $ this -> fail ( "couldn't delete {$filename}" ) ; } $ this -> debug ( "Deleted: {$... | Delete file on server |
41,556 | private function ftpDelete ( $ directory ) { if ( ! ( @ ftp_rmdir ( $ this -> ftp , $ directory ) || @ ftp_delete ( $ this -> ftp , $ directory ) ) ) { $ filelist = @ ftp_nlist ( $ this -> ftp , $ directory ) ; foreach ( $ filelist as $ file ) { $ this -> ftpDelete ( $ file ) ; } $ this -> ftpDelete ( $ directory ) ; }... | Function to recursively delete folder used for PHP FTP build in client . |
41,557 | private function clearDirectory ( $ path ) { $ this -> debug ( "Clear directory: {$path}" ) ; $ this -> delete ( $ path ) ; $ this -> makeDirectory ( $ path ) ; } | Clear directory on server of all content |
41,558 | private function size ( $ filename ) { if ( $ this -> isSFTP ( ) ) { $ size = ( int ) @ $ this -> ftp -> size ( $ filename ) ; } else { $ size = @ ftp_size ( $ this -> ftp , $ filename ) ; } if ( $ size > 0 ) { return $ size ; } $ this -> fail ( "couldn't get the file size for {$filename}" ) ; } | Return the size of a given file |
41,559 | private function modified ( $ filename ) { if ( $ this -> isSFTP ( ) ) { $ info = @ $ this -> ftp -> lstat ( $ filename ) ; if ( $ info ) { return $ info [ 'mtime' ] ; } } else { if ( $ time = @ ftp_mdtm ( $ this -> ftp , $ filename ) ) { return $ time ; } } $ this -> fail ( "couldn't get the file size for {$filename}"... | Return the last modified time of a given file |
41,560 | protected function setupMongoDB ( $ dsn , $ options ) { try { $ this -> client = new \ MongoDB \ Client ( $ dsn , $ options ) ; $ this -> dbh = $ this -> client -> selectDatabase ( $ this -> dbName ) ; } catch ( \ MongoDB \ Driver \ Exception $ e ) { throw new ModuleException ( $ this , sprintf ( 'Failed to open Mongo ... | Connect to the Mongo server using the MongoDB extension . |
41,561 | protected function setupMongo ( $ dsn , $ options ) { try { $ this -> client = new \ MongoClient ( $ dsn , $ options ) ; $ this -> dbh = $ this -> client -> selectDB ( $ this -> dbName ) ; } catch ( \ MongoConnectionException $ e ) { throw new ModuleException ( $ this , sprintf ( 'Failed to open Mongo connection: %s' ,... | Connect to the Mongo server using the legacy mongo extension . |
41,562 | protected function cleanupMongoDB ( ) { try { $ this -> dbh -> drop ( ) ; } catch ( \ MongoDB \ Driver \ Exception $ e ) { throw new \ Exception ( sprintf ( 'Failed to drop the DB: %s' , $ e -> getMessage ( ) ) ) ; } } | Clean up the Mongo database using the MongoDB extension . |
41,563 | protected function cleanupMongo ( ) { try { $ list = $ this -> dbh -> listCollections ( ) ; } catch ( \ MongoException $ e ) { throw new \ Exception ( sprintf ( 'Failed to list collections of the DB: %s' , $ e -> getMessage ( ) ) ) ; } foreach ( $ list as $ collection ) { try { $ collection -> drop ( ) ; } catch ( \ Mo... | Clean up the Mongo database using the legacy Mongo extension . |
41,564 | public function haveMultiple ( $ name , $ times , array $ extraAttrs = [ ] ) { return $ this -> factoryMuffin -> seed ( $ times , $ name , $ extraAttrs ) ; } | Generates and saves a record multiple times . |
41,565 | public function load ( $ sql ) { $ query = '' ; $ delimiter = ';' ; $ delimiterLength = 1 ; $ dollarsOpen = false ; foreach ( $ sql as $ sqlLine ) { if ( preg_match ( '/DELIMITER ([\;\$\|\\\\]+)/i' , $ sqlLine , $ match ) ) { $ delimiter = $ match [ 1 ] ; $ delimiterLength = strlen ( $ delimiter ) ; continue ; } $ pars... | Loads a SQL file . |
41,566 | public function lastInsertId ( $ table ) { $ sequenceName = $ this -> getQuotedName ( $ table . '_id_seq' ) ; $ lastSequence = null ; try { $ lastSequence = $ this -> getDbh ( ) -> lastInsertId ( $ sequenceName ) ; } catch ( \ PDOException $ e ) { } if ( ! $ lastSequence ) { $ primaryKeys = $ this -> getPrimaryKey ( $ ... | Get the last inserted ID of table . |
41,567 | public static function fetchAnnotationsFromDocblock ( $ annotation , $ docblock ) { if ( preg_match_all ( sprintf ( self :: $ regex , $ annotation ) , $ docblock , $ matched ) ) { return $ matched [ 1 ] ; } return [ ] ; } | Parses raw comment for annotations |
41,568 | public static function fetchAllAnnotationsFromDocblock ( $ docblock ) { $ annotations = [ ] ; if ( ! preg_match_all ( sprintf ( self :: $ regex , '(\w+)' ) , $ docblock , $ matched ) ) { return $ annotations ; } foreach ( $ matched [ 1 ] as $ k => $ annotation ) { if ( ! isset ( $ annotations [ $ annotation ] ) ) { $ a... | Fetches all available annotations |
41,569 | public static function arrayValue ( $ annotation ) { $ annotation = trim ( $ annotation ) ; $ openingBrace = substr ( $ annotation , 0 , 1 ) ; if ( in_array ( $ openingBrace , [ '{' , '[' ] ) ) { return json_decode ( $ annotation , true ) ; } if ( $ openingBrace === '(' ) { preg_match_all ( '~(\w+)\s*?=\s*?"(.*?)"\s*?[... | Returns an associative array value of annotation Either JSON or Doctrine - annotation style allowed Returns null if not a valid array data |
41,570 | public function _initialize ( ) { try { $ this -> driver = new RedisDriver ( [ 'host' => $ this -> config [ 'host' ] , 'port' => $ this -> config [ 'port' ] , 'database' => $ this -> config [ 'database' ] ] ) ; } catch ( \ Exception $ e ) { throw new ModuleException ( __CLASS__ , $ e -> getMessage ( ) ) ; } } | Instructions to run after configuration is loaded |
41,571 | public function cleanup ( ) { try { $ this -> driver -> flushdb ( ) ; } catch ( \ Exception $ e ) { throw new ModuleException ( __CLASS__ , $ e -> getMessage ( ) ) ; } } | Delete all the keys in the Redis database |
41,572 | public function grabFromRedis ( $ key ) { $ args = func_get_args ( ) ; switch ( $ this -> driver -> type ( $ key ) ) { case 'none' : throw new ModuleException ( $ this , "Cannot grab key \"$key\" as it does not exist" ) ; break ; case 'string' : $ reply = $ this -> driver -> get ( $ key ) ; break ; case 'list' : if ( c... | Returns the value of a given key |
41,573 | public function haveInRedis ( $ type , $ key , $ value ) { switch ( strtolower ( $ type ) ) { case 'string' : if ( ! is_scalar ( $ value ) ) { throw new ModuleException ( $ this , 'If second argument of haveInRedis() method is "string", ' . 'third argument must be a scalar' ) ; } $ this -> driver -> set ( $ key , $ val... | Creates or modifies keys |
41,574 | public function dontSeeRedisKeyContains ( $ key , $ item , $ itemValue = null ) { $ this -> assertFalse ( ( bool ) $ this -> checkKeyContains ( $ key , $ item , $ itemValue ) , "The key \"$key\" contains " . ( is_null ( $ itemValue ) ? "\"$item\"" : "[\"$item\" => \"$itemValue\"]" ) ) ; } | Asserts that a given key does not contain a given item |
41,575 | public function seeRedisKeyContains ( $ key , $ item , $ itemValue = null ) { $ this -> assertTrue ( ( bool ) $ this -> checkKeyContains ( $ key , $ item , $ itemValue ) , "The key \"$key\" does not contain " . ( is_null ( $ itemValue ) ? "\"$item\"" : "[\"$item\" => \"$itemValue\"]" ) ) ; } | Asserts that a given key contains a given item |
41,576 | private function boolToString ( $ var ) { $ copy = is_array ( $ var ) ? $ var : [ $ var ] ; foreach ( $ copy as $ key => $ value ) { if ( is_bool ( $ value ) ) { $ copy [ $ key ] = $ value ? '1' : '0' ; } } return is_array ( $ var ) ? $ copy : $ copy [ 0 ] ; } | Converts boolean values to 0 and 1 |
41,577 | private function checkKeyContains ( $ key , $ item , $ itemValue = null ) { $ result = null ; if ( ! is_scalar ( $ item ) ) { throw new ModuleException ( $ this , "All arguments of [dont]seeRedisKeyContains() must be scalars" ) ; } switch ( $ this -> driver -> type ( $ key ) ) { case 'string' : $ reply = $ this -> driv... | Checks whether a key contains a given item |
41,578 | private function initialize ( $ request = null ) { $ this -> oldDb = null ; if ( isset ( $ this -> app [ 'db' ] ) && $ this -> app [ 'db' ] -> connection ( ) ) { $ this -> oldDb = $ this -> app [ 'db' ] ; } $ this -> app = $ this -> kernel = $ this -> loadApplication ( ) ; if ( is_null ( $ request ) ) { $ appConfig = r... | Initialize the Laravel framework . |
41,579 | private function loadApplication ( ) { $ app = require $ this -> module -> config [ 'bootstrap_file' ] ; $ app -> loadEnvironmentFrom ( $ this -> module -> config [ 'environment_file' ] ) ; $ app -> instance ( 'request' , new Request ( ) ) ; return $ app ; } | Boot the Laravel application object . |
41,580 | private function mockEventDispatcher ( ) { $ callback = function ( $ event ) { $ this -> triggeredEvents [ ] = $ this -> normalizeEvent ( $ event ) ; return [ ] ; } ; $ method = method_exists ( $ this -> app [ 'events' ] , 'dispatch' ) ? 'dispatch' : 'fire' ; $ mock = Stub :: makeEmpty ( 'Illuminate\Contracts\Events\Di... | Replace the Laravel event dispatcher with a mock . |
41,581 | private function normalizeEvent ( $ event ) { if ( is_object ( $ event ) ) { $ event = get_class ( $ event ) ; } if ( preg_match ( '/^bootstrapp(ing|ed): /' , $ event ) ) { return $ event ; } $ segments = explode ( ':' , $ event ) ; return $ segments [ 0 ] ; } | Normalize events to class names . |
41,582 | public function eventTriggered ( $ event ) { $ event = $ this -> normalizeEvent ( $ event ) ; foreach ( $ this -> triggeredEvents as $ triggeredEvent ) { if ( $ event == $ triggeredEvent || is_subclass_of ( $ event , $ triggeredEvent ) ) { return true ; } } return false ; } | Did an event trigger? |
41,583 | private function phpEncodeValue ( $ value ) { if ( is_array ( $ value ) ) { return $ this -> phpEncodeArray ( $ value ) ; } if ( is_string ( $ value ) ) { return json_encode ( $ value ) ; } return var_export ( $ value , true ) ; } | PHP encoded a value |
41,584 | private function phpEncodeArray ( array $ array ) { $ isPlainArray = function ( array $ value ) { return ( ( count ( $ value ) === 0 ) || ( ( array_keys ( $ value ) === range ( 0 , count ( $ value ) - 1 ) ) && ( 0 === count ( array_filter ( array_keys ( $ value ) , 'is_string' ) ) ) ) ) ; } ; if ( $ isPlainArray ( $ ar... | Recursively PHP encode an array |
41,585 | public function initDir ( $ workDir ) { $ this -> checkInstalled ( $ workDir ) ; $ this -> sayInfo ( "Initializing Codeception in $workDir" ) ; $ this -> createDirectoryFor ( $ workDir ) ; chdir ( $ workDir ) ; $ this -> workDir = $ workDir ; } | Change the directory where Codeception should be installed . |
41,586 | protected function createHelper ( $ name , $ directory ) { $ file = $ this -> createDirectoryFor ( $ dir = $ directory . DIRECTORY_SEPARATOR . "Helper" , "$name.php" ) . "$name.php" ; $ gen = new Lib \ Generator \ Helper ( $ name , $ this -> namespace ) ; $ this -> createFile ( $ file , $ gen -> produce ( ) ) ; require... | Create a helper class inside a directory |
41,587 | protected function createActor ( $ name , $ directory , $ suiteConfig ) { $ file = $ this -> createDirectoryFor ( $ directory , $ name ) . $ this -> getShortClassName ( $ name ) ; $ file .= '.php' ; $ suiteConfig [ 'namespace' ] = $ this -> namespace ; $ config = Configuration :: mergeConfigs ( Configuration :: $ defau... | Create an Actor class and generate actions for it . Requires a suite config as array in 3rd parameter . |
41,588 | public function amInPath ( $ path ) { chdir ( $ this -> path = $ this -> absolutizePath ( $ path ) . DIRECTORY_SEPARATOR ) ; $ this -> debug ( 'Moved to ' . getcwd ( ) ) ; } | Enters a directory In local filesystem . Project root directory is used by default |
41,589 | public function openFile ( $ filename ) { $ this -> file = file_get_contents ( $ this -> absolutizePath ( $ filename ) ) ; $ this -> filepath = $ filename ; } | Opens a file and stores it s content . |
41,590 | public function deleteFile ( $ filename ) { if ( ! file_exists ( $ this -> absolutizePath ( $ filename ) ) ) { \ PHPUnit \ Framework \ Assert :: fail ( 'file not found' ) ; } unlink ( $ this -> absolutizePath ( $ filename ) ) ; } | Deletes a file |
41,591 | public function seeNumberNewLines ( $ number ) { $ lines = preg_split ( '/\n|\r/' , $ this -> file ) ; $ this -> assertTrue ( ( int ) $ number === count ( $ lines ) , "The number of new lines does not match with $number" ) ; } | Checks If opened file has the number of new lines . |
41,592 | public function seeFileContentsEqual ( $ text ) { $ file = str_replace ( "\r" , '' , $ this -> file ) ; \ PHPUnit \ Framework \ Assert :: assertEquals ( $ text , $ file ) ; } | Checks the strict matching of file contents . Unlike seeInThisFile will fail if file has something more than expected lines . Better to use with HEREDOC strings . Matching is done after removing \ r chars from file content . |
41,593 | public function seeFileFound ( $ filename , $ path = '' ) { if ( $ path === '' && file_exists ( $ filename ) ) { $ this -> openFile ( $ filename ) ; \ PHPUnit \ Framework \ Assert :: assertFileExists ( $ filename ) ; return ; } $ found = $ this -> findFileInPath ( $ filename , $ path ) ; if ( $ found === false ) { $ th... | Checks if file exists in path . Opens a file when it s exists |
41,594 | public function dontSeeFileFound ( $ filename , $ path = '' ) { if ( $ path === '' ) { \ PHPUnit \ Framework \ Assert :: assertFileNotExists ( $ filename ) ; return ; } $ found = $ this -> findFileInPath ( $ filename , $ path ) ; if ( $ found === false ) { \ PHPUnit \ Framework \ Assert :: assertTrue ( true ) ; return ... | Checks if file does not exist in path |
41,595 | private function findFileInPath ( $ filename , $ path ) { $ path = $ this -> absolutizePath ( $ path ) ; if ( ! file_exists ( $ path ) ) { $ this -> fail ( "Directory does not exist: $path" ) ; } $ files = Finder :: create ( ) -> files ( ) -> name ( $ filename ) -> in ( $ path ) ; if ( $ files -> count ( ) === 0 ) { re... | Finds the first matching file |
41,596 | protected function validateConfig ( ) { $ this -> queueDriver = $ this -> createQueueDriver ( ) ; $ this -> requiredFields = $ this -> queueDriver -> getRequiredConfig ( ) ; $ this -> config = array_merge ( $ this -> queueDriver -> getDefaultConfig ( ) , $ this -> config ) ; parent :: validateConfig ( ) ; } | Provide and override for the config settings and allow custom settings depending on the service being used . |
41,597 | private function applyBindings ( ) { foreach ( $ this -> bindings as $ abstract => $ binding ) { list ( $ concrete , $ shared ) = $ binding ; $ this -> app -> bind ( $ abstract , $ concrete , $ shared ) ; } } | Apply the registered Laravel service container bindings . |
41,598 | private function applyContextualBindings ( ) { foreach ( $ this -> contextualBindings as $ concrete => $ bindings ) { foreach ( $ bindings as $ abstract => $ implementation ) { $ this -> app -> addContextualBinding ( $ concrete , $ abstract , $ implementation ) ; } } } | Apply the registered Laravel service container contextual bindings . |
41,599 | public function haveContextualBinding ( $ concrete , $ abstract , $ implementation ) { if ( ! isset ( $ this -> contextualBindings [ $ concrete ] ) ) { $ this -> contextualBindings [ $ concrete ] = [ ] ; } $ this -> contextualBindings [ $ concrete ] [ $ abstract ] = $ implementation ; } | Register a Laravel service container contextual binding that should be applied after initializing the Laravel Application object . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.