Skip to content

Commit 0d580ea

Browse files
committed
Added travis graphic
1 parent 7d2d079 commit 0d580ea

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"require-dev": {
1313
"phpunit/phpunit": "~4.0",
14-
"phake/phake": "1.0.5"
14+
"phake/phake": "1.0.5",
15+
"jimbojsb/pseudo": "dev-master"
1516
},
1617
"autoload": {
1718
"psr-4": {

src/Databases/MySQL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ public function getLastInsertId() {
9494
* @return array
9595
*/
9696
public function getTableFields($table) {
97+
$table = $this->select()->aliasReplacer()->replace($table);
9798
if(array_key_exists($table, self::$tableFields)) {
9899
return self::$tableFields[$table];
99100
}
100101
$stmt = $this->pdo->query("DESCRIBE {$table}");
101-
$stmt->execute();
102102
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
103103
self::$tableFields[$table] = array_map(function ($row) { return $row['Field']; }, $rows);
104104
$stmt->closeCursor();

tests/Databases/MySQLTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
namespace Kir\MySQL\Databases;
33

4-
use PDO;
4+
use Phake;
5+
use Pseudo\Pdo;
56

67
class MySQLTest extends \PHPUnit_Framework_TestCase {
78
public function testTransactionTries1() {
8-
$pdo = new PDO('sqlite::memory:');
9+
$pdo = new Pdo();
910
$mysql = new MySQL($pdo);
1011

1112
$this->setExpectedException('Exception', '5');
@@ -18,7 +19,7 @@ public function testTransactionTries1() {
1819
}
1920

2021
public function testTransactionTries2() {
21-
$pdo = new PDO('sqlite::memory:');
22+
$pdo = new Pdo();
2223
$mysql = new MySQL($pdo);
2324

2425
$result = $mysql->transaction(5, function () {
@@ -32,4 +33,15 @@ public function testTransactionTries2() {
3233

3334
$this->assertEquals(5, $result);
3435
}
36+
37+
public function testGetTableFields() {
38+
$pdo = new Pdo();
39+
$pdo->mock('DESCRIBE test__table', [['Field' => 'a'], ['Field' => 'b'], ['Field' => 'c']]);
40+
41+
$mysql = new MySQL($pdo);
42+
$mysql->getAliasRegistry()->add('test', 'test__');
43+
$fields = $mysql->getTableFields('test#table');
44+
45+
$this->assertEquals(array('a', 'b', 'c'), $fields);
46+
}
3547
}

0 commit comments

Comments
 (0)