How to use getScriptFile method of stub class

Best Atoum code snippet using stub.getScriptFile

stub.php

Source:stub.php Github

copy

Full Screen

...34 return $this->stopRun();35 }36 public function useScript($script)37 {38 $scriptFile = self::getScriptFile($script);39 if (file_exists($scriptFile) === false)40 {41 throw new exceptions\logic\invalidArgument(sprintf($this->getLocale()->_('Script %s does not exist'), $script));42 }43 require_once $scriptFile;44 exit(0);45 }46 public function infos()47 {48 $phar = call_user_func($this->pharFactory, $this->getName());49 $this->writeLabels($phar->getMetadata());50 return $this->stopRun();51 }52 public function signature()53 {54 $phar = call_user_func($this->pharFactory, $this->getName());55 $signature = $phar->getSignature();56 $this->writeLabel($this->locale->_('Signature'), $signature['hash']);57 return $this->stopRun();58 }59 public function extractTo($directory)60 {61 if (($versions = $this->getVersions($phar = call_user_func($this->pharFactory, $this->getName()))) === null)62 {63 throw new exceptions\runtime('Unable to extract the PHAR to \'' . $directory . '\', the versions\'s file is invalid');64 }65 $directory = rtrim($directory, DIRECTORY_SEPARATOR);66 $pharName = \phar::running();67 foreach (new \recursiveIteratorIterator($phar) as $pharFile)68 {69 $pharFilePath = ltrim(str_replace($pharName, '', $pharFile), DIRECTORY_SEPARATOR);70 if (strpos($pharFilePath, $versions['current']) === 0)71 {72 $path = $directory . '/' . ltrim(substr($pharFilePath, strlen($versions['current'])), DIRECTORY_SEPARATOR);73 $pathDirectory = dirname($path);74 @mkdir($pathDirectory, 0777, true);75 if (is_dir($pathDirectory) === false)76 {77 throw new exceptions\runtime('Unable to create directory \'' . $pathDirectory . '\'');78 }79 $data = file_get_contents($pharFile);80 if (file_put_contents($path, $data) != strlen($data))81 {82 throw new exceptions\runtime('Unable to extract file \'' . $pharFilePath . '\' in directory \'' . $pathDirectory . '\'');83 }84 }85 }86 return $this->stopRun();87 }88 public function extractResourcesTo($directory)89 {90 $resourcesDirectory = $this->getResourcesDirectory();91 $directory = rtrim($directory, DIRECTORY_SEPARATOR);92 foreach (new \recursiveIteratorIterator(new \recursiveDirectoryIterator($resourcesDirectory)) as $resourceFile)93 {94 $resourceFilePath = ltrim(str_replace($resourcesDirectory, '', $resourceFile), DIRECTORY_SEPARATOR);95 $resourceFileDirectory = $directory . '/' . dirname($resourceFilePath);96 @mkdir($resourceFileDirectory, 0777, true);97 if (is_dir($resourceFileDirectory) === false)98 {99 throw new exceptions\runtime('Unable to create directory \'' . $resourceFileDirectory . '\'');100 }101 $data = file_get_contents($resourceFile);102 if (file_put_contents($directory . '/' . $resourceFilePath, $data) != strlen($data))103 {104 throw new exceptions\runtime('Unable to extract resource file \'' . $resourceFilePath . '\' in directory \'' . $directory . '\'');105 }106 }107 return $this->stopRun();108 }109 public function useDefaultConfigFiles($startDirectory = null)110 {111 if ($startDirectory === null)112 {113 $startDirectory = dirname($this->getName());114 }115 return parent::useDefaultConfigFiles($startDirectory);116 }117 public function version()118 {119 $this120 ->writeInfo(sprintf($this->locale->_('atoum version %s by %s (%s)'), atoum\version, atoum\author, \phar::running()))121 ;122 return $this->stopRun();123 }124 public function update()125 {126 if ($this->adapter->ini_get('phar.readonly') == true)127 {128 throw new exceptions\runtime('Unable to update the PHAR, phar.readonly is set, use \'-d phar.readonly=0\'');129 }130 if ($this->adapter->ini_get('allow_url_fopen') == false)131 {132 throw new exceptions\runtime('Unable to update the PHAR, allow_url_fopen is not set, use \'-d allow_url_fopen=1\'');133 }134 if (($versions = $this->getVersions($currentPhar = call_user_func($this->pharFactory, $this->getName()))) === null)135 {136 throw new exceptions\runtime('Unable to update the PHAR, the versions\'s file is invalid');137 }138 unset($versions['current']);139 $this->writeMessage($this->locale->_('Checking if a new version is available...'), false);140 $data = json_decode($this->adapter->file_get_contents(sprintf(self::updateUrl, json_encode(array_values($versions)))), true);141 $this142 ->clearMessage()143 ->writeMessage($this->locale->_('Checking if a new version is available... Done!' . PHP_EOL))144 ;145 if (is_array($data) === false || isset($data['version']) === false || isset($data['phar']) === false)146 {147 $this->writeInfo($this->locale->_('There is no new version available!'));148 }149 else150 {151 $tmpFile = $this->adapter->realpath($this->adapter->sys_get_temp_dir()) . '/' . md5($data['version']) . '.phar';152 if ($this->adapter->file_put_contents($tmpFile, utf8_decode($data['phar'])) === false)153 {154 throw new exceptions\runtime('Unable to create temporary file to update to version \'' . $data['version']);155 }156 $this->writeMessage(sprintf($this->locale->_('Update to version \'%s\'...'), $data['version']), false);157 $pharPathLength = strlen($pharPath = 'phar://' . $tmpFile . '/1/');158 $newCurrentDirectory = 1;159 while (isset($versions[$newCurrentDirectory]) === true)160 {161 $newCurrentDirectory++;162 }163 $newFiles = new \arrayIterator();164 foreach (new \recursiveIteratorIterator(new \recursiveDirectoryIterator($pharPath)) as $newFile)165 {166 $newFiles[$newCurrentDirectory . '/' . substr($newFile, $pharPathLength)] = ($newFile = (string) $newFile);167 }168 $currentPhar->buildFromIterator($newFiles);169 $this170 ->clearMessage()171 ->writeMessage(sprintf($this->locale->_('Update to version \'%s\'... Done!' . PHP_EOL), $data['version']))172 ;173 @$this->adapter->unlink($tmpFile);174 $this->writeMessage(sprintf($this->locale->_('Enable version \'%s\'...'), $data['version']), false);175 $versions[$newCurrentDirectory] = $data['version'];176 $versions['current'] = $newCurrentDirectory;177 $currentPhar['versions'] = serialize($versions);178 $this179 ->clearMessage()180 ->writeMessage(sprintf($this->locale->_('Enable version \'%s\'... Done!' . PHP_EOL), $data['version']))181 ;182 $this->writeInfo(sprintf($this->locale->_('Atoum has been updated from version \'%s\' to \'%s\' successfully!'), atoum\version, $data['version']));183 }184 return $this->stopRun();185 }186 public function listAvailableVersions()187 {188 $currentPhar = call_user_func($this->pharFactory, $this->getName());189 if (isset($currentPhar['versions']) === false)190 {191 throw new exceptions\runtime('Unable to list available versions in PHAR, the versions\'s file does not exist');192 }193 $versions = unserialize(file_get_contents($currentPhar['versions']));194 if (is_array($versions) === false || sizeof($versions) <= 0 || isset($versions['current']) === false)195 {196 throw new exceptions\runtime('Unable to list available versions in PHAR, the versions\'s file is invalid');197 }198 $currentDirectory = $versions['current'];199 unset($versions['current']);200 asort($versions);201 foreach ($versions as $directory => $version)202 {203 $this->writeMessage(($directory == $currentDirectory ? '*' : ' ') . ' ' . $version . PHP_EOL);204 }205 return $this->stopRun();206 }207 public function enableVersion($versionName, \phar $phar = null)208 {209 if ($this->adapter->ini_get('phar.readonly') == true)210 {211 throw new exceptions\runtime('Unable to update the PHAR, phar.readonly is set, use \'-d phar.readonly=0\'');212 }213 if ($phar === null)214 {215 $phar = call_user_func($this->pharFactory, $this->getName());216 }217 if (($versions = $this->getVersions($phar)) === null)218 {219 throw new exceptions\runtime('Unable to enable version \'' . $versionName . '\', the versions\'s file is invalid');220 }221 $versionDirectory = array_search($versionName, $versions);222 if ($versionDirectory === false)223 {224 throw new exceptions\runtime('Unable to enable version \'' . $versionName . '\' because it does not exist');225 }226 $versions['current'] = $versionDirectory;227 $phar['versions'] = serialize($versions);228 return $this->stopRun();229 }230 public function deleteVersion($versionName, \phar $phar = null)231 {232 if ($this->adapter->ini_get('phar.readonly') == true)233 {234 throw new exceptions\runtime('Unable to update the PHAR, phar.readonly is set, use \'-d phar.readonly=0\'');235 }236 if ($phar === null)237 {238 $phar = call_user_func($this->pharFactory, $this->getName());239 }240 if (($versions = $this->getVersions($phar)) === null)241 {242 throw new exceptions\runtime('Unable to delete version \'' . $versionName . '\', the versions\'s file is invalid');243 }244 $versionDirectory = array_search($versionName, $versions);245 if ($versionDirectory === false)246 {247 throw new exceptions\runtime('Unable to delete version \'' . $versionName . '\' because it does not exist');248 }249 if ($versionDirectory == $versions['current'])250 {251 throw new exceptions\runtime('Unable to delete version \'' . $versionName . '\' because it is the current version');252 }253 unset($versions[$versionDirectory]);254 unset($phar[$versionDirectory]);255 $phar['versions'] = serialize($versions);256 return $this->stopRun();257 }258 public function getResourcesDirectory()259 {260 if (($versions = $this->getVersions($phar = call_user_func($this->pharFactory, $this->getName()))) === null)261 {262 throw new exceptions\runtime('Unable to define resources directory, verions\'s file is invalid');263 }264 if (isset($phar[$versions['current'] . '/resources']) === false)265 {266 throw new exceptions\logic('Resources directory does not exist in PHAR \'' . $this->getName() . '\'');267 }268 return 'phar://' . $this->getName() . '/' . $versions['current'] . '/resources';269 }270 protected function setArgumentHandlers()271 {272 return273 parent::setArgumentHandlers()274 ->addArgumentHandler(275 function($script, $argument, $values) {276 if (sizeof($values) !== 0)277 {278 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));279 }280 $script->infos();281 },282 array('-i', '--infos'),283 null,284 $this->locale->_('Display informations, do not run any script')285 )286 ->addArgumentHandler(287 function($script, $argument, $values) {288 if (sizeof($values) !== 0)289 {290 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));291 }292 $script->signature();293 },294 array('-s', '--signature'),295 null,296 $this->locale->_('Display phar signature, do not run any script')297 )298 ->addArgumentHandler(299 function($script, $argument, $values) {300 if (sizeof($values) !== 1)301 {302 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));303 }304 $script->extractTo($values[0]);305 },306 array('-e', '--extract-to'),307 '<directory>',308 $this->locale->_('Extract all file from phar to <directory>, do not run any script')309 )310 ->addArgumentHandler(311 function($script, $argument, $values) {312 if (sizeof($values) !== 1)313 {314 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));315 }316 $script->extractResourcesTo($values[0]);317 },318 array('-er', '--extract-resources-to'),319 '<directory>',320 $this->locale->_('Extract resources from phar to <directory>, do not run any script')321 )322 ->addArgumentHandler(323 function($script, $argument, $values, $position) {324 if ($position !== 1 || sizeof($values) !== 1)325 {326 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));327 }328 unset($_SERVER['argv'][1]);329 unset($_SERVER['argv'][2]);330 $script->useScript($values[0]);331 },332 array('-u', '--use'),333 '<script> <args>',334 $this->locale->_('Run script <script> from PHAR with <args> as arguments (this argument must be the first)'),335 4336 )337 ->addArgumentHandler(338 function($script, $argument, $values) {339 if (sizeof($values) > 0)340 {341 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));342 }343 $script->listScripts();344 },345 array('-ls', '--list-scripts'),346 null,347 $this->locale->_('List available scripts')348 )349 ->addArgumentHandler(350 function($script, $argument, $values) {351 if (sizeof($values) > 0)352 {353 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));354 }355 $script->update();356 },357 array('--update'),358 null,359 $this->locale->_('Update atoum')360 )361 ->addArgumentHandler(362 function($script, $argument, $values) {363 if (sizeof($values) > 0)364 {365 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));366 }367 $script->listAvailableVersions();368 },369 array('-lav', '--list-available-versions'),370 null,371 $this->locale->_('List available versions in the PHAR')372 )373 ->addArgumentHandler(374 function($script, $argument, $values) {375 if (sizeof($values) != 1)376 {377 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));378 }379 $script->enableVersion($values[0]);380 },381 array('-ev', '--enable-version'),382 '<version>',383 $this->locale->_('Enable version <version>')384 )385 ->addArgumentHandler(386 function($script, $argument, $values) {387 if (sizeof($values) != 1)388 {389 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));390 }391 $script->deleteVersion($values[0]);392 },393 array('-dv', '--delete-version'),394 '<version>',395 $this->locale->_('Delete version <version>')396 )397 ;398 return $this;399 }400 protected function getVersions(\phar $phar)401 {402 if (isset($phar['versions']) === false)403 {404 throw new exceptions\runtime('The versions\'s file does not exist');405 }406 $versions = unserialize($this->adapter->file_get_contents($phar['versions']));407 return ((is_array($versions) === false || isset($versions['current']) === false || isset($versions[$versions['current']]) === false) ? null : $versions);408 }409 protected static function extractFilesTo(\recursiveDirectoryIterator $fromPharDirectory, $toDirectory)410 {411 $directory = rtrim($directory, DIRECTORY_SEPARATOR);412 $pharName = \phar::running();413 foreach (new \recursiveIteratorIterator($fromPharDirectory) as $pharFile)414 {415 $pharFilePath = ltrim(str_replace($pharName, '', $pharFile), DIRECTORY_SEPARATOR);416 if (strpos($pharFilePath, $versions['current']) === 0)417 {418 $path = $directory . '/' . ltrim(substr($pharFilePath, strlen($versions['current'])), DIRECTORY_SEPARATOR);419 $pathDirectory = dirname($path);420 @mkdir($pathDirectory, 0777, true);421 if (is_dir($pathDirectory) === false)422 {423 throw new exceptions\runtime('Unable to create directory \'' . $pathDirectory . '\'');424 }425 $data = file_get_contents($pharFile);426 if (file_put_contents($path, $data) != strlen($data))427 {428 throw new exceptions\runtime('Unable to extract file \'' . $pharFilePath . '\' in directory \'' . $pathDirectory . '\'');429 }430 }431 }432 return $this;433 }434 protected static function getScriptFile($scriptName)435 {436 return atoum\directory . '/' . self::scriptsDirectory . '/' . $scriptName . self::scriptsExtension;437 }438}...

Full Screen

Full Screen

getScriptFile

Using AI Code Generation

copy

Full Screen

1$stub = new stub();2echo $stub->getScriptFile();3$stub = new stub();4echo $stub->getScriptFile();5$stub = new stub();6echo $stub->getScriptFile();7$stub = new stub();8echo $stub->getScriptFile();9$stub = new stub();10echo $stub->getScriptFile();11$stub = new stub();12echo $stub->getScriptFile();13$stub = new stub();14echo $stub->getScriptFile();15$stub = new stub();16echo $stub->getScriptFile();17$stub = new stub();18echo $stub->getScriptFile();19$stub = new stub();20echo $stub->getScriptFile();21$stub = new stub();22echo $stub->getScriptFile();23$stub = new stub();24echo $stub->getScriptFile();25$stub = new stub();26echo $stub->getScriptFile();27$stub = new stub();28echo $stub->getScriptFile();29$stub = new stub();30echo $stub->getScriptFile();

Full Screen

Full Screen

getScriptFile

Using AI Code Generation

copy

Full Screen

1$stub = new stub();2echo $stub->getScriptFile();3$stub = new stub();4echo $stub->getScriptFile();5$stub = new stub();6echo $stub->getScriptFile();7$stub = new stub();8echo $stub->getScriptFile();9$stub = new stub();10echo $stub->getScriptFile();11$stub = new stub();12echo $stub->getScriptFile();13$stub = new stub();14echo $stub->getScriptFile();15$stub = new stub();16echo $stub->getScriptFile();17$stub = new stub();18echo $stub->getScriptFile();

Full Screen

Full Screen

getScriptFile

Using AI Code Generation

copy

Full Screen

1require_once 'stub.php';2$stub = new stub();3echo $stub->getScriptFile();4require_once 'stub.php';5$stub = new stub();6echo $stub->getScriptFile();7class stub{8 public function getScriptFile(){9 $trace = debug_backtrace();10 return $trace[0]['file'];11 }12}

Full Screen

Full Screen

getScriptFile

Using AI Code Generation

copy

Full Screen

1$stub = new stub();2$stub->getScriptFile();3$stub = new stub();4$stub->getScriptFile();5Fatal error: Call to private method stub::getScriptFile() from context 'test'6$stub = new stub();7$stub->getScriptFile();8$stub = new stub();9$stub->getScriptFile();10$test = new test();11$test->getScriptFile();12class stub {13 private function getScriptFile() {14 echo __FILE__;15 }16}17class test {18 public function getScriptFile() {19 $stub = new stub();

Full Screen

Full Screen

getScriptFile

Using AI Code Generation

copy

Full Screen

1echo "Path of the file is : ".stub::getScriptFile()."2";3Recommended Posts: PHP | getScriptDir() Function4PHP | getScriptName() Function5PHP | getScriptPath() Function6PHP | getScriptURL() Function7PHP | getScriptURI() Function8PHP | getScriptURL() Function9PHP | getScriptURI() Function10PHP | getScriptPath() Function11PHP | getScriptName() Function12PHP | getScriptDir() Function13PHP | getScriptName() Function14PHP | getScriptURL() Function15PHP | getScriptURI() Function16PHP | getScriptPath() Function17PHP | getScriptDir() Function18PHP | getScriptName() Function19PHP | getScriptURL() Function20PHP | getScriptURI() Function21PHP | getScriptPath() Function22PHP | getScriptDir() Function

Full Screen

Full Screen

getScriptFile

Using AI Code Generation

copy

Full Screen

1";2";3";4";5";6";7";8";9";10";11";12";13";

Full Screen

Full Screen

getScriptFile

Using AI Code Generation

copy

Full Screen

1$stub = new stub();2echo $stub->getScriptFile();3echo $_SERVER['PHP_SELF'];4echo $_SERVER['SCRIPT_NAME'];5echo $_SERVER['SCRIPT_FILENAME'];6echo $_SERVER['PHP_SELF'];7echo "<br>";8echo $_SERVER['SCRIPT_NAME'];9echo $_SERVER['PHP_SELF'];10echo "<br>";11echo $_SERVER['SCRIPT_FILENAME'];

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger getScriptFile code on LambdaTest Cloud Grid

Execute automation tests with getScriptFile on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful