TripalJobsTest.test 966 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. class TripalJobsTest extends TestCase {
  4. /**
  5. * Holds the job id to delete when done.
  6. *
  7. * @var int|bool
  8. */
  9. protected $job_id;
  10. /**
  11. * Tests the ability to create a tripal job.
  12. *
  13. * @test
  14. */
  15. public function should_create_a_tripal_job() {
  16. $this->job_id = tripal_add_job('Test adding jobs', 'test_module', 'test_callback', [], 1);
  17. $this->assertTrue(is_numeric($this->job_id));
  18. }
  19. /**
  20. * Tests whether creating a duplicate job is possible.
  21. *
  22. * @test
  23. */
  24. public function should_refuse_to_create_duplicate_job() {
  25. $job = tripal_add_job('Test adding jobs', 'test_module', 'test_callback', [], 1, 10, TRUE);
  26. $this->assertEmpty($job);
  27. }
  28. /**
  29. * Run clean up
  30. */
  31. public function __destruct() {
  32. // Clean up any data inserted to the DB
  33. if ($this->job_id) {
  34. db_query('DELETE FROM {tripal_jobs} WHERE job_id = :id', [':id' => $this->job_id]);
  35. }
  36. }
  37. }