7
7
class SelectTestX extends \PHPUnit_Framework_TestCase {
8
8
public function testAddition () {
9
9
$ str = TestSelect::create ()->field ('1+2 ' )->asString ();
10
- $ this ->assertEquals ("SELECT \n\t1+2 \n; \n " , $ str );
10
+ $ this ->assertEquals ("SELECT \n\t1+2 \n" , $ str );
11
11
}
12
12
13
13
public function testFrom () {
14
14
$ str = TestSelect::create ()
15
15
->field ('a ' )
16
16
->from ('t ' , 'test ' )
17
17
->asString ();
18
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \n; \n " , $ str );
18
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \n" , $ str );
19
19
}
20
20
21
21
public function testMultipleFrom () {
@@ -24,7 +24,7 @@ public function testMultipleFrom() {
24
24
->from ('t1 ' , 'test1 ' )
25
25
->from ('t2 ' , 'test2 ' )
26
26
->asString ();
27
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest1 t1, \n\ttest2 t2 \n; \n " , $ str );
27
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest1 t1, \n\ttest2 t2 \n" , $ str );
28
28
}
29
29
30
30
public function testJoins () {
@@ -34,14 +34,14 @@ public function testJoins() {
34
34
->from ('t1 ' , 'test1 ' )
35
35
->{$ method }('t2 ' , 'test2 ' , 't2.id=t1.id ' )
36
36
->asString ();
37
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest1 t1 \n{$ type } JOIN \n\ttest2 t2 ON t2.id=t1.id \n; \n " , $ sql );
37
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest1 t1 \n{$ type } JOIN \n\ttest2 t2 ON t2.id=t1.id \n" , $ sql );
38
38
39
39
$ sql = TestSelect::create ()
40
40
->field ('a ' )
41
41
->from ('t1 ' , 'test1 ' )
42
42
->{$ method }('t2 ' , 'test2 ' , 't2.id=t1.id AND t2.id < ? ' , 1000 )
43
43
->asString ();
44
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest1 t1 \n{$ type } JOIN \n\ttest2 t2 ON t2.id=t1.id AND t2.id < '1000' \n; \n " , $ sql );
44
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest1 t1 \n{$ type } JOIN \n\ttest2 t2 ON t2.id=t1.id AND t2.id < '1000' \n" , $ sql );
45
45
};
46
46
47
47
$ testFn ('joinInner ' , 'INNER ' );
@@ -55,21 +55,21 @@ public function testWhere() {
55
55
->from ('t ' , 'test ' )
56
56
->where ('a+1<2 ' )
57
57
->asString ();
58
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nWHERE \n\t(a+1<2) \n; \n " , $ str );
58
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nWHERE \n\t(a+1<2) \n" , $ str );
59
59
60
60
$ str = TestSelect::create ()
61
61
->field ('a ' )
62
62
->from ('t ' , 'test ' )
63
63
->where ('a < ? ' , 1000 )
64
64
->asString ();
65
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nWHERE \n\t(a < '1000') \n; \n " , $ str );
65
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nWHERE \n\t(a < '1000') \n" , $ str );
66
66
67
67
$ str = TestSelect::create ()
68
68
->field ('a ' )
69
69
->from ('t ' , 'test ' )
70
70
->where ('a < :0 ' , 1000 )
71
71
->asString ();
72
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nWHERE \n\t(a < '1000') \n; \n " , $ str );
72
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nWHERE \n\t(a < '1000') \n" , $ str );
73
73
}
74
74
75
75
public function testHaving () {
@@ -78,7 +78,7 @@ public function testHaving() {
78
78
->from ('t ' , 'test ' )
79
79
->having ('a+1<2 ' )
80
80
->asString ();
81
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nHAVING \n\t(a+1<2) \n; \n " , $ str );
81
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nHAVING \n\t(a+1<2) \n" , $ str );
82
82
}
83
83
84
84
public function testOrder () {
@@ -87,7 +87,7 @@ public function testOrder() {
87
87
->from ('t ' , 'test ' )
88
88
->orderBy ('a ' , 'desc ' )
89
89
->asString ();
90
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nORDER BY \n\ta DESC \n; \n " , $ str );
90
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nORDER BY \n\ta DESC \n" , $ str );
91
91
}
92
92
93
93
public function testGroup () {
@@ -96,7 +96,7 @@ public function testGroup() {
96
96
->from ('t ' , 'test ' )
97
97
->groupBy ('a ' , 'b ' , 'c ' )
98
98
->asString ();
99
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nGROUP BY \n\ta, \n\tb, \n\tc \n; \n " , $ str );
99
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nGROUP BY \n\ta, \n\tb, \n\tc \n" , $ str );
100
100
}
101
101
102
102
public function testLimit () {
@@ -105,7 +105,7 @@ public function testLimit() {
105
105
->from ('t ' , 'test ' )
106
106
->limit (100 )
107
107
->asString ();
108
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nLIMIT \n\t100 \n; \n " , $ str );
108
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nLIMIT \n\t100 \n" , $ str );
109
109
}
110
110
111
111
public function testOffset () {
@@ -115,7 +115,7 @@ public function testOffset() {
115
115
->limit (100 )
116
116
->offset (50 )
117
117
->asString ();
118
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nLIMIT \n\t100 \nOFFSET \n\t50 \n; \n " , $ str );
118
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nLIMIT \n\t100 \nOFFSET \n\t50 \n" , $ str );
119
119
}
120
120
121
121
public function testForUpdate () {
@@ -124,7 +124,7 @@ public function testForUpdate() {
124
124
->from ('t ' , 'test ' )
125
125
->forUpdate ()
126
126
->asString ();
127
- $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nFOR UPDATE \n; \n " , $ str );
127
+ $ this ->assertEquals ("SELECT \n\ta \nFROM \n\ttest t \nFOR UPDATE \n" , $ str );
128
128
}
129
129
130
130
public function testInnerSelect () {
@@ -136,15 +136,15 @@ public function testInnerSelect() {
136
136
->from ('t ' , $ select )
137
137
->asString ();
138
138
139
- $ this ->assertEquals ("SELECT \n\t* \nFROM \n\t(SELECT \n\t\t* \n\tFROM \n\t\ttable a \n\tWHERE \n\t\t(a.id=1)) t \n; \n " , $ str );
139
+ $ this ->assertEquals ("SELECT \n\t* \nFROM \n\t(SELECT \n\t\t* \n\tFROM \n\t\ttable a \n\tWHERE \n\t\t(a.id=1)) t \n" , $ str );
140
140
}
141
141
142
142
public function testAlias () {
143
143
$ query = TestSelect::create ()
144
144
->from ('t ' , 'travis#test1 ' )
145
145
->asString ();
146
146
147
- $ this ->assertEquals ("SELECT \n\t* \nFROM \n\ttravis_test.test1 t \n; \n " , $ query );
147
+ $ this ->assertEquals ("SELECT \n\t* \nFROM \n\ttravis_test.test1 t \n" , $ query );
148
148
}
149
149
150
150
public function testCount () {
@@ -155,7 +155,7 @@ public function testCount() {
155
155
->where ('t1.id > 10 ' )
156
156
->asString ();
157
157
158
- $ this ->assertEquals ("SELECT \n\tCOUNT(*) \nFROM \n\ttest1 t1 \nINNER JOIN \n\ttest2 t2 ON t1.id=t2.id \nWHERE \n\t(t1.id > 10) \n; \n " , $ query );
158
+ $ this ->assertEquals ("SELECT \n\tCOUNT(*) \nFROM \n\ttest1 t1 \nINNER JOIN \n\ttest2 t2 ON t1.id=t2.id \nWHERE \n\t(t1.id > 10) \n" , $ query );
159
159
}
160
160
161
161
public function testSubselectAsField () {
@@ -172,6 +172,6 @@ public function testSubselectAsField() {
172
172
->where ('t1.id > 10 ' )
173
173
->asString ();
174
174
175
- $ this ->assertEquals ("SELECT \n\t( \n\t\tSELECT \n\t\t\tCOUNT(*) \n\t\tFROM \n\t\t\ttest1 t1 \n\t\tINNER JOIN \n\t\t\ttest2 t2 ON t1.id=t2.id \n\t\tWHERE \n\t\t\t(t1.id > 10) \n\t) AS `testfield` \nFROM \n\ttest1 t1 \nINNER JOIN \n\ttest2 t2 ON t1.id=t2.id \nWHERE \n\t(t1.id > 10) \n; \n " , $ query );
175
+ $ this ->assertEquals ("SELECT \n\t( \n\t\tSELECT \n\t\t\tCOUNT(*) \n\t\tFROM \n\t\t\ttest1 t1 \n\t\tINNER JOIN \n\t\t\ttest2 t2 ON t1.id=t2.id \n\t\tWHERE \n\t\t\t(t1.id > 10) \n\t) AS `testfield` \nFROM \n\ttest1 t1 \nINNER JOIN \n\ttest2 t2 ON t1.id=t2.id \nWHERE \n\t(t1.id > 10) \n" , $ query );
176
176
}
177
177
}
0 commit comments