@@ -86,6 +86,99 @@ public function testSelect(): void {
86
86
);
87
87
}
88
88
89
+ public function testInsert (): void {
90
+ $ this ->assertQuery (
91
+ 'INSERT INTO "t" ( "c" ) VALUES ( 1 ) ' ,
92
+ 'INSERT INTO t (c) VALUES (1) '
93
+ );
94
+
95
+ $ this ->assertQuery (
96
+ 'INSERT INTO "s"."t" ( "c" ) VALUES ( 1 ) ' ,
97
+ 'INSERT INTO s.t (c) VALUES (1) '
98
+ );
99
+
100
+ $ this ->assertQuery (
101
+ 'INSERT INTO "t" ( "c1" , "c2" ) VALUES ( 1 , 2 ) ' ,
102
+ 'INSERT INTO t (c1, c2) VALUES (1, 2) '
103
+ );
104
+
105
+ $ this ->assertQuery (
106
+ 'INSERT INTO "t" ( "c" ) VALUES ( 1 ) , ( 2 ) ' ,
107
+ 'INSERT INTO t (c) VALUES (1), (2) '
108
+ );
109
+
110
+ $ this ->assertQuery (
111
+ 'INSERT INTO "t1" SELECT * FROM "t2" ' ,
112
+ 'INSERT INTO t1 SELECT * FROM t2 '
113
+ );
114
+ }
115
+
116
+ public function testReplace (): void {
117
+ $ this ->assertQuery (
118
+ 'REPLACE INTO "t" ( "c" ) VALUES ( 1 ) ' ,
119
+ 'REPLACE INTO t (c) VALUES (1) '
120
+ );
121
+
122
+ $ this ->assertQuery (
123
+ 'REPLACE INTO "s"."t" ( "c" ) VALUES ( 1 ) ' ,
124
+ 'REPLACE INTO s.t (c) VALUES (1) '
125
+ );
126
+
127
+ $ this ->assertQuery (
128
+ 'REPLACE INTO "t" ( "c1" , "c2" ) VALUES ( 1 , 2 ) ' ,
129
+ 'REPLACE INTO t (c1, c2) VALUES (1, 2) '
130
+ );
131
+
132
+ $ this ->assertQuery (
133
+ 'REPLACE INTO "t" ( "c" ) VALUES ( 1 ) , ( 2 ) ' ,
134
+ 'REPLACE INTO t (c) VALUES (1), (2) '
135
+ );
136
+
137
+ $ this ->assertQuery (
138
+ 'REPLACE INTO "t1" SELECT * FROM "t2" ' ,
139
+ 'REPLACE INTO t1 SELECT * FROM t2 '
140
+ );
141
+ }
142
+
143
+ public function testUpdate (): void {
144
+ $ this ->assertQuery (
145
+ 'UPDATE "t" SET "c" = 1 ' ,
146
+ 'UPDATE t SET c = 1 '
147
+ );
148
+
149
+ $ this ->assertQuery (
150
+ 'UPDATE "s"."t" SET "c" = 1 ' ,
151
+ 'UPDATE s.t SET c = 1 '
152
+ );
153
+
154
+ $ this ->assertQuery (
155
+ 'UPDATE "t" SET "c1" = 1 , "c2" = 2 ' ,
156
+ 'UPDATE t SET c1 = 1, c2 = 2 '
157
+ );
158
+
159
+ $ this ->assertQuery (
160
+ 'UPDATE "t" SET "c" = 1 WHERE "c" = 2 ' ,
161
+ 'UPDATE t SET c = 1 WHERE c = 2 '
162
+ );
163
+ }
164
+
165
+ public function testDelete (): void {
166
+ $ this ->assertQuery (
167
+ 'DELETE FROM "t" ' ,
168
+ 'DELETE FROM t '
169
+ );
170
+
171
+ $ this ->assertQuery (
172
+ 'DELETE FROM "s"."t" ' ,
173
+ 'DELETE FROM s.t '
174
+ );
175
+
176
+ $ this ->assertQuery (
177
+ 'DELETE FROM "t" WHERE "c" = 1 ' ,
178
+ 'DELETE FROM t WHERE c = 1 '
179
+ );
180
+ }
181
+
89
182
private function assertQuery ( $ expected , string $ query ): void {
90
183
$ driver = new WP_SQLite_Driver ( new PDO ( 'sqlite::memory: ' ) );
91
184
$ driver ->query ( $ query );
0 commit comments