ChadoQueryTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Tests;
  3. use StatonLab\TripalTestSuite\DBTransaction;
  4. use StatonLab\TripalTestSuite\TripalTestCase;
  5. class ChadoQueryTest extends TripalTestCase {
  6. // Uncomment to auto start and rollback db transactions per test method.
  7. use DBTransaction;
  8. /**
  9. * @group filter
  10. * See PR 827.
  11. */
  12. public function test_filter_level(){
  13. $stock = factory('chado.stock')->create(['uniquename' => 'octopus_core_test_name']);
  14. // Test 1. Pass a single filter.
  15. $selector = array(
  16. 'stock_id' => 1085,
  17. 'uniquename' => array(
  18. 'op' => 'LIKE',
  19. 'data' => '01%',
  20. ),
  21. );
  22. $object = chado_generate_var('stock', $selector);
  23. $this->assertNotNull($object);
  24. // Test 2 Pass an array of filters with a single item.
  25. $selector = array(
  26. 'stock_id' => 1085,
  27. 'uniquename' => array(
  28. array(
  29. 'op' => 'LIKE',
  30. 'data' => '01%',
  31. ),
  32. ),
  33. );
  34. $object = chado_generate_var('stock', $selector);
  35. $this->assertNotNull($object);
  36. // Test 3 Pass an array of filters with multiple items.
  37. $selector = array(
  38. 'uniquename' => array(
  39. array(
  40. 'op' => '>',
  41. 'data' => ($stock->type_id - 1),
  42. ),
  43. array(
  44. 'op' => '<',
  45. 'data' => ($stock->type_id + 1),
  46. ),
  47. ),
  48. );
  49. $object = chado_generate_var('stock', $selector);
  50. $this->assertNotNull($object);
  51. }
  52. }