Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AgelxNash committed Jun 16, 2018
1 parent 17e0738 commit a45e075
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Drivers/IlluminateDriver.php
Expand Up @@ -393,7 +393,9 @@ public function getColumn($name, $result)

if ($this->isResult($result)) {
while ($row = $this->getRow($result)) {
$col[] = $row[$name];
if (array_key_exists($name, $row)) {
$col[] = $row[$name];
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/Drivers/MySqliDriver.php
Expand Up @@ -266,7 +266,9 @@ public function getColumn($name, $result)

if ($this->isResult($result)) {
while ($row = $this->getRow($result)) {
$col[] = $row[$name];
if (array_key_exists($name, $row)) {
$col[] = $row[$name];
}
}
}

Expand Down
35 changes: 35 additions & 0 deletions tests/RealQueryTest.php
Expand Up @@ -129,6 +129,11 @@ public function testHelperMethods()
$this->instance->getColumnNames($result)
);

$this->assertEquals(
[],
$this->instance->getColumnNames(null)
);

$out = $this->instance->getColumn('id', $result);
$this->assertEquals(
['1', '2', '4'],
Expand All @@ -139,11 +144,26 @@ public function testHelperMethods()
$this->instance->getColumn('id', $query)
);

$this->assertEquals(
[],
$this->instance->getColumn('id', null)
);

$this->assertEquals(
[],
$this->instance->getColumn('nop', $query)
);

$this->assertEquals(
3,
$this->instance->getRecordCount($result)
);

$this->assertEquals(
0,
$this->instance->getRecordCount(null)
);

$this->assertEquals(
'id',
$this->instance->fieldName($result, 0)
Expand All @@ -154,10 +174,20 @@ public function testHelperMethods()
$this->instance->fieldName($result, 1)
);

$this->assertEquals(
null,
$this->instance->fieldName(null)
);

$this->assertEquals(
2,
$this->instance->numFields($result)
);

$this->assertEquals(
0,
$this->instance->numFields(null)
);
}

public function testUpdate()
Expand Down Expand Up @@ -291,6 +321,11 @@ public function testGetTableMetaData()
{
$this->instance->flushExecutedQuery();

$this->assertEquals(
[],
$this->instance->getTableMetaData('')
);

$data = $this->instance->getTableMetaData($this->table);

$this->assertArrayHasKey('id', $data);
Expand Down

0 comments on commit a45e075

Please sign in to comment.