original_string: public static function behat_setup_problem() {
          global $CFG;
  
          // Moodle setting.
          if (!self::are_behat_dependencies_installed()) {
  
              // Returning composer error code to avoid conflicts with behat and moodle error codes.
              self::output_msg(get_string('errorcomposer', 'tool_behat'));
              return TESTING_EXITCODE_COMPOSER;
          }
  
          // Behat test command.
          list($output, $code) = self::run(' --help');
  
          if ($code != 0) {
  
              // Returning composer error code to avoid conflicts with behat and moodle error codes.
              self::output_msg(get_string('errorbehatcommand', 'tool_behat', self::get_behat_command()));
              return TESTING_EXITCODE_COMPOSER;
          }
  
          // No empty values.
          if (empty($CFG->behat_dataroot) || empty($CFG->behat_prefix) || empty($CFG->behat_wwwroot)) {
              self::output_msg(get_string('errorsetconfig', 'tool_behat'));
              return BEHAT_EXITCODE_CONFIG;
  
          }
  
          // Not repeated values.
          // We only need to check this when the behat site is not running as
          // at this point, when it is running, all $CFG->behat_* vars have
          // already been copied to $CFG->dataroot, $CFG->prefix and $CFG->wwwroot.
          if (!defined('BEHAT_SITE_RUNNING') &&
                  ($CFG->behat_prefix == $CFG->prefix ||
                  $CFG->behat_dataroot == $CFG->dataroot ||
                  $CFG->behat_wwwroot == $CFG->wwwroot ||
                  (!empty($CFG->phpunit_prefix) && $CFG->phpunit_prefix == $CFG->behat_prefix) ||
                  (!empty($CFG->phpunit_dataroot) && $CFG->phpunit_dataroot == $CFG->behat_dataroot)
                  )) {
              self::output_msg(get_string('erroruniqueconfig', 'tool_behat'));
              return BEHAT_EXITCODE_CONFIG;
          }
  
          // Checking behat dataroot existence otherwise echo about admin/tool/behat/cli/init.php.
          if (!empty($CFG->behat_dataroot)) {
              $CFG->behat_dataroot = realpath($CFG->behat_dataroot);
          }
          if (empty($CFG->behat_dataroot) || !is_dir($CFG->behat_dataroot) || !is_writable($CFG->behat_dataroot)) {
              self::output_msg(get_string('errordataroot', 'tool_behat'));
              return BEHAT_EXITCODE_CONFIG;
          }
  
          // If app config is supplied, check the value is correct.
          if (!empty($CFG->behat_ionic_dirroot) && !file_exists($CFG->behat_ionic_dirroot . '/ionic.config.json')) {
              self::output_msg(get_string('errorapproot', 'tool_behat'));
              return BEHAT_EXITCODE_CONFIG;
          }
  
          return 0;
      }
code: public static function behat_setup_problem() {
          global $CFG;
  
          // Moodle setting.
          if (!self::are_behat_dependencies_installed()) {
  
              // Returning composer error code to avoid conflicts with behat and moodle error codes.
              self::output_msg(get_string('errorcomposer', 'tool_behat'));
              return TESTING_EXITCODE_COMPOSER;
          }
  
          // Behat test command.
          list($output, $code) = self::run(' --help');
  
          if ($code != 0) {
  
              // Returning composer error code to avoid conflicts with behat and moodle error codes.
              self::output_msg(get_string('errorbehatcommand', 'tool_behat', self::get_behat_command()));
              return TESTING_EXITCODE_COMPOSER;
          }
  
          // No empty values.
          if (empty($CFG->behat_dataroot) || empty($CFG->behat_prefix) || empty($CFG->behat_wwwroot)) {
              self::output_msg(get_string('errorsetconfig', 'tool_behat'));
              return BEHAT_EXITCODE_CONFIG;
  
          }
  
          // Not repeated values.
          // We only need to check this when the behat site is not running as
          // at this point, when it is running, all $CFG->behat_* vars have
          // already been copied to $CFG->dataroot, $CFG->prefix and $CFG->wwwroot.
          if (!defined('BEHAT_SITE_RUNNING') &&
                  ($CFG->behat_prefix == $CFG->prefix ||
                  $CFG->behat_dataroot == $CFG->dataroot ||
                  $CFG->behat_wwwroot == $CFG->wwwroot ||
                  (!empty($CFG->phpunit_prefix) && $CFG->phpunit_prefix == $CFG->behat_prefix) ||
                  (!empty($CFG->phpunit_dataroot) && $CFG->phpunit_dataroot == $CFG->behat_dataroot)
                  )) {
              self::output_msg(get_string('erroruniqueconfig', 'tool_behat'));
              return BEHAT_EXITCODE_CONFIG;
          }
  
          // Checking behat dataroot existence otherwise echo about admin/tool/behat/cli/init.php.
          if (!empty($CFG->behat_dataroot)) {
              $CFG->behat_dataroot = realpath($CFG->behat_dataroot);
          }
          if (empty($CFG->behat_dataroot) || !is_dir($CFG->behat_dataroot) || !is_writable($CFG->behat_dataroot)) {
              self::output_msg(get_string('errordataroot', 'tool_behat'));
              return BEHAT_EXITCODE_CONFIG;
          }
  
          // If app config is supplied, check the value is correct.
          if (!empty($CFG->behat_ionic_dirroot) && !file_exists($CFG->behat_ionic_dirroot . '/ionic.config.json')) {
              self::output_msg(get_string('errorapproot', 'tool_behat'));
              return BEHAT_EXITCODE_CONFIG;
          }
  
          return 0;
      }
code_tokens: public static function behat_setup_problem ( ) { global $ CFG ; // Moodle setting. if ( ! self :: are_behat_dependencies_installed ( ) ) { // Returning composer error code to avoid conflicts with behat and moodle error codes. self :: output_msg ( get_string ( 'errorcomposer' , 'tool_behat' ) ) ; return TESTING_EXITCODE_COMPOSER ; } // Behat test command. list ( $ output , $ code ) = self :: run ( ' --help' ) ; if ( $ code != 0 ) { // Returning composer error code to avoid conflicts with behat and moodle error codes. self :: output_msg ( get_string ( 'errorbehatcommand' , 'tool_behat' , self :: get_behat_command ( ) ) ) ; return TESTING_EXITCODE_COMPOSER ; } // No empty values. if ( empty ( $ CFG -> behat_dataroot ) || empty ( $ CFG -> behat_prefix ) || empty ( $ CFG -> behat_wwwroot ) ) { self :: output_msg ( get_string ( 'errorsetconfig' , 'tool_behat' ) ) ; return BEHAT_EXITCODE_CONFIG ; } // Not repeated values. // We only need to check this when the behat site is not running as // at this point, when it is running, all $CFG->behat_* vars have // already been copied to $CFG->dataroot, $CFG->prefix and $CFG->wwwroot. if ( ! defined ( 'BEHAT_SITE_RUNNING' ) && ( $ CFG -> behat_prefix == $ CFG -> prefix || $ CFG -> behat_dataroot == $ CFG -> dataroot || $ CFG -> behat_wwwroot == $ CFG -> wwwroot || ( ! empty ( $ CFG -> phpunit_prefix ) && $ CFG -> phpunit_prefix == $ CFG -> behat_prefix ) || ( ! empty ( $ CFG -> phpunit_dataroot ) && $ CFG -> phpunit_dataroot == $ CFG -> behat_dataroot ) ) ) { self :: output_msg ( get_string ( 'erroruniqueconfig' , 'tool_behat' ) ) ; return BEHAT_EXITCODE_CONFIG ; } // Checking behat dataroot existence otherwise echo about admin/tool/behat/cli/init.php. if ( ! empty ( $ CFG -> behat_dataroot ) ) { $ CFG -> behat_dataroot = realpath ( $ CFG -> behat_dataroot ) ; } if ( empty ( $ CFG -> behat_dataroot ) || ! is_dir ( $ CFG -> behat_dataroot ) || ! is_writable ( $ CFG -> behat_dataroot ) ) { self :: output_msg ( get_string ( 'errordataroot' , 'tool_behat' ) ) ; return BEHAT_EXITCODE_CONFIG ; } // If app config is supplied, check the value is correct. if ( ! empty ( $ CFG -> behat_ionic_dirroot ) && ! file_exists ( $ CFG -> behat_ionic_dirroot . '/ionic.config.json' ) ) { self :: output_msg ( get_string ( 'errorapproot' , 'tool_behat' ) ) ; return BEHAT_EXITCODE_CONFIG ; } return 0 ; }
docstring: Checks if behat is set up and working
  
  Notifies failures both from CLI and web interface.
  
  It checks behat dependencies have been installed and runs
  the behat help command to ensure it works as expected
  
  @return int Error code or 0 if all ok
docstring_tokens: Checks if behat is set up and working