JBrowseInstanceNodeSeeder.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Tests\DatabaseSeeders;
  3. use StatonLab\TripalTestSuite\Database\Seeder;
  4. use Faker\Factory;
  5. class JBrowseInstanceNodeSeeder extends Seeder
  6. {
  7. /**
  8. * Seeds the database with users.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. $faker = Factory::create();
  15. // Log in the god user.
  16. global $user;
  17. $user = user_load(1);
  18. $node = new \stdClass();
  19. if (!isset($node->title)) $node->title = $faker->name();
  20. $node->type = 'jbrowse_instance';
  21. node_object_prepare($node);
  22. $node->language = LANGUAGE_NONE;
  23. $node->uid = $user->uid;
  24. $node->status = 1; // published.
  25. $node->promote = 0; // not promoted.
  26. $node->comment = 0; // disabled.
  27. $node->field_jburl['und'][0]['url'] = $faker->url();
  28. $node->field_datadir['und'][0] = 'fake/path';
  29. $node->field_jbloc['und'][0] = $faker->word() .':'. rand(0,1000).'..'.rand(2000, 10000);
  30. $node->field_jbtracks['und'][0] = str_replace(' ',',',$faker->words(5,true));
  31. $node = node_submit($node);
  32. node_save($node);
  33. // log out the god user.
  34. $user = drupal_anonymous_user();
  35. $this->node = $node;
  36. }
  37. /**
  38. * Returns the node created by up().
  39. */
  40. public function getNode() {
  41. return $this->node;
  42. }
  43. }