From 9b0c1fc5606ca53116ea2913b5e629c6e7f13d49 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 7 Aug 2015 21:54:03 -0400 Subject: [PATCH] Add regression test for #7163 --- tests/TestCase/ORM/QueryRegressionTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/TestCase/ORM/QueryRegressionTest.php b/tests/TestCase/ORM/QueryRegressionTest.php index 58f7a99c597..99aebab8b79 100644 --- a/tests/TestCase/ORM/QueryRegressionTest.php +++ b/tests/TestCase/ORM/QueryRegressionTest.php @@ -1022,4 +1022,26 @@ public function testDotNotationNotOverride() $this->assertEquals([['name' => 'nate', 'tag' => 'tag1']], $results); } + + /** + * Test expression based ordering with unions. + * + * @return void + */ + public function testComplexOrderWithUnion() + { + $table = TableRegistry::get('Comments'); + $query = $table->find(); + $inner = $table->find()->where(['id >' => 3]); + $inner2 = $table->find()->where(['id <' => 3]); + + $order = $query->func()->concat(['inside__comment' => 'literal', 'test']); + + $query->select(['inside__comment' => 'Comments__comment']) + ->from(['inside' => $inner->unionAll($inner2)]) + ->orderAsc($order); + + $results = $query->toArray(); + $this->assertCount(5, $results); + } }