当前位置: 首页>>代码示例>>PHP>>正文


PHP behat_context_helper::set_session方法代码示例

本文整理汇总了PHP中behat_context_helper::set_session方法的典型用法代码示例。如果您正苦于以下问题:PHP behat_context_helper::set_session方法的具体用法?PHP behat_context_helper::set_session怎么用?PHP behat_context_helper::set_session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在behat_context_helper的用法示例。


在下文中一共展示了behat_context_helper::set_session方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: before_scenario

 /**
  * Resets the test environment.
  *
  * @param OutlineExampleEvent|ScenarioEvent $event event fired before scenario.
  * @throws coding_exception If here we are not using the test database it should be because of a coding error
  * @BeforeScenario
  */
 public function before_scenario($event)
 {
     global $DB, $CFG;
     // TODO: check config value to ensure site is set for performance data.
     $moreinfo = 'More info in ' . behat_command::DOCS_URL . '#Running_tests';
     $driverexceptionmsg = 'Selenium server is not running, you need to start it to run tests that involve Javascript. ' . $moreinfo;
     try {
         $session = $this->getSession();
     } catch (CurlExec $e) {
         // Exception thrown by WebDriver, so only @javascript tests will be caugth; in
         // behat_util::is_server_running() we already checked that the server is running.
         throw new Exception($driverexceptionmsg);
     } catch (DriverException $e) {
         throw new Exception($driverexceptionmsg);
     } catch (UnknownError $e) {
         // Generic 'I have no idea' Selenium error. Custom exception to provide more feedback about possible solutions.
         $this->throw_unknown_exception($e);
     }
     // We need the Mink session to do it and we do it only before the first scenario.
     if (self::is_first_scenario()) {
         behat_selectors::register_moodle_selectors($session);
         behat_context_helper::set_session($session);
     }
     // Reset mink session between the scenarios.
     $session->reset();
     // Assign valid data to admin user (some generator-related code needs a valid user).
     $user = $DB->get_record('user', array('username' => 'admin'));
     \core\session\manager::set_user($user);
     // Start always in the the homepage.
     try {
         // Let's be conservative as we never know when new upstream issues will affect us.
         $session->visit($this->locate_path('/'));
     } catch (UnknownError $e) {
         $this->throw_unknown_exception($e);
     }
     // Checking that the root path is a Moodle test site.
     /*if (self::is_first_scenario()) {
                 $notestsiteexception = new Exception('The base URL (' . $CFG->wwwroot . ') is not a behat test site, ' .
                     'ensure you started the built-in web server in the correct directory or your web server is correctly started and set up');
                 $this->find("xpath", "//head/child::title[normalize-space(.)='" . behat_util::BEHATSITENAME . "']", $notestsiteexception);
     
                 self::$initprocessesfinished = true;
             }*/
 }
开发者ID:rajeshtaneja,项目名称:moodle-performance-toolkit,代码行数:51,代码来源:behat_hooks.php

示例2: before_scenario

 /**
  * Resets the test environment.
  *
  * @param OutlineExampleEvent|ScenarioEvent $event event fired before scenario.
  * @throws coding_exception If here we are not using the test database it should be because of a coding error
  * @BeforeScenario
  */
 public function before_scenario(BeforeScenario $event)
 {
     global $DB, $CFG;
     // TODO: check config value to ensure site is set for performance data.
     $moreinfo = 'More info in ' . behat_command::DOCS_URL . '#Running_tests';
     $driverexceptionmsg = 'Selenium server is not running, you need to start it to run tests that involve Javascript. ' . $moreinfo;
     try {
         $session = $this->getSession();
     } catch (CurlExec $e) {
         // Exception thrown by WebDriver, so only @javascript tests will be caugth; in
         // behat_util::is_server_running() we already checked that the server is running.
         throw new Exception($driverexceptionmsg);
     } catch (DriverException $e) {
         throw new Exception($driverexceptionmsg);
     } catch (UnknownError $e) {
         // Generic 'I have no idea' Selenium error. Custom exception to provide more feedback about possible solutions.
         $this->throw_unknown_exception($e);
     }
     // We need the Mink session to do it and we do it only before the first scenario.
     if (self::is_first_scenario()) {
         behat_selectors::register_moodle_selectors($session);
         behat_context_helper::set_session($session);
         // Ensure performance site is enable.
         if (!get_config('core', 'performancesitedata')) {
             $notperformancesite = "This is not a performance site" . PHP_EOL . " - Run vendor/bin/moodle_performance_site --enable=s" . PHP_EOL;
             throw new Exception($notperformancesite);
         }
     }
     // Start a new thread group.
     testplan_writer::start_thread_group(self::$featurefile, self::$threadgroupname);
 }
开发者ID:rajeshtaneja,项目名称:moodle-performance-tool,代码行数:38,代码来源:behat_hooks.php

示例3: before_scenario

 /**
  * Resets the test environment.
  *
  * @throws coding_exception If here we are not using the test database it should be because of a coding error
  * @BeforeScenario
  */
 public function before_scenario($event)
 {
     global $DB, $SESSION, $CFG;
     // As many checks as we can.
     if (!defined('BEHAT_TEST') || !defined('BEHAT_SITE_RUNNING') || php_sapi_name() != 'cli' || !behat_util::is_test_mode_enabled() || !behat_util::is_test_site()) {
         throw new coding_exception('Behat only can modify the test database and the test dataroot!');
     }
     $moreinfo = 'More info in ' . behat_command::DOCS_URL . '#Running_tests';
     $driverexceptionmsg = 'Selenium server is not running, you need to start it to run tests that involve Javascript. ' . $moreinfo;
     try {
         $session = $this->getSession();
     } catch (CurlExec $e) {
         // Exception thrown by WebDriver, so only @javascript tests will be caugth; in
         // behat_util::is_server_running() we already checked that the server is running.
         throw new Exception($driverexceptionmsg);
     } catch (DriverException $e) {
         throw new Exception($driverexceptionmsg);
     } catch (UnknownError $e) {
         // Generic 'I have no idea' Selenium error. Custom exception to provide more feedback about possible solutions.
         $this->throw_unknown_exception($e);
     }
     // We need the Mink session to do it and we do it only before the first scenario.
     if (self::is_first_scenario()) {
         behat_selectors::register_moodle_selectors($session);
         behat_context_helper::set_session($session);
     }
     // Reset $SESSION.
     \core\session\manager::init_empty_session();
     behat_util::reset_database();
     behat_util::reset_dataroot();
     accesslib_clear_all_caches(true);
     // Reset the nasty strings list used during the last test.
     nasty_strings::reset_used_strings();
     // Assign valid data to admin user (some generator-related code needs a valid user).
     $user = $DB->get_record('user', array('username' => 'admin'));
     \core\session\manager::set_user($user);
     // Reset the browser if specified in config.php.
     if (!empty($CFG->behat_restart_browser_after) && $this->running_javascript()) {
         $now = time();
         if (self::$lastbrowsersessionstart + $CFG->behat_restart_browser_after < $now) {
             $session->restart();
             self::$lastbrowsersessionstart = $now;
         }
     }
     // Start always in the the homepage.
     try {
         // Let's be conservative as we never know when new upstream issues will affect us.
         $session->visit($this->locate_path('/'));
     } catch (UnknownError $e) {
         $this->throw_unknown_exception($e);
     }
     // Checking that the root path is a Moodle test site.
     if (self::is_first_scenario()) {
         $notestsiteexception = new Exception('The base URL (' . $CFG->wwwroot . ') is not a behat test site, ' . 'ensure you started the built-in web server in the correct directory or your web server is correctly started and set up');
         $this->find("xpath", "//head/child::title[normalize-space(.)='" . behat_util::BEHATSITENAME . "']", $notestsiteexception);
         self::$initprocessesfinished = true;
     }
     // Run all test with medium (1024x768) screen size, to avoid responsive problems.
     $this->resize_window('medium');
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:66,代码来源:behat_hooks.php

示例4: before_scenario

 /**
  * Resets the test environment.
  *
  * @param OutlineExampleEvent|ScenarioEvent $event event fired before scenario.
  * @throws coding_exception If here we are not using the test database it should be because of a coding error
  * @BeforeScenario
  */
 public function before_scenario($event)
 {
     global $DB, $CFG;
     // TODO: check config value to ensure site is set for performance data.
     $moreinfo = 'More info in ' . behat_command::DOCS_URL . '#Running_tests';
     $driverexceptionmsg = 'Selenium server is not running, you need to start it to run tests that involve Javascript. ' . $moreinfo;
     try {
         $session = $this->getSession();
     } catch (CurlExec $e) {
         // Exception thrown by WebDriver, so only @javascript tests will be caugth; in
         // behat_util::is_server_running() we already checked that the server is running.
         throw new Exception($driverexceptionmsg);
     } catch (DriverException $e) {
         throw new Exception($driverexceptionmsg);
     } catch (UnknownError $e) {
         // Generic 'I have no idea' Selenium error. Custom exception to provide more feedback about possible solutions.
         $this->throw_unknown_exception($e);
     }
     // We need the Mink session to do it and we do it only before the first scenario.
     if (self::is_first_scenario()) {
         behat_selectors::register_moodle_selectors($session);
         behat_context_helper::set_session($session);
     }
     // Reset mink session between the scenarios.
     $session->reset();
     // Assign valid data to admin user (some generator-related code needs a valid user).
     $user = $DB->get_record('user', array('username' => 'admin'));
     \core\session\manager::set_user($user);
     // Start always in the the homepage.
     try {
         // Let's be conservative as we never know when new upstream issues will affect us.
         $session->visit($this->locate_path('/'));
     } catch (UnknownError $e) {
         $this->throw_unknown_exception($e);
     }
 }
开发者ID:rajeshtaneja,项目名称:moodle-behat-generator,代码行数:43,代码来源:behat_hooks.php


注:本文中的behat_context_helper::set_session方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。