Skip to content

Instantly share code, notes, and snippets.

@alnutile
Created February 2, 2015 16:15
Show Gist options
  • Save alnutile/49998777be50bffc86ca to your computer and use it in GitHub Desktop.
Save alnutile/49998777be50bffc86ca to your computer and use it in GitHub Desktop.
<?php
function behat_editor_saucelabs_permission() {
$items['behat run saucelabs test'] = array(
'title' => t('Can run a Saucelabs a test'),
'description' => t('Can run a Saucelabs a test')
);
return $items;
}
function behat_editor_saucelabs_menu() {
$path = drupal_get_path('module', 'behat_editor_saucelabs');
/* allow jquery to get data about jobs status */
$items['admin/behat/saucelabs/browser/%'] = array(
'page callback' => array('behat_editor_saucelabs_browser'),
'page arguments' => array(4),
'access arguments' => array('behat run saucelabs test')
);
return $items;
}
function behat_editor_saucelabs_browser($os) {
composer_manager_register_autoloader();
if (!class_exists('Drupal\BehatEditorSauceLabs\Wrapper')) {
$message = t('SauceLabs Wrapper not found.');
drupal_json_output(array('error' => 1, 'message' => $message));
exit();
}
//Do your work here and return $summary
$message = "Here is your data";
drupal_json_output(drupal_api_remote_response($summary, $message));
exit();
}
function drupal_api_remote_response($results, $message)
{
return array('data' => $results, 'message' => $message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment