diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-10-06 13:57:47 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-10-06 13:57:47 +0000 |
commit | 973562ffa79951ad932e6f8156dce74616e805ed (patch) | |
tree | 3bfc16259481fa31ad03461cc74d20b4d7fb9048 /modules/simpletest | |
parent | 77c85e329a489ac51e4b60a78f8e6c95657ffbaf (diff) | |
download | brdo-973562ffa79951ad932e6f8156dce74616e805ed.tar.gz brdo-973562ffa79951ad932e6f8156dce74616e805ed.tar.bz2 |
- Patch #908798 by bojanz: EntityFieldQuery does not handle ordering correctly.
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/tests/entity_query.test | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/modules/simpletest/tests/entity_query.test b/modules/simpletest/tests/entity_query.test index e569cba1a..171c51730 100644 --- a/modules/simpletest/tests/entity_query.test +++ b/modules/simpletest/tests/entity_query.test @@ -295,7 +295,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase { array('test_entity_bundle_key', 2), array('test_entity_bundle_key', 1), ), t('Test sort entity entity_id in descending order.'), TRUE); - + // Test entity sort by entity_id, with a field condition. $query = new EntityFieldQuery(); $query @@ -351,7 +351,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase { array('test_entity_bundle_key', 2), array('test_entity_bundle_key', 1), ), t('Test sort entity entity_id property in descending order.'), TRUE); - + // Test property sort by entity id, with a field condition. $query = new EntityFieldQuery(); $query @@ -394,7 +394,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase { array('test_entity_bundle_key', 1), array('test_entity_bundle_key', 6), array('test_entity_bundle_key', 5), - ), t('Test sort entity bundle in ascending order.'), TRUE); + ), t('Test sort entity bundle in ascending order, property in descending order.'), TRUE); $query = new EntityFieldQuery(); $query @@ -408,38 +408,67 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase { array('test_entity_bundle_key', 2), array('test_entity_bundle_key', 3), array('test_entity_bundle_key', 4), - ), t('Test sort entity bundle in descending order.'), TRUE); - + ), t('Test sort entity bundle in descending order, property in ascending order.'), TRUE); + // Test entity sort by bundle, with a field condition. $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'test_entity_bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->entityOrderBy('bundle', 'ASC') - ->propertyOrderBy('ftid', 'ASC'); + ->propertyOrderBy('ftid', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), + array('test_entity_bundle_key', 3), + array('test_entity_bundle_key', 2), + array('test_entity_bundle_key', 1), array('test_entity_bundle_key', 6), - ), t('Test sort entity bundle in ascending order, with a field condition.'), TRUE); + array('test_entity_bundle_key', 5), + ), t('Test sort entity bundle in ascending order, property in descending order, with a field condition.'), TRUE); $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'test_entity_bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->entityOrderBy('bundle', 'DESC') - ->propertyOrderBy('ftid', 'DESC'); + ->propertyOrderBy('ftid', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), array('test_entity_bundle_key', 5), + array('test_entity_bundle_key', 6), + array('test_entity_bundle_key', 1), + array('test_entity_bundle_key', 2), + array('test_entity_bundle_key', 3), + array('test_entity_bundle_key', 4), + ), t('Test sort entity bundle in descending order, property in ascending order, with a field condition.'), TRUE); + + // Test entity sort by bundle, field. + $query = new EntityFieldQuery(); + $query + ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityOrderBy('bundle', 'ASC') + ->fieldOrderBy($this->fields[0], 'value', 'DESC'); + $this->assertEntityFieldQuery($query, array( array('test_entity_bundle_key', 4), array('test_entity_bundle_key', 3), array('test_entity_bundle_key', 2), array('test_entity_bundle_key', 1), - ), t('Test sort entity bundle in descending order, with a field condition.'), TRUE); + array('test_entity_bundle_key', 6), + array('test_entity_bundle_key', 5), + ), t('Test sort entity bundle in ascending order, field in descending order.'), TRUE); + + $query = new EntityFieldQuery(); + $query + ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityOrderBy('bundle', 'DESC') + ->fieldOrderBy($this->fields[0], 'value', 'ASC'); + $this->assertEntityFieldQuery($query, array( + array('test_entity_bundle_key', 5), + array('test_entity_bundle_key', 6), + array('test_entity_bundle_key', 1), + array('test_entity_bundle_key', 2), + array('test_entity_bundle_key', 3), + array('test_entity_bundle_key', 4), + ), t('Test sort entity bundle in descending order, field in ascending order.'), TRUE); // Test entity sort by revision_id. $query = new EntityFieldQuery(); @@ -463,7 +492,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase { array('test_entity', 2), array('test_entity', 1), ), t('Test sort entity revision_id in descending order.'), TRUE); - + // Test entity sort by revision_id, with a field condition. $query = new EntityFieldQuery(); $query |