TripalEntityCollection.test 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // Bootstrap Drupal.
  3. $_SERVER['HTTP_HOST'] = 'localhost';
  4. $_SERVER['SCRIPT_NAME'] = '/index.php';
  5. $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
  6. $_SERVER['REQUEST_METHOD'] = 'GET';
  7. $_SERVER['SERVER_NAME'] = NULL;
  8. $_SERVER['SERVER_SOFTWARE'] = NULL;
  9. $_SERVER['HTTP_USER_AGENT'] = NULL;
  10. define('DRUPAL_ROOT', '/var/www/html');
  11. require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
  12. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  13. use PHPUnit\Framework\TestCase;
  14. class TripalEntityCollectionTest extends TestCase {
  15. protected $collection = NULL;
  16. public function setUp() {
  17. $details = ['uid' => 1, 'collection_name' => "test_collection_name"];
  18. $collection = new TripalEntityCollection();
  19. $collection->create($details);
  20. $this->collection = $collection;
  21. }
  22. public function testCreateCollectionAndBaseGetters() {
  23. $collection = $this->collection;
  24. $name = $collection->getName();
  25. $collection_id = $collection->getCollectionID();
  26. $this->assertEquals($name, "test_collection_name");
  27. $this->assertNotNull($collection_id);
  28. $this->assertInternalType("int", (int) $collection_id);
  29. }
  30. public function testAddBundle() {
  31. //create two entities, AND their fields. annoying.
  32. $details = ['bundle_name' => 'organism'];
  33. }
  34. public function tearDown() {
  35. $this->collection->delete();
  36. }
  37. }