@@ -21,7 +21,7 @@ public function setUp(): void {
2121 $ this ->engine ->query (
2222 "CREATE TABLE _options (
2323 ID INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
24- option_name TEXT NOT NULL default '',
24+ option_name TEXT NOT NULL UNIQUE default '',
2525 option_value TEXT NOT NULL default ''
2626 ); "
2727 );
@@ -116,6 +116,29 @@ public function testInsertDateNow() {
116116 $ this ->assertEquals ( gmdate ( 'Y ' ), $ results [0 ]->y );
117117 }
118118
119+ public function testLockingClauses () {
120+ $ this ->assertQuery ( "SELECT * FROM _options FOR UPDATE " );
121+ $ this ->assertQuery ( "SELECT * FROM _options FOR UPDATE SKIP LOCKED " );
122+ $ this ->assertQuery ( "SELECT * FROM _options FOR UPDATE NOWAIT " );
123+ $ this ->assertQuery ( "SELECT * FROM _options LOCK IN SHARE MODE " );
124+
125+ // Complex queries.
126+ $ this ->assertQuery ( "SELECT * FROM _options WHERE ID IN (SELECT ID FROM _options FOR UPDATE) " );
127+ $ this ->assertQuery ( "SELECT * FROM _options UNION SELECT * FROM _options FOR UPDATE " );
128+ }
129+
130+ public function testInsertWithoutInto () {
131+ $ this ->assertQuery ( "INSERT _options (option_name, option_value) VALUES ('test_name', 'test_value') " );
132+ $ results = $ this ->engine ->query ( "SELECT * FROM _options WHERE option_name = 'test_name' " );
133+ $ this ->assertCount ( 1 , $ results );
134+ $ this ->assertEquals ( 'test_value ' , $ results [0 ]->option_value );
135+
136+ $ this ->assertQuery ( "REPLACE _options (option_name, option_value) VALUES ('test_name', 'replaced_value') " );
137+ $ results = $ this ->engine ->query ( "SELECT * FROM _options WHERE option_name = 'test_name' " );
138+ $ this ->assertCount ( 1 , $ results );
139+ $ this ->assertEquals ( 'replaced_value ' , $ results [0 ]->option_value );
140+ }
141+
119142 public function testUpdateWithLimit () {
120143 $ this ->assertQuery (
121144 "INSERT INTO _dates (option_name, option_value) VALUES ('first', '2003-05-27 00:00:45'); "
0 commit comments