Skip to content

Commit ae40ec2

Browse files
committed
corrections, improved test example for query_prepared method, some code coverage
1 parent 7c004c7 commit ae40ec2

File tree

4 files changed

+88
-4
lines changed

4 files changed

+88
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ foreach ($result as $row) {
190190
}
191191
```
192192

193+
>Note: `query_prepared()` example works correctly for MySQL, the other drivers will return full query result statement. Will not be stored in `last_result`.
194+
193195
## For Authors and **[Contributors](https://github.com/ezSQL/ezsql/blob/master/CONTRIBUTORS.md)**
194196

195197
## Contributing

lib/ezFunctions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ function index(string $indexName, ...$indexKeys)
8383
return \column(\INDEX, $indexName, ...$indexKeys);
8484
}
8585

86-
function add(string $columnName, ...$datatype)
86+
function addColumn(string $columnName, ...$datatype)
8787
{
8888
return \column(\ADD, $columnName, ...$datatype);
8989
}
9090

91-
function drop(string $columnName, ...$data)
91+
function dropColumn(string $columnName, ...$data)
9292
{
9393
return \column(\DROP, $columnName, ...$data);
9494
}

tests/ezFunctionsTest.php

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,82 @@ protected function setUp(): void
1111
\clearInstance();
1212
}
1313

14+
/**
15+
* @test getInstance
16+
*/
17+
public function testGetInstance()
18+
{
19+
$this->assertNull(getInstance());
20+
}
21+
22+
/**
23+
* @test getVendor
24+
*/
25+
public function testGetVendor()
26+
{
27+
$this->assertNull(getVendor());
28+
}
29+
30+
/**
31+
* @test column
32+
*/
33+
public function testColumn()
34+
{
35+
$this->assertFalse(column('string', VARCHAR, 32));
36+
}
37+
38+
/**
39+
* @test primary
40+
*/
41+
public function testPrimary()
42+
{
43+
$this->assertFalse(primary('label', 'column'));
44+
}
45+
46+
/**
47+
* @test foreign
48+
*/
49+
public function testForeign()
50+
{
51+
$this->assertFalse(foreign('label', 'column'));
52+
}
53+
54+
/**
55+
* @test unique
56+
*/
57+
public function testUnique()
58+
{
59+
$this->assertFalse(unique('label', 'column'));
60+
}
61+
62+
/**
63+
* @test index
64+
*/
65+
public function testIndex()
66+
{
67+
$this->assertFalse(index('label', 'column'));
68+
}
69+
70+
/**
71+
* @test addColumn
72+
*/
73+
public function testAddColumn()
74+
{
75+
$this->assertFalse(addColumn('column', VARCHAR, 32));
76+
}
77+
78+
/**
79+
* @test dropColumn
80+
*/
81+
public function testDropColumn()
82+
{
83+
$this->assertFalse(dropColumn('column', 'column'));
84+
}
85+
1486
/**
1587
* @test eq
1688
*/
17-
public function testeq()
89+
public function testEq()
1890
{
1991
$this->assertInternalType('array',eq('field', 'data'));
2092
$this->assertArraySubset([1 => EQ], eq('field', 'data'));

tests/mysqli/mysqliTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,18 @@ public function testQuery_prepared() {
515515
column('prepare_key', VARCHAR, 50))
516516
);
517517

518-
$result = $this->object->query_prepared('INSERT INTO unit_test( id, prepare_key ) VALUES( 9, ? )', ['test 1']);
518+
$result = $this->object->query_prepared('INSERT INTO unit_test( id, prepare_key ) VALUES( ?, ? )', [ 9, 'test 1']);
519519
$this->assertEquals(1, $result);
520+
521+
$this->object->query_prepared('SELECT prepare_key FROM unit_test WHERE id = ?', [9]);
522+
$query = $this->object->queryResult();
523+
524+
foreach($query as $row) {
525+
$result = $row->prepare_key;
526+
}
527+
528+
$this->assertEquals('test 1', $this->object->queryResult()[0]->prepare_key);
529+
$this->assertEquals('test 1', $result);
520530
} // testQuery_prepared
521531

522532
/**

0 commit comments

Comments
 (0)