Skip to content

Commit

Permalink
Add tests for schemaValue
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 12, 2013
1 parent f13f32f commit 3649d42
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lib/Cake/Test/TestCase/Database/Driver/SqliteTest.php
Expand Up @@ -95,4 +95,40 @@ public function testConnectionConfigCustom() {
$driver->connect($config);
}

/**
* Data provider for schemaValue()
*
* @return array
*/
public static function schemaValueProvider() {
return [
[null, 'NULL'],
[false, 'FALSE'],
[true, 'TRUE'],
[3.14159, '3.14159'],
['33', '33'],
[66, 66],
[0, 0],
[10e5, '1000000'],
['farts', '"farts"'],
];
}
/**
* Test the schemaValue method on Driver.
*
* @dataProvider schemaValueProvider
* @return void
*/
public function testSchemaValue($input, $expected) {
$driver = new Sqlite();
$mock = $this->getMock('FakePdo', ['quote', 'quoteIdentifier']);
$mock->expects($this->any())
->method('quote')
->will($this->returnCallback(function ($value) {
return '"' . $value . '"';
}));
$driver->connection($mock);
$this->assertEquals($expected, $driver->schemaValue($input));
}

}

0 comments on commit 3649d42

Please sign in to comment.