@@ -15,97 +15,79 @@ class InsertTest extends TestCase
1515
1616 public function testEmptyInsertInto ()
1717 {
18- $ this ->setupTest ();
19-
2018 $ this ->assertSame (null , $ this ->query ->getInto ());
2119 $ this ->assertSame ([], $ this ->query ->getColumns ());
2220 $ this ->assertSame ([], $ this ->query ->getValues ());
2321 $ this ->assertSame (null , $ this ->query ->getSelect ());
24- $ this ->assertCorrectStatementAndValues ('() VALUES() ' , []); // TODO(el): Should we render anything here?
22+ $ this ->assertSql ('() VALUES() ' , $ this -> query , []); // TODO(el): Should we render anything here?
2523 }
2624
2725 public function testIntoTableSpecification ()
2826 {
29- $ this ->setupTest ();
30-
3127 $ this ->query ->into ('table ' );
3228
3329 $ this ->assertSame ('table ' , $ this ->query ->getInto ());
34- $ this ->assertCorrectStatementAndValues ('INSERT INTO table () VALUES() ' , []);
30+ $ this ->assertSql ('INSERT INTO table () VALUES() ' , $ this -> query , []);
3531 }
3632
3733 public function testIntoTableSpecificationWithSchema ()
3834 {
39- $ this ->setupTest ();
40-
4135 $ this ->query ->into ('schema.table ' );
4236
4337 $ this ->assertSame ('schema.table ' , $ this ->query ->getInto ());
44- $ this ->assertCorrectStatementAndValues ('INSERT INTO schema.table () VALUES() ' , []);
38+ $ this ->assertSql ('INSERT INTO schema.table () VALUES() ' , $ this -> query , []);
4539 }
4640
4741 public function testColumns ()
4842 {
49- $ this ->setupTest ();
50-
5143 $ columns = ['c1 ' , 'c2 ' ];
5244 $ this ->query ->columns ($ columns );
5345
5446 $ this ->assertSame ($ columns , $ this ->query ->getColumns ());
55- $ this ->assertCorrectStatementAndValues ('(c1,c2) VALUES() ' , []);
47+ $ this ->assertSql ('(c1,c2) VALUES() ' , $ this -> query , []);
5648 }
5749
5850 public function testValues ()
5951 {
60- $ this ->setupTest ();
61-
6252 $ this ->query ->values (['c1 ' => 'v1 ' ]);
6353
6454 $ this ->assertSame (['c1 ' ], $ this ->query ->getColumns ());
6555 $ this ->assertSame (['v1 ' ], $ this ->query ->getValues ());
66- $ this ->assertCorrectStatementAndValues ('(c1) VALUES(?) ' , ['v1 ' ]);
56+ $ this ->assertSql ('(c1) VALUES(?) ' , $ this -> query , ['v1 ' ]);
6757 }
6858
6959 public function testExpressionValue ()
7060 {
71- $ this ->setupTest ();
72-
7361 $ value = new Expression ('x = ? ' , null , 1 );
7462 $ this ->query ->values (['c1 ' => $ value ]);
7563
7664 $ this ->assertSame (['c1 ' ], $ this ->query ->getColumns ());
7765 $ this ->assertSame ([$ value ], $ this ->query ->getValues ());
78- $ this ->assertCorrectStatementAndValues ('(c1) VALUES(x = ?) ' , [1 ]);
66+ $ this ->assertSql ('(c1) VALUES(x = ?) ' , $ this -> query , [1 ]);
7967 }
8068
8169 public function testSelectValue ()
8270 {
83- $ this ->setupTest ();
84-
8571 $ value = (new Select ())->columns ('COUNT(*) ' )->from ('table2 ' )->where (['active = ? ' => 1 ]);
8672 $ this ->query ->values (['c1 ' => $ value ]);
8773
8874 $ this ->assertSame (['c1 ' ], $ this ->query ->getColumns ());
8975 $ this ->assertSame ([$ value ], $ this ->query ->getValues ());
90- $ this ->assertCorrectStatementAndValues ('(c1) VALUES((SELECT COUNT(*) FROM table2 WHERE active = ?)) ' , [1 ]);
76+ $ this ->assertSql ('(c1) VALUES((SELECT COUNT(*) FROM table2 WHERE active = ?)) ' , $ this -> query , [1 ]);
9177 }
9278
9379 public function testColumnsAndValues ()
9480 {
95- $ this ->setupTest ();
96-
9781 $ this ->query ->columns (['c1 ' , 'c2 ' ]);
9882 $ this ->query ->values (['v1 ' , 'v2 ' ]);
9983
10084 $ this ->assertSame (['c1 ' , 'c2 ' ], $ this ->query ->getColumns ());
10185 $ this ->assertSame (['v1 ' , 'v2 ' ], $ this ->query ->getValues ());
102- $ this ->assertCorrectStatementAndValues ('(c1,c2) VALUES(?,?) ' , ['v1 ' , 'v2 ' ]);
86+ $ this ->assertSql ('(c1,c2) VALUES(?,?) ' , $ this -> query , ['v1 ' , 'v2 ' ]);
10387 }
10488
10589 public function testInsertIntoSelectStatement ()
10690 {
107- $ this ->setupTest ();
108-
10991 $ select = (new Select ())
11092 ->from ('table ' )
11193 ->columns (['c1 ' , 'c2 ' ]);
@@ -116,29 +98,25 @@ public function testInsertIntoSelectStatement()
11698 ->select ($ select );
11799
118100 $ this ->assertSame ($ select , $ this ->query ->getSelect ());
119- $ this ->assertCorrectStatementAndValues ('INSERT INTO table (c1,c2) SELECT c1, c2 FROM table ' , []);
101+ $ this ->assertSql ('INSERT INTO table (c1,c2) SELECT c1, c2 FROM table ' , $ this -> query , []);
120102 }
121103
122104 public function testInsertIntoStatementWithValues ()
123105 {
124- $ this ->setupTest ();
125-
126106 $ this ->query
127107 ->into ('table ' )
128108 ->values (['c1 ' => 'v1 ' , 'c2 ' => 'v2 ' ]);
129109
130- $ this ->assertCorrectStatementAndValues ('INSERT INTO table (c1,c2) VALUES(?,?) ' , ['v1 ' , 'v2 ' ]);
110+ $ this ->assertSql ('INSERT INTO table (c1,c2) VALUES(?,?) ' , $ this -> query , ['v1 ' , 'v2 ' ]);
131111 }
132112
133113 public function testInsertIntoStatementWithColumnsAndValues ()
134114 {
135- $ this ->setupTest ();
136-
137115 $ this ->query
138116 ->into ('table ' )
139117 ->columns (['c1 ' , 'c2 ' ])
140118 ->values (['v1 ' , 'v2 ' ]);
141119
142- $ this ->assertCorrectStatementAndValues ('INSERT INTO table (c1,c2) VALUES(?,?) ' , ['v1 ' , 'v2 ' ]);
120+ $ this ->assertSql ('INSERT INTO table (c1,c2) VALUES(?,?) ' , $ this -> query , ['v1 ' , 'v2 ' ]);
143121 }
144122}
0 commit comments