Skip to content
This repository was archived by the owner on Nov 26, 2022. It is now read-only.

Commit 329c7c3

Browse files
committed
Update tests
1 parent 0ca73cb commit 329c7c3

10 files changed

Lines changed: 181 additions & 133 deletions

tests/BaseTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class BaseTest extends TestCase
3333
*
3434
* @return void
3535
*/
36-
protected function createTestTable()
36+
protected function createTestTable(): void
3737
{
3838
$db = $this->getConnection();
3939
$schema = $this->getSchema();
@@ -67,7 +67,9 @@ protected function createTestTable()
6767
}
6868

6969
/**
70-
* @return PDO
70+
* Get PDO.
71+
*
72+
* @return PDO The connection
7173
*/
7274
protected function getPdo(): PDO
7375
{
@@ -100,7 +102,7 @@ protected function getConnection(): Connection
100102
/**
101103
* @return Schema
102104
*/
103-
protected function getSchema()
105+
protected function getSchema(): Schema
104106
{
105107
if ($this->schema === null) {
106108
$this->schema = new Schema($this->getConnection());

tests/ConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ConnectionTest extends BaseTest
1717
*
1818
* @return void
1919
*/
20-
public function testInstance()
20+
public function testInstance(): void
2121
{
2222
$connection = $this->getConnection();
2323
$this->assertInstanceOf(Connection::class, $connection);
@@ -26,7 +26,7 @@ public function testInstance()
2626
/**
2727
* Test.
2828
*/
29-
public function testPrepareQuery()
29+
public function testPrepareQuery(): void
3030
{
3131
$select = $this->select();
3232
$select->columns(['TABLE_NAME'])

tests/DeleteQueryTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ class DeleteQueryTest extends BaseTest
1414
*
1515
* @return void
1616
*/
17-
public function testInstance()
17+
public function testInstance(): void
1818
{
1919
$this->assertInstanceOf(DeleteQuery::class, $this->delete());
2020
}
2121

2222
/**
2323
* @return DeleteQuery
2424
*/
25-
protected function delete()
25+
protected function delete(): DeleteQuery
2626
{
2727
return new DeleteQuery($this->getConnection());
2828
}
2929

3030
/**
3131
* Test.
3232
*/
33-
public function testFrom()
33+
public function testFrom(): void
3434
{
3535
$delete = $this->delete()->from('test');
3636
$this->assertSame('DELETE FROM `test`;', $delete->build());
@@ -40,7 +40,7 @@ public function testFrom()
4040
/**
4141
* Test.
4242
*/
43-
public function testLowPriority()
43+
public function testLowPriority(): void
4444
{
4545
$delete = $this->delete()->lowPriority()->from('test');
4646
$this->assertSame('DELETE LOW_PRIORITY FROM `test`;', $delete->build());
@@ -49,7 +49,7 @@ public function testLowPriority()
4949
/**
5050
* Test.
5151
*/
52-
public function testIgnore()
52+
public function testIgnore(): void
5353
{
5454
$delete = $this->delete()->ignore()->from('test')->where('id', '=', '1');
5555
$this->assertSame("DELETE IGNORE FROM `test` WHERE `id` = '1';", $delete->build());
@@ -61,7 +61,7 @@ public function testIgnore()
6161
/**
6262
* Test.
6363
*/
64-
public function testQuick()
64+
public function testQuick(): void
6565
{
6666
$delete = $this->delete()->quick()->from('test')->where('id', '=', '1');
6767
$this->assertSame("DELETE QUICK FROM `test` WHERE `id` = '1';", $delete->build());
@@ -70,7 +70,7 @@ public function testQuick()
7070
/**
7171
* Test.
7272
*/
73-
public function testOrderBy()
73+
public function testOrderBy(): void
7474
{
7575
$delete = $this->delete()->from('test')->where('id', '=', '1')->orderBy('id');
7676
$this->assertSame("DELETE FROM `test` WHERE `id` = '1' ORDER BY `id`;", $delete->build());
@@ -88,7 +88,7 @@ public function testOrderBy()
8888
/**
8989
* Test.
9090
*/
91-
public function testLimit()
91+
public function testLimit(): void
9292
{
9393
$delete = $this->delete()->from('test')->where('id', '>', '1')->limit(10);
9494
$this->assertSame("DELETE FROM `test` WHERE `id` > '1' LIMIT 10;", $delete->build());
@@ -97,7 +97,7 @@ public function testLimit()
9797
/**
9898
* Test.
9999
*/
100-
public function testWhere()
100+
public function testWhere(): void
101101
{
102102
$delete = $this->delete()->from('test')->where('id', '=', '1')
103103
->where('test.id', '=', 1)
@@ -108,13 +108,13 @@ public function testWhere()
108108
/**
109109
* Test.
110110
*/
111-
public function testTruncate()
111+
public function testTruncate(): void
112112
{
113113
$delete = $this->delete()->from('test')->truncate();
114114
$this->assertSame('TRUNCATE TABLE `test`;', $delete->build());
115115
}
116116

117-
protected function setUp()
117+
protected function setUp(): void
118118
{
119119
parent::setUp();
120120
$this->createTestTable();

tests/FunctionBuilderTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class FunctionBuilderTest extends BaseTest
1818
*
1919
* @return void
2020
*/
21-
public function testInstance()
21+
public function testInstance(): void
2222
{
2323
$func = $this->getConnection()->select()->func();
2424
$this->assertInstanceOf(FunctionBuilder::class, $func);
@@ -46,7 +46,7 @@ public function testSum()
4646
*
4747
* @return void
4848
*/
49-
public function testAvg()
49+
public function testAvg(): void
5050
{
5151
$func = $this->getConnection()->select()->func();
5252

@@ -59,7 +59,7 @@ public function testAvg()
5959
*
6060
* @return void
6161
*/
62-
public function testMin()
62+
public function testMin(): void
6363
{
6464
$func = $this->getConnection()->select()->func();
6565

@@ -72,7 +72,7 @@ public function testMin()
7272
*
7373
* @return void
7474
*/
75-
public function testMax()
75+
public function testMax(): void
7676
{
7777
$func = $this->getConnection()->select()->func();
7878

@@ -85,7 +85,7 @@ public function testMax()
8585
*
8686
* @return void
8787
*/
88-
public function testCount()
88+
public function testCount(): void
8989
{
9090
$func = $this->getConnection()->select()->func();
9191

@@ -103,7 +103,7 @@ public function testCount()
103103
*
104104
* @return void
105105
*/
106-
public function testNow()
106+
public function testNow(): void
107107
{
108108
$func = $this->getConnection()->select()->func();
109109

@@ -117,7 +117,7 @@ public function testNow()
117117
*
118118
* @return void
119119
*/
120-
public function testCustom()
120+
public function testCustom(): void
121121
{
122122
$query = $this->getConnection()->select();
123123
$func = $query->func();

tests/InsertQueryTest.php

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,43 @@
99
*/
1010
class InsertQueryTest extends BaseTest
1111
{
12+
/**
13+
* Set up.
14+
*
15+
* @return void
16+
*/
17+
protected function setUp(): void
18+
{
19+
parent::setUp();
20+
$this->createTestTable();
21+
}
22+
1223
/**
1324
* Test create object.
1425
*
1526
* @return void
1627
*/
17-
public function testInstance()
28+
public function testInstance(): void
1829
{
1930
$this->assertInstanceOf(InsertQuery::class, $this->insert());
2031
}
2132

2233
/**
23-
* @return InsertQuery
34+
* Create insert.
35+
*
36+
* @return InsertQuery The query
2437
*/
25-
protected function insert()
38+
protected function insert(): InsertQuery
2639
{
2740
return new InsertQuery($this->getConnection());
2841
}
2942

3043
/**
3144
* Test.
45+
*
46+
* @return void
3247
*/
33-
public function testInto()
48+
public function testInto(): void
3449
{
3550
$insert = $this->insert()->into('test')->set(['keyname' => 'admin-007']);
3651
$this->assertSame("INSERT INTO `test` SET `keyname`='admin-007';", $insert->build());
@@ -42,8 +57,10 @@ public function testInto()
4257

4358
/**
4459
* Test.
60+
*
61+
* @return void
4562
*/
46-
public function testLastInsertId()
63+
public function testLastInsertId(): void
4764
{
4865
$insert = $this->insert()->into('test')->set(['keyname' => 'admin-007']);
4966
$insert->execute();
@@ -52,17 +69,21 @@ public function testLastInsertId()
5269

5370
/**
5471
* Test.
72+
*
73+
* @return void
5574
*/
56-
public function testInsertGetId()
75+
public function testInsertGetId(): void
5776
{
5877
$insertGetId = $this->insert()->into('test')->insertGetId(['keyname' => 'admin-007']);
5978
$this->assertSame('1', $insertGetId);
6079
}
6180

6281
/**
6382
* Test.
83+
*
84+
* @return void
6485
*/
65-
public function testPriority()
86+
public function testPriority(): void
6687
{
6788
$insert = $this->insert()->lowPriority()->into('test')->set(['username' => 'admin']);
6889
$this->assertSame("INSERT LOW_PRIORITY INTO `test` SET `username`='admin';", $insert->build());
@@ -73,8 +94,10 @@ public function testPriority()
7394

7495
/**
7596
* Test.
97+
*
98+
* @return void
7699
*/
77-
public function testIgnore()
100+
public function testIgnore(): void
78101
{
79102
$insert = $this->insert()->ignore()->into('test')->set(['username' => 'admin']);
80103
$this->assertSame("INSERT IGNORE INTO `test` SET `username`='admin';", $insert->build());
@@ -85,26 +108,25 @@ public function testIgnore()
85108

86109
/**
87110
* Test.
111+
*
112+
* @return void
88113
*/
89-
public function testDelayed()
114+
public function testDelayed(): void
90115
{
91116
$insert = $this->insert()->delayed()->into('test')->set(['username' => 'admin']);
92117
$this->assertSame("INSERT DELAYED INTO `test` SET `username`='admin';", $insert->build());
93118
}
94119

95120
/**
96121
* Test.
122+
*
123+
* @return void
97124
*/
98-
public function testOnDuplicateKeyUpdate()
125+
public function testOnDuplicateKeyUpdate(): void
99126
{
100127
$insert = $this->insert()->ignore()->into('test')->set(['username' => 'admin']);
101128
$insert->onDuplicateKeyUpdate(['username' => 'admin-01']);
102129
$this->assertSame("INSERT IGNORE INTO `test` SET `username`='admin' ON DUPLICATE KEY UPDATE `username`='admin-01';", $insert->build());
103130
}
104131

105-
protected function setUp()
106-
{
107-
parent::setUp();
108-
$this->createTestTable();
109-
}
110132
}

tests/QuoterTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class QuoterTest extends BaseTest
1717
*
1818
* @return void
1919
*/
20-
public function testInstance()
20+
public function testInstance(): void
2121
{
2222
$connection = $this->getConnection()->getQuoter();
2323
$this->assertInstanceOf(Quoter::class, $connection);
@@ -28,7 +28,7 @@ public function testInstance()
2828
*
2929
* @return void
3030
*/
31-
public function testEsc()
31+
public function testEsc(): void
3232
{
3333
$quoter = $this->getConnection()->getQuoter();
3434
$this->assertSame('NULL', $quoter->quoteValue(null));
@@ -66,7 +66,7 @@ public function testEsc()
6666
*
6767
* @return void
6868
*/
69-
public function testQuoteName()
69+
public function testQuoteName(): void
7070
{
7171
$quoter = $this->getConnection()->getQuoter();
7272

@@ -107,7 +107,7 @@ public function testQuoteName()
107107
*
108108
* @return void
109109
*/
110-
public function testQuoteArray()
110+
public function testQuoteArray(): void
111111
{
112112
$quoter = $this->getConnection()->getQuoter();
113113
$this->assertSame([], $quoter->quoteArray([]));
@@ -124,7 +124,7 @@ public function testQuoteArray()
124124
*
125125
* @return void
126126
*/
127-
public function testQuoteNames()
127+
public function testQuoteNames(): void
128128
{
129129
$quoter = $this->getConnection()->getQuoter();
130130
$this->assertSame([], $quoter->quoteNames([]));
@@ -138,7 +138,7 @@ public function testQuoteNames()
138138
*
139139
* @return void
140140
*/
141-
public function testQuoteByFields()
141+
public function testQuoteByFields(): void
142142
{
143143
$quoter = $this->getConnection()->getQuoter();
144144
$this->assertSame([], $quoter->quoteByFields([]));

0 commit comments

Comments
 (0)