You are here

payment-generate-content.sh in Payment 7

Generates content for Payment 7.x-1.x.

Run this script at the root of an existing Drupal 7 installation. Steps to use this generation script:

  • Install drupal 7.
  • Run this script from your Drupal ROOT directory.
  • Use ./scripts/dump-database-d7.sh to generate the database dump.

File

payment-generate-content.sh
View source
  1. #!/usr/bin/env php
  2. /**
  3. * @file
  4. * Generates content for Payment 7.x-1.x.
  5. *
  6. * Run this script at the root of an existing Drupal 7 installation.
  7. * Steps to use this generation script:
  8. * - Install drupal 7.
  9. * - Run this script from your Drupal ROOT directory.
  10. * - Use ./scripts/dump-database-d7.sh to generate the database dump.
  11. */
  12. // Define settings.
  13. $cmd = 'index.php';
  14. define('DRUPAL_ROOT', getcwd());
  15. $_SERVER['HTTP_HOST'] = 'default';
  16. $_SERVER['PHP_SELF'] = '/index.php';
  17. $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
  18. $_SERVER['SERVER_SOFTWARE'] = NULL;
  19. $_SERVER['REQUEST_METHOD'] = 'GET';
  20. $_SERVER['QUERY_STRING'] = '';
  21. $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
  22. $_SERVER['HTTP_USER_AGENT'] = 'console';
  23. $modules_to_enable = array('payment', 'paymentform', 'paymentmethodbasic', 'paymentreference');
  24. // Bootstrap Drupal.
  25. include_once './includes/bootstrap.inc';
  26. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  27. // Enable requested modules.
  28. require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
  29. include_once './modules/system/system.admin.inc';
  30. $form = system_modules();
  31. foreach ($modules_to_enable as $module) {
  32. $form_state['values']['status'][$module] = TRUE;
  33. }
  34. $form_state['values']['disabled_modules'] = $form['disabled_modules'];
  35. system_modules_submit(NULL, $form_state);
  36. unset($form_state);
  37. // Run cron after installing.
  38. drupal_cron_run();
  39. // Create two payment methods.
  40. $payment_method_unavailable = PaymentGenerate::paymentMethod();
  41. $payment_method_unavailable->enabled = FALSE;
  42. entity_save('payment_method', $payment_method_unavailable);
  43. $payment_method_basic = PaymentGenerate::paymentMethod('PaymentMethodBasicController');
  44. entity_save('payment_method', $payment_method_basic);
  45. // Create two payments
  46. $payment_unavailable = PaymentGenerate::payment($payment_method_unavailable);
  47. entity_save('payment', $payment_unavailable);
  48. $payment_basic = PaymentGenerate::payment($payment_method_basic);
  49. entity_save('payment', $payment_basic);