X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fapi%2Fv4%2FAction%2FBasicActionsTest.php;h=b71f2683a787b55783c305ef56643eb8f9d574ee;hb=7392872b837fd644d37c5db75cbaea302b40988d;hp=de06f6882e9c8b46c596b5ac4de52d88eff96e88;hpb=372d897eed3f8d5736b7dcb710d0c604e7a0328c;p=civicrm-core.git diff --git a/tests/phpunit/api/v4/Action/BasicActionsTest.php b/tests/phpunit/api/v4/Action/BasicActionsTest.php index de06f6882e..b71f2683a7 100644 --- a/tests/phpunit/api/v4/Action/BasicActionsTest.php +++ b/tests/phpunit/api/v4/Action/BasicActionsTest.php @@ -45,7 +45,9 @@ class BasicActionsTest extends UnitTestCase { MockBasicEntity::update()->addWhere('id', '=', $id2)->addValue('foo', 'new')->execute(); $result = MockBasicEntity::get()->addOrderBy('id', 'DESC')->setLimit(1)->execute(); - $this->assertCount(1, $result); + // The object's count() method will account for all results, ignoring limit, while the array results are limited + $this->assertCount(2, $result); + $this->assertCount(1, (array) $result); $this->assertEquals('new', $result->first()['foo']); $result = MockBasicEntity::save() @@ -266,6 +268,7 @@ class BasicActionsTest extends UnitTestCase { $results = MockBasicEntity::get() ->addSelect('*', 'group:label', 'group:name', 'fruit:name', 'fruit:color', 'fruit:label') + ->addOrderBy('fruit:color', "DESC") ->execute(); $this->assertEquals('round', $results[0]['shape']); @@ -277,6 +280,12 @@ class BasicActionsTest extends UnitTestCase { $this->assertEquals('banana', $results[0]['fruit:name']); $this->assertEquals('yellow', $results[0]['fruit:color']); + // Reverse order + $results = MockBasicEntity::get() + ->addOrderBy('fruit:color') + ->execute(); + $this->assertEquals('two', $results[0]['group']); + // Cannot match to a non-unique option property like :color on create try { MockBasicEntity::create()->addValue('fruit:color', 'yellow')->execute();