Conditions | 1 |
Paths | 1 |
Total Lines | 46 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
42 | public function testUnion() |
||
43 | { |
||
44 | $posts = TableRegistry::getTableLocator()->get('Posts'); |
||
45 | |||
46 | $expected = ' |
||
47 | SELECT |
||
48 | * |
||
49 | FROM |
||
50 | ( |
||
51 | SELECT |
||
52 | Posts.id AS "Posts__id", |
||
53 | Posts.modified AS "Posts__modified" |
||
54 | FROM |
||
55 | posts Posts |
||
56 | WHERE |
||
57 | id > :c0 |
||
58 | ORDER BY |
||
59 | modified ASC |
||
60 | ) |
||
61 | UNION ALL |
||
62 | SELECT |
||
63 | * |
||
64 | FROM |
||
65 | ( |
||
66 | SELECT |
||
67 | Posts.id AS "Posts__id", |
||
68 | Posts.modified AS "Posts__modified" |
||
69 | FROM |
||
70 | posts Posts |
||
71 | ORDER BY |
||
72 | modified ASC |
||
73 | ) |
||
74 | '; |
||
75 | |||
76 | $subQuery = $posts->find() |
||
77 | ->select(['id', 'modified']) |
||
78 | ->orderAsc('modified'); |
||
79 | |||
80 | $mainQuery = $posts->find() |
||
81 | ->select(['id', 'modified']) |
||
82 | ->where(['id >' => 1]) |
||
83 | ->orderAsc('modified') |
||
84 | ->unionAll($subQuery); |
||
85 | |||
86 | $actual = $mainQuery->sql(); |
||
87 | $this->assertSqlEquals($expected, $actual); |
||
88 | } |
||
90 |