How to use run method of gui class

Best Phoronix-test-suite code snippet using gui.run

equilibration

Source:equilibration Github

copy

Full Screen

...4#### the namd executable for this5$namd2 = __DIR__ . "/namd/NAMD_2.14_Linux-x86_64-multicore/namd2";6#### the CHARMM-gui generated base file name ".inp" extension is assumed and not provided here7$ifile = "step4_equilibration";8#### number seconds between checking to see if the NAMD process is still running9$poll_interval_seconds = 5;10#### frequency of actual UI updates, multiply this by the $poll_interval_seconds to determine actual user update time11$poll_update_freq = 1;12### end user configuration13### developer configuration14$timeout = "";15#### for debugging16## $timeout = "timeout 60";17### end developer configuration18$self = __FILE__;19if ( count( $argv ) != 2 ) {20 echo '{"error":"$self requires a JSON input object"}';21 exit;22}23$json_input = $argv[1];24$input = json_decode( $json_input );25if ( !$input ) {26 echo '{"error":"$self - invalid JSON."}';27 exit;28}29$output = (object)[];30include "genapp.php";31include "datetime.php";32$ga = new GenApp( $input, $output );33$fdir = preg_replace( "/^.*\/results\//", "results/", $input->_base_directory );34## get state35require "common.php";36$cgstate = new cgrun_state();37## check for previous run38#### would be nice to do this before openstack :(39#### another case for early defaults?40if ( file_exists( "charmm-gui/namd/$ifile.dcd" ) ) {41 $response =42 json_decode(43 $ga->tcpquestion(44 [45 "id" => "q1"46 ,"title" => "<h5>Project '$input->_project' has previous equilibration results</h5>"47 ,"icon" => "warning.png"48 ,"text" => ""49 ,"timeouttext" => "The time to respond has expired, please submit again."50 ,"buttons" => [ "Erase previous results", "Cancel" ]51 ,"fields" => [52 [53 "id" => "l1"54 ,"type" => "label"55 ,"label" => "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Previous results will be overwritten!"56 ,"align" => "center"57 ]58 ]59 ]60 )61 );62 if ( $response->_response->button == "cancel" ) {63 echo '{"_message":{"icon":"information.png","text":"Canceled"}}';64 exit;65 }66}67## process inputs here to produce output68if ( !isset( $input->os_flavor ) ) {69 echo '{"_message":{"icon":"toast.png","text":"Internal error: <i>os_flavor</i> not defined.<br>This should not happen.<br>Please contact the administrators via the <i>Feedback</i> tab"}}';70 exit;71}72if ( !file_exists( __DIR__ . "/../appconfig.json" ) ) {73 echo '{"_message":{"icon":"toast.png","text":"Internal error: <i>appconfig.json</i> not found.<br>This should not happen.<br>Please contact the administrators via the <i>Feedback</i> tab"}}';74 exit;75}76$appconfig = json_decode( file_get_contents( __DIR__ . "/../appconfig.json" ) );77if ( !isset( $appconfig->resources )78 || !isset( $appconfig->resources->oscluster )79 || !isset( $appconfig->resources->oscluster->properties )80 || !isset( $appconfig->resources->oscluster->properties->flavors ) ) {81 echo '{"_message":{"icon":"toast.png","text":"Internal error: <i>appconfig.json</i> missing <i>resources:oscluster:properties:flavors</i>.<br>This should not happen.<br>Please contact the administrators via the <i>Feedback</i> tab"}}';82 exit;83}84if ( !array_key_exists( str_replace( "_", ".", $input->os_flavor ), $appconfig->resources->oscluster->properties->flavors ) ) {85 echo '{"_message":{"icon":"toast.png","text":"Internal error: flavor <i>' . str_replace( "_", ".", $input->os_flavor ) . '</i> missing resources:oscluster:properties:flavors.<br>This should not happen.<br>Please contact the administrators via the <i>Feedback</i> tab"}}';86 exit;87}88$cores = $appconfig->resources->oscluster->properties->flavors->{ str_replace( "_", ".", $input->os_flavor ) };89# $ga->tcpmessage( [ "_textarea" => json_encode( $appconfig->resources->oscluster->properties->flavors, JSON_PRETTY_PRINT ) . "\n" ] );90### read appconfig.json & get flavor mapping to determine # of cores91## is this a proper project that has been "load"'d92if ( !$cgstate->state->loaded ) {93 echo '{"_message":{"icon":"information.png","text":"The current project <i>' . $input->_project . '</i> is not ready for equilibration,<br>Did you <i>load</i> it yet?<br>You can change projects in user configuration (top right)"}}';94 exit;95}96## are the expected directories present?97if ( !is_dir( "charmm-gui/namd" ) ) {98 echo '{"_message":{"icon":"toast.png","text":"The directory <i>charmm-gui/namd</i> does not exist. You will need to run <i>Load</i> again"}}';99 exit;100}101if ( !file_exists( "charmm-gui/namd/$ifile.inp" ) ) {102 echo '{"_message":{"icon":"toast.png","text":"The file <i>' . $ifile . '.inp</i> is missing.<br>Either the loaded file is incorrect, CHARMM-gui has changed how it creates NAMD output or the file was removed after loading.<br>If this problem persists, Please contact the administrators via the <i>Feedback</i> tab"}}';103 exit;104}105## validate $ifile.inp106if ( count( explode( "\n", `grep -Pi '^minimize ' charmm-gui/namd/$ifile.inp` ) ) != 2107 || count( explode( "\n", `grep -Pi '^run ' charmm-gui/namd/$ifile.inp` ) ) != 2108 ) {109 echo '{"_message":{"icon":"toast.png","text":"The file <i>' . $ifile . '.inp</i> does not contain exactly one <i>minimize</i> line and exactly one <i>run<i> line.<br>Either the loaded file is incorrect, CHARMM-gui has changed how it creates NAMD output or the file was somehow modified after loading.<br>If this problem persists, Please contact the administrators via the <i>Feedback</i> tab"}}';110 exit;111}112## update $ifile.inp if needed113if (114 isset( $input->min_steps )115 || isset( $input->run_steps )116 || isset( $input->dcdfreq )117 || isset( $input->temperature )118 ) {119 $inplines = explode( "\n", file_get_contents( "charmm-gui/namd/$ifile.inp" ) );120 $inpnew = preg_replace(121 [122 '/^set temp\s+.*$/'123 ,'/^dcdfreq(\s*)(\d+)/'124 ,'/^minimize(\s*)(\d+)/'125 ,'/^run(\s*)(\d+)/'126 ],127 [128 "set temp $input->temperature;"129 ,"dcdfreq $input->dcdfreq"130 ,"minimize $input->min_steps"131 ,"run $input->run_steps"132 ]133 ,$inplines134 );135 if ( count( $inplines ) != count( $inpnew ) ) {136 echo '{"_message":{"icon":"toast.png","text":"Error replacing values in input script<br>Try <i>load</i> again.<br>If this problem persists, Please contact the administrators via the <i>Feedback</i> tab"}}';137 exit;138 }139 file_put_contents( "charmm-gui/namd/$ifile.inp", implode( "\n", $inpnew ) );140}141if ( !file_exists( $namd2 ) ) {142 echo '{"_message":{"icon":"toast.png","text":"Internal error: <i>' . $namd2 . '</i> does not exist.<br>This should not happen.<br>Please contact the administrators via the <i>Feedback</i> tab"}}';143 exit;144}145## create the command146$cmd = "umask 002 && cd charmm-gui/namd && $timeout $namd2 +idlepoll +p$cores $ifile.inp 2> $ifile.stderr > $ifile.stdout";147$ga->tcpmessage( [ "_textarea" => "Command:\n$cmd\n" ] );148## ready to run, fork & execute cmd in child149$deletes = [ ".stdout", ".dcd", "_last.dcd", "_last.pdb", "_last_dry.pdb", "_results.tgz" ];150foreach ( $deletes as $v ) {151 if ( file_exists( "charmm-gui/namd/$ifile$v" ) ) {152 unlink( "charmm-gui/namd/$ifile$v" );153 }154}155$ga->tcpmessage( [ "inputlink" => "$fdir/charmm-gui/namd/$ifile.inp" ] );156unset( $cgstate->state->equilibrated );157if ( !$cgstate->save() ) {158 echo '{"_message":{"icon":"toast.png","text":"Save state failed: ' . $cgstate->errors . '"}}';159 exit;160}161## fork ... child will exec162$pid = pcntl_fork();163if ( $pid == -1 ) {164 echo '{"_message":{"icon":"toast.png","text":"Unable to fork process.<br>This should not happen.<br>Please contact the administrators via the <i>Feedback</i> tab"}}';165 exit;166}167## prepare to run168$errors = false;169if ( $pid ) {170 ## parent171 init_ui();172 $updatenumber = 0;173 while ( file_exists( "/proc/$pid/stat" ) ) {174 ## is Z/defunct ?175 $stat = file_get_contents( "/proc/$pid/stat" );176 $stat_fields = explode( ' ', $stat );177 if ( count( $stat_fields ) > 2 && $stat_fields[2] == "Z" ) {178 break;179 }180 ## still running181 if ( !( $updatenumber++ % $poll_update_freq ) ) {182 ## update UI183 # $ga->tcpmessage( [ "_textarea" => "update the UI $updatenumber - $pid\n" ] );184 update_ui();185 } else {186 ## simply checking for job completion187 # $ga->tcpmessage( [ "_textarea" => "polling update $updatenumber - $pid\n" ] );188 }189 sleep( $poll_interval_seconds );190 } 191 ## get exit status from /proc/$pid192 pcntl_waitpid( $pid, $status );193 ## namd returns status zero even if it fails :(194 ## $ga->tcpmessage( [ "_textarea" => sprintf( "exit status %s\n", pcntl_wexitstatus( $status ) ) ] );195 if ( file_exists( "charmm-gui/namd/${ifile}.stderr" ) && filesize( "charmm-gui/namd/${ifile}.stderr" ) ) {196 $ga->tcpmessage( [ "_textarea" => "NAMD errors:\n----\n" . file_get_contents( "charmm-gui/namd/${ifile}.stderr" ) . "\n----\n" ] );197 $errors = true;198 }199 update_ui();200} else {201 ## child202 ob_start();203 $ga->tcpmessage( [ "_textarea" => "\nEquilibration job starting\n" ] );204 $ga->tcpmessage( [ "stdoutlink" => "$fdir/charmm-gui/namd/$ifile.stdout" ] );205 $time_start = dt_now();206 shell_exec( $cmd );207 $time_end = dt_now();208 $ga->tcpmessage( [ "_textarea" =>209 "\nEquilibration job ending\n"210 . "NAMD duration: " . dhms_from_minutes( dt_duration_minutes( $time_start, $time_end ) ) . "\n"211 ] );212 ob_end_clean();213 exit();214}215## assemble final output216## dcd->pdb217if ( file_exists( "charmm-gui/namd/$ifile.dcd" ) ) {218 $cmd = "cd charmm-gui/namd && " . __DIR__ . "/util/catdcd -num $ifile.dcd | grep -P '^Total frames' | awk '{ print \$3 }'";219 $lframe = intval( `$cmd 2>/dev/null` );220 if ( $lframe > 1 ) {221 # $ga->tcpmessage( [ "_textarea" => "checking for dcd to make pdb - lframe > 1\n" ] );222 ## need 2 frames for mdconvert223 $lframe--;224 $cmd = "cd charmm-gui/namd && " . __DIR__ . "/util/catdcd -first $lframe -o ${ifile}_last.dcd $ifile.dcd";225 `$cmd 2>&1 > /dev/null`;226 if ( file_exists( "charmm-gui/namd/${ifile}_last.dcd" ) ) {227 $cmd = "cd charmm-gui/namd && mdconvert -f -o ${ifile}_last.pdb -t step3_input.pdb -i -1 ${ifile}_last.dcd";228 `$cmd 2>&1 > /dev/null`;229 if ( file_exists( "charmm-gui/namd/${ifile}_last.pdb" ) ) {230 $cmd = "cd charmm-gui/namd && grep -Pv ' (HOH|POT POT|SOD SOD|CLA CLA) ' ${ifile}_last.pdb > ${ifile}_last_dry.pdb";231 #$ga->tcpmessage( [ "_textarea" => "nowat cmd $cmd\n" ] );232 `$cmd 2> /dev/null`;233 if ( file_exists( "charmm-gui/namd/${ifile}_last_dry.pdb" ) ) {234 $output->pdblastdry = "$fdir/charmm-gui/namd/${ifile}_last_dry.pdb";235 } else {236 $ga->tcpmessage( [ "_textarea" => "Notice: failed to extract solvent from pdb, so no pdb will be created for visualization\n" ] );237 }238 } else {239 $ga->tcpmessage( [ "_textarea" => "Notice: mdconvert failed to create a pdb from the dcd, so no pdb will be created for visualization\n" ] );240 }241 } else {242 $ga->tcpmessage( [ "_textarea" => "Notice: catdcd failed to extract frames from the dcd, so no pdb will be created for visualization\n" ] );243 }244 } else {245 $ga->tcpmessage( [ "_textarea" => "Notice: final dcd has only one frame, so no pdb will be created for visualization\n" ] );246 }247} else {248 $ga->tcpmessage( [ "_textarea" => "Notice: No final dcd file found so no pdb will be created for visualization\n" ] );249 $errors = true;250} 251## tar gz output252$tgzfiles = [253 "$ifile.vel"254 ,"$ifile.coor"255 ,"$ifile.xsc"256 ,"$ifile.xst"257 ,"$ifile.stdout"258 ,"$ifile.stderr"259 ,"${ifile}_last.pdb"260 ,"${ifile}_last_dry.pdb"261 ];262$cmd = "cd charmm-gui/namd && ls -1 " . implode( " ", $tgzfiles ) . " 2> /dev/null";263exec( $cmd, $tgzfilesfound );264$cmd = "cd charmm-gui/namd && tar -I pigz -cf ${ifile}_results.tgz " . implode( " ", $tgzfilesfound );265`$cmd 2>&1 > /dev/null`;266 267update_ui( false );268$output->inputlink = "$fdir/charmm-gui/namd/$ifile.inp";269if ( file_exists( "charmm-gui/namd/$ifile.dcd" ) ) {270 $output->dcdlink = "$fdir/charmm-gui/namd/$ifile.dcd";271}272$output->stdoutlink = "$fdir/charmm-gui/namd/$ifile.stdout";273if ( file_exists( "charmm-gui/namd/${ifile}_results.tgz" ) ) {274 $output->tgzlink = "$fdir/charmm-gui/namd/${ifile}_results.tgz";275}276if ( file_exists( "charmm-gui/namd/$ifile.stdout" ) && filesize( "charmm-gui/namd/$ifile.stdout" ) > 0 ) {277 $output->min_e_plot = $namd->min_e_plot;278 $output->run_e_plot = $namd->run_e_plot;279 $output->run_t_plot = $namd->run_t_plot;280}281$output->_textarea = "";282#$output->_textarea .= "JSON output from executable:\n" . json_encode( $output, JSON_PRETTY_PRINT ) . "\n";283$output->_textarea .= "JSON input to executable:\n" . json_encode( $input, JSON_PRETTY_PRINT ) . "\n";284# $output->_textarea .= "Command:\n$cmd\n";285$output->_textarea .= "\nEQUILBRATION complete\n";286## update state287if ( !$errors ) {288 $cgstate->state->equilibrated = true;289 $cgstate->state->lastoutput = $ifile;290 if ( isset( $input->description ) ) {291 $cgstate->state->description = $input->description;292 }293 if ( !$cgstate->save() ) {294 echo '{"_message":{"icon":"toast.png","text":"Save state failed:' . $cgstate->errors . '"}}';295 exit;296 }297}298echo json_encode( $output );299## ui bits should really be a class300function init_ui() {301 global $ifile;302 global $namd;303 global $ga;304 $namd = (object)[];305 306 $namd->min_e_plot = json_decode(307 '{308 "data" : [309 {310 "x" : []311 ,"y" : []312 ,"mode" : "lines"313 ,"line" : {314 "color" : "rgb(150,150,222)"315 ,"width" : 2316 }317 }318 ]319 ,"layout" : {320 "title" : "Minimize TOTAL3"321 ,"showlegend" : false322 ,"font" : {323 "color" : "rgb(0,0,0)"324 }325 ,"paper_bgcolor": "rgba(0,0,0,0)"326 ,"plot_bgcolor": "rgba(0,0,0,0)"327 ,"xaxis" : {328 "gridcolor" : "rgba(50,50,50,0.5)"329 ,"title" : {330 "text" : "Timestep"331 ,"gridcolor" : "rgb(50,50,50)"332 ,"font" : {333 "color" : "rgb(50,50,50)"334 }335 }336 }337 ,"yaxis" : {338 "gridcolor" : "rgba(50,50,50,0.5)"339 ,"title" : {340 "text" : "TOTAL3"341 ,"font" : {342 "color" : "rgb(50,50,50)"343 }344 }345 }346 }347 }'348 );349 $namd->run_e_plot = json_decode( json_encode( $namd->min_e_plot ) );350 $namd->run_e_plot->layout->title = "Run TOTAL3";351 $namd->run_t_plot = json_decode( json_encode( $namd->min_e_plot ) );352 $namd->run_t_plot->layout->title = "Run Temperature";353 $namd->run_t_plot->layout->yaxis->title->text = "Temperature";354 $namd->min_steps = intval( `grep -Pi '^minimize ' charmm-gui/namd/$ifile.inp | awk '{ print \$2 }'` );355 $namd->run_steps = intval( `grep -Pi '^run ' charmm-gui/namd/$ifile.inp | awk '{ print \$2 }'` );356 $namd->temperature = floatval( `grep -Pi '^set temp ' charmm-gui/namd/$ifile.inp | awk '{ print \$3 }'` );357 if ( $namd->min_steps > 0 ) {358 $namd->min_e_plot->layout->xaxis->range = [0, $namd->min_steps ];359 }360 361 if ( $namd->run_steps > 0 ) {362 $namd->run_e_plot->layout->xaxis->range = [$namd->min_steps, $namd->min_steps + $namd->run_steps ];363 $namd->run_t_plot->layout->xaxis->range = [$namd->min_steps, $namd->min_steps + $namd->run_steps ];364 if ( $namd->temperature > 0 ) {365 $namd->run_t_plot->data[] =366 [367 "x" => [ $namd->min_steps, $namd->min_steps + $namd->run_steps ]368 ,"y" => [ $namd->temperature, $namd->temperature ]369 ,"mode" => "lines"370 ,"line" => [371 "color" => "rgba(222,0,0,0.5)"372 ,"dash" => "dashdot"373 ,"width" => 2374 ]375 ]376 ;377 }378 }379 # $ga->tcpmessage( [ "_textarea" => "temperature: $namd->temperature\n" . json_encode( $namd->run_t_plot, JSON_PRETTY_PRINT ) . "\n" ] );380 $namd->min_plot_done = false;381}382function update_ui( $message = true ) {383 global $ga;384 global $ifile;385 global $namd;386 # $ga->tcpmessage( [ "_textarea" => "update_ui()\n" ] );387 $cmd = "grep -P '^ENERGY:' charmm-gui/namd/$ifile.stdout 2> /dev/null";388 $allE = `$cmd`;389 $Es = explode( "\n", $allE );390 if ( count( $Es ) < 2 ) {391 return;392 }393 array_pop( $Es ); ## last one appears to be empty394 395 # $ga->tcpmessage( [ "_textarea" => end( $Es ) . "\n" ] );396 397 ## create plotly plot398 $namd->min_e_plot->data[0]->x = [];399 $namd->min_e_plot->data[0]->y = [];400 $namd->run_e_plot->data[0]->x = [];401 $namd->run_e_plot->data[0]->y = [];402 $namd->run_t_plot->data[0]->x = [];403 $namd->run_t_plot->data[0]->y = [];404 $min_done = $namd->min_plot_done;405 406 $lastt = 0;407 foreach ( $Es as $v ) {408 $l = preg_split( "/\s+/", $v );409 if ( count( $l ) > 14 ) {410 $lastt = intval( $l[1] );411 if ( intval( $l[1] ) < $namd->min_steps ) {412 $namd->min_e_plot->data[0]->x[] = $l[1];413 $namd->min_e_plot->data[0]->y[] = $l[14];414 } else {415 $min_done = true;416 $namd->run_e_plot->data[0]->x[] = $l[1];417 $namd->run_e_plot->data[0]->y[] = $l[14];418 $namd->run_t_plot->data[0]->x[] = $l[1];419 $namd->run_t_plot->data[0]->y[] = $l[12];420 }421 422 # $ga->tcpmessage( [ "_textarea" => "data $l[1] $l[14]\n" ] );423 }424 }425 426 # $ga->tcpmessage( [ "_textarea" => json_encode( $min_e_plot, JSON_PRETTY_PRINT ) . "\n" ] );427 if ( $message ) {428 if ( !$namd->min_plot_done ) {429 $ga->tcpmessage( [430 "min_e_plot" => $namd->min_e_plot431 ,"_progress" => $lastt / ( $namd->min_steps + $namd->run_steps )432 ] );433 }434 $namd->min_plot_done = $min_done;435 if ( $min_done ) {436 $ga->tcpmessage( [437 "run_e_plot" => $namd->run_e_plot438 ,"run_t_plot" => $namd->run_t_plot439 ,"_progress" => $lastt / ( $namd->min_steps + $namd->run_steps )440 ] );441 }442 }443}...

Full Screen

Full Screen

RouterTest.php

Source:RouterTest.php Github

copy

Full Screen

...5{6 /**7 * @covers OpCacheGUI\Network\Router::__construct8 * @covers OpCacheGUI\Network\Router::post9 * @covers OpCacheGUI\Network\Router::run10 * @covers OpCacheGUI\Network\Router::getIdentifier11 */12 public function testPost()13 {14 $requestMock = $this->getMock('\\OpCacheGUI\\Network\\RequestData');15 $requestMock->method('getVerb')->willReturn('POST');16 $requestMock->method('path')->willReturn('somepath');17 $routeMock = $this->getMockBuilder('\\OpCacheGUI\\Network\\Route')->disableOriginalConstructor()->getMock();18 $routeMock->method('matchesRequest')->willReturn(true);19 $routeMock->method('run')->willReturn('foo');20 $factoryMock = $this->getMock('\\OpCacheGUI\\Network\\RouteBuilder');21 $factoryMock->method('build')->willReturn($routeMock);22 $router = new Router($requestMock, $factoryMock);23 $router->post('id', function () {});24 $this->assertSame('foo', $router->run());25 }26 /**27 * @covers OpCacheGUI\Network\Router::__construct28 * @covers OpCacheGUI\Network\Router::get29 * @covers OpCacheGUI\Network\Router::run30 * @covers OpCacheGUI\Network\Router::getIdentifier31 */32 public function testGet()33 {34 $requestMock = $this->getMock('\\OpCacheGUI\\Network\\RequestData');35 $requestMock->method('getVerb')->willReturn('GET');36 $requestMock->method('path')->willReturn('somepath');37 $routeMock = $this->getMockBuilder('\\OpCacheGUI\\Network\\Route')->disableOriginalConstructor()->getMock();38 $routeMock->method('matchesRequest')->willReturn(true);39 $routeMock->method('run')->willReturn('foo');40 $factoryMock = $this->getMock('\\OpCacheGUI\\Network\\RouteBuilder');41 $factoryMock->method('build')->willReturn($routeMock);42 $router = new Router($requestMock, $factoryMock);43 $router->get('id', function () {});44 $this->assertSame('foo', $router->run());45 }46 /**47 * @covers OpCacheGUI\Network\Router::__construct48 * @covers OpCacheGUI\Network\Router::run49 * @covers OpCacheGUI\Network\Router::getMainPage50 */51 public function testRunNoRoutes()52 {53 $requestMock = $this->getMock('\\OpCacheGUI\\Network\\RequestData');54 $requestMock->method('getVerb')->willReturn('GET');55 $requestMock->method('path')->willReturn('somepath');56 //$routeMock = $this->getMockBuilder('\\OpCacheGUI\\Network\\Route')->disableOriginalConstructor()->getMock();57 //$routeMock->method('matchesRequest')->will($this->onConsecutiveCalls(false, true));58 //$routeMock->method('run')->willReturn('main route');59 $factoryMock = $this->getMock('\\OpCacheGUI\\Network\\RouteBuilder');60 //$factoryMock->method('build')->willReturn($routeMock);61 $router = new Router($requestMock, $factoryMock);62 //$router->get('id', function () {});63 $this->assertNull($router->run());64 }65 /**66 * @covers OpCacheGUI\Network\Router::__construct67 * @covers OpCacheGUI\Network\Router::run68 * @covers OpCacheGUI\Network\Router::getMainPage69 */70 public function testRunNoMatchFirstMatchMain()71 {72 $requestMock = $this->getMock('\\OpCacheGUI\\Network\\RequestData');73 $requestMock->method('getVerb')->willReturn('GET');74 $requestMock->method('path')->willReturn('somepath');75 $routeMock = $this->getMockBuilder('\\OpCacheGUI\\Network\\Route')->disableOriginalConstructor()->getMock();76 $routeMock->method('matchesRequest')->will($this->onConsecutiveCalls(false, true));77 $routeMock->method('run')->willReturn('main route');78 $factoryMock = $this->getMock('\\OpCacheGUI\\Network\\RouteBuilder');79 $factoryMock->method('build')->willReturn($routeMock);80 $router = new Router($requestMock, $factoryMock);81 $router->get('id', function () {});82 $this->assertSame('main route', $router->run());83 }84 /**85 * @covers OpCacheGUI\Network\Router::__construct86 * @covers OpCacheGUI\Network\Router::run87 * @covers OpCacheGUI\Network\Router::getMainPage88 */89 public function testRunNoMatchSecondMatchMain()90 {91 $requestMock = $this->getMock('\\OpCacheGUI\\Network\\RequestData');92 $requestMock->method('getVerb')->willReturn('GET');93 $requestMock->method('path')->willReturn('somepath');94 $routeMock = $this->getMockBuilder('\\OpCacheGUI\\Network\\Route')->disableOriginalConstructor()->getMock();95 $routeMock->method('matchesRequest')->will($this->onConsecutiveCalls(false, false, false, true));96 $routeMock->method('run')->willReturn('main route');97 $factoryMock = $this->getMock('\\OpCacheGUI\\Network\\RouteBuilder');98 $factoryMock->method('build')->willReturn($routeMock);99 $router = new Router($requestMock, $factoryMock);100 $router->get('id', function () {});101 $router->post('id', function () {});102 $this->assertSame('main route', $router->run());103 }104 /**105 * @covers OpCacheGUI\Network\Router::__construct106 * @covers OpCacheGUI\Network\Router::post107 * @covers OpCacheGUI\Network\Router::run108 * @covers OpCacheGUI\Network\Router::getIdentifier109 */110 public function testRunMatchesFirst()111 {112 $requestMock = $this->getMock('\\OpCacheGUI\\Network\\RequestData');113 $requestMock->method('getVerb')->willReturn('POST');114 $requestMock->method('path')->willReturn('somepath');115 $routeMockMatch = $this->getMockBuilder('\\OpCacheGUI\\Network\\Route')->disableOriginalConstructor()->getMock();116 $routeMockMatch->method('matchesRequest')->willReturn(true);117 $routeMockMatch->method('run')->willReturn('match');118 $routeMockNoMatch = $this->getMockBuilder('\\OpCacheGUI\\Network\\Route')->disableOriginalConstructor()->getMock();119 $routeMockNoMatch->method('matchesRequest')->willReturn(false);120 $routeMockNoMatch->method('run')->willReturn('nomatch');121 $factoryMock = $this->getMock('\\OpCacheGUI\\Network\\RouteBuilder');122 $factoryMock->method('build')->will($this->onConsecutiveCalls($routeMockMatch, $routeMockNoMatch));123 $router = new Router($requestMock, $factoryMock);124 $router->post('id', function () {});125 $this->assertSame('match', $router->run());126 }127 /**128 * @covers OpCacheGUI\Network\Router::__construct129 * @covers OpCacheGUI\Network\Router::post130 * @covers OpCacheGUI\Network\Router::run131 * @covers OpCacheGUI\Network\Router::getIdentifier132 */133 public function testRunMatchesLast()134 {135 $requestMock = $this->getMock('\\OpCacheGUI\\Network\\RequestData');136 $requestMock->method('getVerb')->willReturn('POST');137 $requestMock->method('path')->willReturn('somepath');138 $routeMockMatch = $this->getMockBuilder('\\OpCacheGUI\\Network\\Route')->disableOriginalConstructor()->getMock();139 $routeMockMatch->method('matchesRequest')->willReturn(true);140 $routeMockMatch->method('run')->willReturn('match');141 $routeMockNoMatch = $this->getMockBuilder('\\OpCacheGUI\\Network\\Route')->disableOriginalConstructor()->getMock();142 $routeMockNoMatch->method('matchesRequest')->willReturn(false);143 $routeMockNoMatch->method('run')->willReturn('nomatch');144 $factoryMock = $this->getMock('\\OpCacheGUI\\Network\\RouteBuilder');145 $factoryMock->method('build')->will($this->onConsecutiveCalls($routeMockNoMatch, $routeMockMatch));146 $router = new Router($requestMock, $factoryMock);147 $router->post('id', function () {});148 $router->post('id', function () {});149 $this->assertSame('match', $router->run());150 }151 /**152 * @covers OpCacheGUI\Network\Router::__construct153 * @covers OpCacheGUI\Network\Router::getIdentifier154 */155 public function testIdentifierWithImplicitUrlRewrite()156 {157 $requestMock = $this->getMock('\\OpCacheGUI\\Network\\RequestData');158 $requestMock->method('path')->willReturn('somepath');159 $factoryMock = $this->getMock('\\OpCacheGUI\\Network\\RouteBuilder');160 $router = new Router($requestMock, $factoryMock);161 $this->assertSame('somepath', $router->getIdentifier());162 }163 /**...

Full Screen

Full Screen

CustomizationSysprepTest.php

Source:CustomizationSysprepTest.php Github

copy

Full Screen

1<?php2namespace Zorille\framework;3use \Exception as Exception;4use \ArrayObject as ArrayObject;5use \soapvar as soapvar;6/**7 * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2015-09-07 at 11:31:16.8 */9if (! defined ( '__DOCUMENT_ROOT__' )) {10 require_once $_SERVER ["PWD"] . '/prepare.php';11}12class CustomizationSysprepTest extends MockedListeOptions {13 /**14 * @var CustomizationSysprep15 */16 protected $object;17 /**18 * Sets up the fixture, for example, opens a network connection.19 * This method is called before a test is executed.20 */21 protected function setUp() {22 ob_start ();23 $this->object = new CustomizationSysprep ( false, "TESTS CustomizationSysprep" );24 }25 /**26 * Tears down the fixture, for example, closes a network connection.27 * This method is called after a test is executed.28 */29 protected function tearDown() {30 ob_end_clean ();31 }32 /**33 * @covers Zorille\framework\CustomizationSysprep::renvoi_donnees_soap34 */35 public function testrenvoi_donnees_soap_Exception() {36 $this ->expectException(Exception::class);37 $this->expectExceptionMessage( '(TESTS CustomizationSysprep) Il faut un guiUnattended' );38 $this->object ->renvoi_donnees_soap ();39 }40 /**41 * @covers Zorille\framework\CustomizationSysprep::renvoi_donnees_soap42 */43 public function testrenvoi_donnees_soap_Exception2() {44 $guiUnattended = $this ->createMock('Zorille\framework\CustomizationGuiUnattended' );45 $guiUnattended ->expects ( $this ->any () ) 46 ->method ( 'renvoi_objet_soap' ) 47 ->will ( $this ->returnValue ( array ( 48 "CustomizationGuiUnattended" ) ) );49 $this->object ->setGuiUnattended ( $guiUnattended );50 $this ->expectException(Exception::class);51 $this->expectExceptionMessage( '(TESTS CustomizationSysprep) Il faut un userData' );52 $this->object ->renvoi_donnees_soap ();53 }54 /**55 * @covers Zorille\framework\CustomizationSysprep::renvoi_donnees_soap56 */57 public function testrenvoi_donnees_soap_Exception3() {58 $guiUnattended = $this ->createMock('Zorille\framework\CustomizationGuiUnattended' );59 $guiUnattended ->expects ( $this ->any () ) 60 ->method ( 'renvoi_objet_soap' ) 61 ->will ( $this ->returnValue ( array ( 62 "CustomizationGuiUnattended" ) ) );63 $userData = $this ->createMock('Zorille\framework\CustomizationUserData' );64 $userData ->expects ( $this ->any () ) 65 ->method ( 'renvoi_objet_soap' ) 66 ->will ( $this ->returnValue ( array ( 67 "CustomizationUserData" ) ) );68 $this->object ->setGuiUnattended ( $guiUnattended ) 69 ->setUserData ( $userData );70 $this ->expectException(Exception::class);71 $this->expectExceptionMessage( '(TESTS CustomizationSysprep) Il faut une identification' );72 $this->object ->renvoi_donnees_soap ();73 }74 /**75 * @covers Zorille\framework\CustomizationSysprep::renvoi_donnees_soap76 */77 public function testrenvoi_donnees_soap() {78 $guiRunOnce = $this ->createMock('Zorille\framework\CustomizationGuiRunOnce' );79 $guiRunOnce ->expects ( $this ->any () ) 80 ->method ( 'renvoi_donnees_soap' ) 81 ->will ( $this ->returnValue ( array ( 82 "CustomizationGuiRunOnce" ) ) );83 $guiUnattended = $this ->createMock('Zorille\framework\CustomizationGuiUnattended' );84 $guiUnattended ->expects ( $this ->any () ) 85 ->method ( 'renvoi_objet_soap' ) 86 ->will ( $this ->returnValue ( array ( 87 "CustomizationGuiUnattended" ) ) );88 $identification = $this ->createMock('Zorille\framework\CustomizationIdentification' );89 $identification ->expects ( $this ->any () ) 90 ->method ( 'renvoi_objet_soap' ) 91 ->will ( $this ->returnValue ( array ( 92 "CustomizationIdentification" ) ) );93 $licenseFilePrintData = $this ->createMock('Zorille\framework\CustomizationLicenseFilePrintData' );94 $licenseFilePrintData ->expects ( $this ->any () ) 95 ->method ( 'renvoi_donnees_soap' ) 96 ->will ( $this ->returnValue ( array ( 97 "CustomizationLicenseFilePrintData" ) ) );98 $userData = $this ->createMock('Zorille\framework\CustomizationUserData' );99 $userData ->expects ( $this ->any () ) 100 ->method ( 'renvoi_objet_soap' ) 101 ->will ( $this ->returnValue ( array ( 102 "CustomizationUserData" ) ) );103 $this->object ->setGuiRunOnce ( $guiRunOnce ) 104 ->setGuiUnattended ( $guiUnattended ) 105 ->setIdentification ( $identification ) 106 ->setLicenseFilePrintData ( $licenseFilePrintData ) 107 ->setUserData ( $userData );108 $this ->assertEquals ( 109 array ( 110 'guiUnattended' => Array ( 111 "CustomizationGuiUnattended" ), 112 'userData' => Array ( 113 "CustomizationUserData" ), 114 'guiRunOnce' => array ( 115 "CustomizationGuiRunOnce" ), 116 'identification' => Array ( 117 "CustomizationIdentification" ), 118 'licenseFilePrintData' => Array ( 119 "CustomizationLicenseFilePrintData" ) ), 120 $this->object ->renvoi_donnees_soap () );121 }122 /**123 * @covers Zorille\framework\CustomizationSysprep::renvoi_donnees_soap124 */125 public function testrenvoi_donnees_soap_renvoi_objet() {126 $guiRunOnce = $this ->createMock('Zorille\framework\CustomizationGuiRunOnce' );127 $guiRunOnce ->expects ( $this ->any () ) 128 ->method ( 'renvoi_donnees_soap' ) 129 ->will ( $this ->returnValue ( array ( 130 "CustomizationGuiRunOnce" ) ) );131 $guiUnattended = $this ->createMock('Zorille\framework\CustomizationGuiUnattended' );132 $guiUnattended ->expects ( $this ->any () ) 133 ->method ( 'renvoi_objet_soap' ) 134 ->will ( $this ->returnValue ( array ( 135 "CustomizationGuiUnattended" ) ) );136 $identification = $this ->createMock('Zorille\framework\CustomizationIdentification' );137 $identification ->expects ( $this ->any () ) 138 ->method ( 'renvoi_objet_soap' ) 139 ->will ( $this ->returnValue ( array ( 140 "CustomizationIdentification" ) ) );141 $licenseFilePrintData = $this ->createMock('Zorille\framework\CustomizationLicenseFilePrintData' );142 $licenseFilePrintData ->expects ( $this ->any () ) 143 ->method ( 'renvoi_donnees_soap' ) 144 ->will ( $this ->returnValue ( array ( 145 "CustomizationLicenseFilePrintData" ) ) );146 $userData = $this ->createMock('Zorille\framework\CustomizationUserData' );147 $userData ->expects ( $this ->any () ) 148 ->method ( 'renvoi_objet_soap' ) 149 ->will ( $this ->returnValue ( array ( 150 "CustomizationUserData" ) ) );151 $this->object ->setGuiRunOnce ( $guiRunOnce ) 152 ->setGuiUnattended ( $guiUnattended ) 153 ->setIdentification ( $identification ) 154 ->setLicenseFilePrintData ( $licenseFilePrintData ) 155 ->setUserData ( $userData );156 $object = new arrayObject ( 157 array ( 158 'guiUnattended' => Array ( 159 "CustomizationGuiUnattended" ), 160 'userData' => Array ( 161 "CustomizationUserData" ), 162 'guiRunOnce' => array ( 163 "CustomizationGuiRunOnce" ), 164 'identification' => Array ( 165 "CustomizationIdentification" ), 166 'licenseFilePrintData' => Array ( 167 "CustomizationLicenseFilePrintData" ) ) );168 $this ->assertEquals ( $object, $this->object ->renvoi_donnees_soap ( true ) );169 }170 /**171 * @covers Zorille\framework\CustomizationSysprep::renvoi_objet_soap172 */173 public function testrenvoi_objet_soap_renvoi_objet() {174 $guiRunOnce = $this ->createMock('Zorille\framework\CustomizationGuiRunOnce' );175 $guiRunOnce ->expects ( $this ->any () ) 176 ->method ( 'renvoi_donnees_soap' ) 177 ->will ( $this ->returnValue ( array ( 178 "CustomizationGuiRunOnce" ) ) );179 $guiUnattended = $this ->createMock('Zorille\framework\CustomizationGuiUnattended' );180 $guiUnattended ->expects ( $this ->any () ) 181 ->method ( 'renvoi_objet_soap' ) 182 ->will ( $this ->returnValue ( array ( 183 "CustomizationGuiUnattended" ) ) );184 $identification = $this ->createMock('Zorille\framework\CustomizationIdentification' );185 $identification ->expects ( $this ->any () ) 186 ->method ( 'renvoi_objet_soap' ) 187 ->will ( $this ->returnValue ( array ( 188 "CustomizationIdentification" ) ) );189 $licenseFilePrintData = $this ->createMock('Zorille\framework\CustomizationLicenseFilePrintData' );190 $licenseFilePrintData ->expects ( $this ->any () ) 191 ->method ( 'renvoi_donnees_soap' ) 192 ->will ( $this ->returnValue ( array ( 193 "CustomizationLicenseFilePrintData" ) ) );194 $userData = $this ->createMock('Zorille\framework\CustomizationUserData' );195 $userData ->expects ( $this ->any () ) 196 ->method ( 'renvoi_objet_soap' ) 197 ->will ( $this ->returnValue ( array ( 198 "CustomizationUserData" ) ) );199 $this->object ->setGuiRunOnce ( $guiRunOnce ) 200 ->setGuiUnattended ( $guiUnattended ) 201 ->setIdentification ( $identification ) 202 ->setLicenseFilePrintData ( $licenseFilePrintData ) 203 ->setUserData ( $userData );204 $object = new arrayObject ( 205 array ( 206 'guiUnattended' => Array ( 207 "CustomizationGuiUnattended" ), 208 'userData' => Array ( 209 "CustomizationUserData" ), 210 'guiRunOnce' => array ( 211 "CustomizationGuiRunOnce" ), 212 'identification' => Array ( 213 "CustomizationIdentification" ), 214 'licenseFilePrintData' => Array ( 215 "CustomizationLicenseFilePrintData" ) ) );216 $resultat = new soapvar ( $object, SOAP_ENC_OBJECT, "CustomizationSysprep" );217 $this ->assertEquals ( $resultat, $this->object ->renvoi_objet_soap ( true ) );218 }219}...

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1$gui = new gui();2$gui->run();3$gui = new gui();4$gui->run();5$gui = new gui();6$gui->run();7$gui = new gui();8$gui->run();9$gui = new gui();10$gui->run();11$gui = new gui();12$gui->run();13$gui = new gui();14$gui->run();15$gui = new gui();16$gui->run();17$gui = new gui();18$gui->run();19$gui = new gui();20$gui->run();21$gui = new gui();22$gui->run();23$gui = new gui();24$gui->run();25$gui = new gui();26$gui->run();27$gui = new gui();28$gui->run();29$gui = new gui();30$gui->run();31$gui = new gui();32$gui->run();33$gui = new gui();34$gui->run();35$gui = new gui();36$gui->run();

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1$gui = new GUI();2$gui->run();3$gui = new GUI();4$gui->run();5$gui = new GUI();6$gui->run();7$gui = new GUI();8$gui->run();9$gui = new GUI();10$gui->run();11$gui = new GUI();12$gui->run();13$gui = new GUI();14$gui->run();15$gui = new GUI();16$gui->run();17$gui = new GUI();18$gui->run();19$gui = new GUI();20$gui->run();21$gui = new GUI();22$gui->run();23$gui = new GUI();24$gui->run();25$gui = new GUI();26$gui->run();27$gui = new GUI();28$gui->run();29$gui = new GUI();30$gui->run();31$gui = new GUI();32$gui->run();33$gui = new GUI();34$gui->run();35$gui = new GUI();36$gui->run();

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

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

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1$gui = new gui();2$gui->run('gui');3$gui = new gui();4$gui->run('gui');5$gui = new gui();6$gui->run('gui');7$gui = new gui();8$gui->run('gui');9$gui = new gui();10$gui->run('gui');11$gui = new gui();12$gui->run('gui');13$gui = new gui();14$gui->run('gui');15$gui = new gui();16$gui->run('gui');17$gui = new gui();18$gui->run('gui');19$gui = new gui();20$gui->run('gui');21$gui = new gui();22$gui->run('gui');23$gui = new gui();24$gui->run('gui');25$gui = new gui();26$gui->run('gui');27$gui = new gui();28$gui->run('gui');29$gui = new gui();30$gui->run('gui');31$gui = new gui();32$gui->run('gui');33$gui = new gui();34$gui->run('gui');

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1$gui = new gui();2$gui->run();3class gui {4 public function run() {5 }6}7$gui = new gui();8$gui->run();9class gui {10 public function run() {11 }12}13$gui = new gui();14$gui->run();15class gui {16 public function run() {17 }18}19$gui = new gui();20$gui->run();21class gui {22 public function run() {23 }24}25$gui = new gui();26$gui->run();27class gui {28 public function run() {29 }30}31$gui = new gui();32$gui->run();33class gui {34 public function run() {35 }36}37$gui = new gui();38$gui->run();39class gui {40 public function run() {41 }42}43$gui = new gui();44$gui->run();45class gui {46 public function run() {47 }48}49$gui = new gui();50$gui->run();51class gui {52 public function run() {53 }54}55$gui = new gui();56$gui->run();57class gui {

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1$gui = new Gui();2$gui->run();3class Gui {4 public function run() {5 echo "GUI is running";6 }7}8class Console {9 public function run() {10 echo "Console is running";11 }12}13require_once('gui.php');14require_once('console.php');15require_once('2.php');16$gui = new Gui();17$gui->run();18class Gui {19 public function run() {20 echo "GUI is running";21 }22}23class Console {24 public function run() {25 echo "Console is running";26 }27}28require_once('gui.php');29require_once('console.php');30require_once('3.php');31$gui = new Gui();32$gui->run();33class Gui {34 public function run() {35 echo "GUI is running";36 }37}

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1require_once('gui.php');2$gui = new gui('gui');3$gui->run();4class gui {5 function gui($name) {6 $this->name = $name;7 }8 function run() {9 echo "Running $this->name";10 }11}

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1$gui = new gui();2$gui->run();3class gui {4 function run() {5 echo "Hello World";6 }7}8class gui {9 function run() {10 echo "Hello World";11 }12}13$gui = new gui();14$gui->run();15$gui = new gui();16$gui->run();17$gui = new gui();18$gui->run();19$gui = new gui();20$gui->run();21$gui = new gui();22$gui->run();

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 Phoronix-test-suite automation tests on LambdaTest cloud grid

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

Most used method in gui

Trigger run code on LambdaTest Cloud Grid

Execute automation tests with run 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