Best Phoronix-test-suite code snippet using run_test.run
xmlrpc-client.php
Source:xmlrpc-client.php
...100}101function foo($method_name, $args) {102 xmlrpc_encode_request($method_name, $args);103}104function run_test($server, $debug, $output, $method, $args='', $expected='') {105 global $HTTP_GET_VARS;106 echo "<hr>";107 if (!is_array($args))108 $params = $args ? array($args) : array();109 else110 $params = $args;111 if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support112 $server['uri'] .= "?start_debug=1";113 $result = xu_rpc_http_concise(array('method' => $method,114 'args' => $params, 115 'host' => $server['host'], 116 'uri' => $server['uri'], 117 'port' => $server['port'], 118 'debug' => $debug,119 'output' => $output));120 check_if_matches($method, $expected, $result);121 echo "</hr>";122 flush();123}124// should return non-zero integer125function run_no_param_test($server, $debug, $output, $method) {126 global $HTTP_GET_VARS;127 echo "<hr>";128 if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support129 $server['uri'] .= "?start_debug=1";130 $result = xu_rpc_http_concise(array('method' => $method,131 'host' => $server['host'], 132 'uri' => $server['uri'], 133 'port' => $server['port'], 134 'debug' => $debug,135 'output' => $output));136 if ($result && gettype($result) === "integer") {137 pass($method);138 }139 else {140 fail($method, false, $result);141 }142 143 flush();144}145// a method to run wiki tests against remote server. tests described at bottom.146function run_easy_tests($server, $debug=0, $output = null) {147 //global $wiki_dmap;148 run_test($server, $debug, $output, "wiki.getRPCVersionSupported", '', 1);149 150 // getRecentChanges of the last day:151 // Note: may crash with dba on index.php, not on RPC2.php152 run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time()-86400));153 154 run_test($server, $debug, $output, "wiki.getPage", "HomePage", "* What is a WikiWikiWeb? A description of this application. * Learn HowToUseWiki and learn about AddingPages. * Use the SandBox page to experiment with Wiki pages. * Please sign your name in RecentVisitors. * See RecentChanges for the latest page additions and changes. * Find out which pages are MostPopular. * Read the ReleaseNotes and RecentReleases. * Administer this wiki via PhpWikiAdministration. * See more PhpWikiDocumentation.");155 run_test($server, $debug, $output, "wiki.getPageVersion", array("HomePage", 1));156 run_test($server, $debug, $output, "wiki.getPageHTML", "HomePage");157 run_test($server, $debug, $output, "wiki.getPageHTMLVersion", array("HomePage", 1));158 run_test($server, $debug, $output, "wiki.getAllPages");159 run_test($server, $debug, $output, "wiki.getPageInfo", "HomePage");160 run_test($server, $debug, $output, "wiki.getPageInfoVersion", array("HomePage", 1));161 run_test($server, $debug, $output, "wiki.listLinks", "HomePage");162 run_test($server, $debug, $output, "wiki.putPage", 163 array("PutPage", "new PutPage content", "XxXx"),164 array('code' => 200, 'version' => 1, 'message' => "Page PutPage version 1 created"));165 run_test($server, $debug, $output, "wiki.putPage", 166 array("PutPage", "new PutPage content", "XxXx"),167 array('code' => 400, 'version' => 1, 'message' => "Page PutPage unchanged"));168 run_test($server, $debug, $output, "wiki.putPage",169 array("PutPage", "new PutPage content", "disallowed"),170 array('code' => 401, 'version' => 0, 'message' => "no permission for disallowed"));171 run_test($server, $debug, $output, "wiki.rssPleaseNotify", "HomePage", 0);172 run_test($server, $debug, $output, "wiki.mailPasswordToUser", ADMIN_USER);173 run_test($server, $debug, $output, "wiki.titleSearch", "Hom");174}175function run_stress_tests($server, $debug=0, $output=null) {176 global $wiki_dmap;177 run_no_param_test($server, $debug, $output, "wiki.getRPCVersionSupported");178 // of the last day:179 run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time()-86400, 1));180 /* ... */181}182// a method to display an html form for invoking the script183function print_html_form($servers_list) {184 echo <<< END185<h1>Choose an xmlrpc wiki server to run tests against</h1>186END;187 print_servers_form($servers_list);188}189// some code which determines if we are in form display or response mode.190$server_list = get_wiki_servers();191$server = get_server_from_user($server_list);192if ($server) {193 $debug = $GLOBALS['HTTP_GET_VARS']['debug'] || $GLOBALS['HTTP_GET_VARS']['start_debug'];194 $output['version'] = $GLOBALS['HTTP_GET_VARS']['version'];195 if ($server) {196 $title = $server['title'];197 echo "<h2><center>Results for $title</center></h2>";198 199 if($GLOBALS['HTTP_GET_VARS']['stress'] == 1) {200 run_stress_tests($server, $debug, $output);201 }202 else {203 run_easy_tests($server, $debug, $output);204 }205 }206 else {207 echo "<h3>invalid option</h3>";208 }209}210else {211 print_html_form($server_list);212}...
expparser_searchfilter_Test.php
Source:expparser_searchfilter_Test.php
...8 /* ******9 * Test correct simple queries for table access10 */11 public function test_host() {12 $parser = $this->run_test('h:kaka', array( 'filters'=>array(13 'hosts'=>array(array('kaka'))14 ) ) );15 }16 public function test_service() {17 $parser = $this->run_test('s:kaka', array( 'filters'=>array(18 'services'=>array(array('kaka'))19 ) ) );20 }21 public function test_comments() {22 $parser = $this->run_test('c:kaka', array( 'filters'=>array(23 'comments'=>array(array('kaka'))24 )) );25 }26 public function test_status() {27 $parser = $this->run_test('si:kaka', array( 'filters'=>array(28 '_si'=>array(array('kaka'))29 )) );30 }31 public function test_hostgroups() {32 $parser = $this->run_test('hg:kaka', array( 'filters'=>array(33 'hostgroups'=>array(array('kaka'))34 )) );35 }36 public function test_servicegroups() {37 $parser = $this->run_test('sg:kaka', array( 'filters'=>array(38 'servicegroups'=>array(array('kaka'))39 )) );40 }41 /* ******42 * Test simple queries with whitespace arguments and or43 */44 public function test_space_argument() {45 $parser = $this->run_test('h:kaka boll or kalles serviceverkstad ', array( 'filters'=>array(46 'hosts'=>array(array('kaka boll','kalles serviceverkstad'))47 )) );48 }49 /* ******50 * Test correct queries with boolean operators51 */52 public function test_same_and() {53 $parser = $this->run_test('h:hostkaka and h:hostkoko', array( 'filters'=>array(54 'hosts'=>array(array('hostkaka'),array('hostkoko')),55 ) ) );56 }57 public function test_diff_and() {58 $parser = $this->run_test('h:hostkaka and s:svckaka', array( 'filters'=>array(59 'hosts'=>array(array('hostkaka')),60 'services'=>array(array('svckaka'))61 ) ) );62 }63 public function test_or() {64 $parser = $this->run_test('h:hostkaka or hostkoko', array( 'filters'=>array(65 'hosts'=>array(array('hostkaka', 'hostkoko'))66 ) ) );67 }68 /* ******69 * Test correct queries with autocompletion extraction of last fields70 */71 public function test_autocomplete_first() {72 $parser = $this->run_test('h:kaka', array('filters'=>array('hosts'=>array(array('kaka')) )) );73 $this->assertEquals( $parser->getLastString(), 'kaka', "Autocomplete: doesn't return correct string" );74 $this->assertEquals( $parser->getLastObject(), 'hosts', "Autocomplete: doesn't return correct object type" );75 }76 public function test_autocomplete_or() {77 $parser = $this->run_test('h:kaka or boll', array('filters'=>array('hosts'=>array(array('kaka','boll')) )) );78 $this->assertEquals( $parser->getLastString(), 'boll', "Autocomplete: doesn't return correct string" );79 $this->assertEquals( $parser->getLastObject(), 'hosts', "Autocomplete: doesn't return correct object type" );80 }81 public function test_autocomplete_and() {82 $parser = $this->run_test('h:kaka and s:boll', array('filters'=>array(83 'hosts'=>array(array('kaka')),84 'services'=>array(array('boll'))85 )) );86 $this->assertEquals( $parser->getLastString(), 'boll', "Autocomplete: doesn't return correct string" );87 $this->assertEquals( $parser->getLastObject(), 'services', "Autocomplete: doesn't return correct object type" );88 }89 /* *******90 * Test correct queries with limit91 */92 public function test_limit() {93 $this->run_test('h:kaka limit=13', array(94 'filters'=>array('hosts'=>array(array('kaka')) ),95 'limit' => 1396 ) );97 }98 public function test_fail_args() {99 $this->run_test('h:kaka limit=13', array(100 'filters'=>array('hosts'=>array(array('kaka')) ),101 'limit' => 13102 ) );103 }104 /* ******105 * Test incorrect tables106 */107 public function test_invalid_table() {108 try {109 $this->run_test('x:doesntexist', false);110 $this->fail( 'Should have thrown an exception');111 }112 catch( ExpParserException $e ) {113 $this->assertTrue(114 1===preg_match('/^Unexpected token.*$/',$e->getMessage()),115 'Incorrect Exception for unexpected token: '.$e->getMessage()116 );117 }118 }119 /* ******120 * Test incomplete limit121 */122 public function test_incomplete_limit() {123 try {124 $this->run_test('h:doesntexist limit=', false);125 $this->fail( 'Should have thrown an exception');126 }127 catch( ExpParserException $e ) {128 $this->assertTrue(129 1===preg_match('/^Unexpected token.*expected number.*$/',$e->getMessage()),130 'Incorrect Exception for unexpected token: '.$e->getMessage()131 );132 }133 }134 /* ******135 * Test case sensitivity136 */137 public function test_case_uppercase_and() {138 $parser = $this->run_test('h:hostkaka AND h:hostkoko', array( 'filters'=>array(139 'hosts'=>array(array('hostkaka'),array('hostkoko')),140 ) ) );141 }142 public function test_case_uppercase_or() {143 $parser = $this->run_test('h:hostkaka OR hostkoko', array( 'filters'=>array(144 'hosts'=>array(array('hostkaka', 'hostkoko'))145 ) ) );146 }147 public function test_case_mixcase_and() {148 $parser = $this->run_test('h:hostkaka aNd h:hostkoko', array( 'filters'=>array(149 'hosts'=>array(array('hostkaka'),array('hostkoko')),150 ) ) );151 }152 public function test_case_mixcase_or() {153 $parser = $this->run_test('h:hostkaka oR hostkoko', array( 'filters'=>array(154 'hosts'=>array(array('hostkaka', 'hostkoko'))155 ) ) );156 }157 /* ******158 * Internal library159 */160 private function run_test( $query, $expect ) {161 $parser = new ExpParser_SearchFilter(array(162 'h' => 'hosts',163 's' => 'services',164 'c' => 'comments',165 'hg' => 'hostgroups',166 'sg' => 'servicegroups',167 'si' => '_si'168 ));169 $result = $parser->parse( $query );170 $this->assertEquals( $result, $expect, "SearchFilter query '$query' doesn't match expected result." );171 return $parser;172 }173}...
Mail.php
Source:Mail.php
...36 */37 public function validate(Validator $validator): void38 {39 if (Config::get('alert.transports.mail') === true) {40 $run_test = 1;41 if (! Config::has('alert.default_mail')) {42 $validator->fail('default_mail config option needs to be specified to test email');43 $run_test = 0;44 } elseif (Config::get('email_backend') == 'sendmail') {45 if (! Config::has('email_sendmail_path')) {46 $validator->fail('You have selected sendmail but not configured email_sendmail_path');47 $run_test = 0;48 } elseif (! file_exists(Config::get('email_sendmail_path'))) {49 $validator->fail('The configured email_sendmail_path is not valid');50 $run_test = 0;51 }52 } elseif (Config::get('email_backend') == 'smtp') {53 if (! Config::has('email_smtp_host')) {54 $validator->fail('You have selected SMTP but not configured an SMTP host');55 $run_test = 0;56 }57 if (! Config::has('email_smtp_port')) {58 $validator->fail('You have selected SMTP but not configured an SMTP port');59 $run_test = 0;60 }61 if (Config::get('email_smtp_auth')62 && (! Config::has('email_smtp_username') || ! Config::has('email_smtp_password'))63 ) {64 $validator->fail('You have selected SMTP auth but have not configured both username and password');65 $run_test = 0;66 }67 }//end if68 if ($run_test == 1) {69 $email = Config::get('alert.default_mail');70 if ($err = send_mail($email, 'Test email', 'Testing email from NMS')) {71 $validator->ok('Email has been sent');72 } else {73 $validator->fail("Issue sending email to $email with error $err");74 }75 }76 }//end if77 }78}...
run
Using AI Code Generation
1$obj = new run_test();2$obj->run();3$obj = new run_test();4$obj->run();5$obj = new run_test();6$obj->run();7$obj = new run_test();8$obj->run();9$obj = new run_test();10$obj->run();11$obj = new run_test();12$obj->run();13$obj = new run_test();14$obj->run();15$obj = new run_test();16$obj->run();17$obj = new run_test();18$obj->run();19$obj = new run_test();20$obj->run();21$obj = new run_test();22$obj->run();23$obj = new run_test();24$obj->run();25$obj = new run_test();26$obj->run();27$obj = new run_test();28$obj->run();29$obj = new run_test();30$obj->run();31$obj = new run_test();32$obj->run();33$obj = new run_test();34$obj->run();35$obj = new run_test();36$obj->run();
run
Using AI Code Generation
1$run_test = new run_test();2$run_test->run();3$run_test = new run_test();4$run_test->run();5$run_test = new run_test();6$run_test->run();7$run_test = new run_test();8$run_test->run();9$run_test = new run_test();10$run_test->run();11$run_test = new run_test();12$run_test->run();13$run_test = new run_test();14$run_test->run();15$run_test = new run_test();16$run_test->run();17$run_test = new run_test();18$run_test->run();19$run_test = new run_test();20$run_test->run();21$run_test = new run_test();22$run_test->run();23$run_test = new run_test();24$run_test->run();25$run_test = new run_test();26$run_test->run();27$run_test = new run_test();28$run_test->run();29$run_test = new run_test();30$run_test->run();31$run_test = new run_test();32$run_test->run();
run
Using AI Code Generation
1$run_test_obj = new run_test();2$run_test_obj->run();3$run_test_obj = new run_test();4$run_test_obj->run();5$run_test_obj = new run_test();6$run_test_obj->run();7$run_test_obj = new run_test();8$run_test_obj->run();9$run_test_obj = new run_test();10$run_test_obj->run();11$run_test_obj = new run_test();12$run_test_obj->run();13$run_test_obj = new run_test();14$run_test_obj->run();15$run_test_obj = new run_test();16$run_test_obj->run();17$run_test_obj = new run_test();18$run_test_obj->run();19$run_test_obj = new run_test();20$run_test_obj->run();21$run_test_obj = new run_test();22$run_test_obj->run();23$run_test_obj = new run_test();24$run_test_obj->run();25$run_test_obj = new run_test();26$run_test_obj->run();27$run_test_obj = new run_test();28$run_test_obj->run();29$run_test_obj = new run_test();30$run_test_obj->run();
run
Using AI Code Generation
1require_once 'run_test.php';2$run = new run_test();3$run->run();4require_once 'run_test.php';5$run = new run_test();6$run->run();7require_once 'run_test.php';8$run = new run_test();9$run->run();10require_once 'run_test.php';11$run = new run_test();12$run->run();13require_once 'run_test.php';14$run = new run_test();15$run->run();16require_once 'run_test.php';17$run = new run_test();18$run->run();19require_once 'run_test.php';20$run = new run_test();21$run->run();22require_once 'run_test.php';23$run = new run_test();24$run->run();25require_once 'run_test.php';26$run = new run_test();27$run->run();28require_once 'run_test.php';29$run = new run_test();30$run->run();31require_once 'run_test.php';32$run = new run_test();33$run->run();34require_once 'run_test.php';35$run = new run_test();36$run->run();37require_once 'run_test.php';38$run = new run_test();39$run->run();40require_once 'run_test.php';41$run = new run_test();
run
Using AI Code Generation
1require_once('run_test.php');2$run_test = new run_test();3$run_test->run();4require_once('run_test.php');5$run_test = new run_test();6$run_test->run();7{8 public function run()9 {10 echo 'This is run method';11 }12}
run
Using AI Code Generation
1$run = new run_test();2$run->run();3{4 var $test;5 function run()6 {7 $test = new test();8 $test->test1();9 $test->test2();10 $test->test3();11 }12}13{14 function test1()15 {16 echo "test1";17 }18 function test2()19 {20 echo "test2";21 }22 function test3()23 {24 echo "test3";25 }26}
run
Using AI Code Generation
1$obj = new run_test();2$obj->run('test');3class run_test{4 function run($method){5 $this->$method();6 }7 function test(){8 echo 'test';9 }10}11$obj = new run_test();12$obj->run('test');
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
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 FreeGet 100 minutes of automation test minutes FREE!!