Permalink
Browse files

Adding test to ensure blob integrity. Disproves #199

  • Loading branch information...
1 parent 72830cb commit 79fdd8b341437287549ace1f413bd495e6db8d3e @markstory markstory committed Oct 24, 2009
Showing with 24 additions and 5 deletions.
  1. +24 −5 cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
@@ -153,6 +153,7 @@ function schema() {
* @subpackage cake.tests.cases.libs.model.datasources.dbo
*/
class DboMysqlTest extends CakeTestCase {
+ var $fixtures = array('core.binary_test');
/**
* The Dbo instance to be tested
*
@@ -176,7 +177,6 @@ function skip() {
*/
function setUp() {
$db = ConnectionManager::getDataSource('test_suite');
- $this->db = new DboMysqlTestDb($db->config);
$this->model = new MysqlTestModel();
}
/**
@@ -185,7 +185,8 @@ function setUp() {
* @access public
*/
function tearDown() {
- unset($this->db);
+ unset($this->model);
+ ClassRegistry::flush();
}
/**
* startCase
@@ -269,7 +270,7 @@ function testQuoting() {
* @return void
*/
function testTinyintCasting() {
- $this->db->cacheSources = $this->db->testing = false;
+ $this->db->cacheSources = false;
$this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
$this->model = new CakeTestModel(array(
@@ -307,7 +308,7 @@ function testTinyintCasting() {
* @access public
*/
function testIndexDetection() {
- $this->db->cacheSources = $this->db->testing = false;
+ $this->db->cacheSources = false;
$name = $this->db->fullTableName('simple');
$this->db->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
@@ -510,7 +511,7 @@ function testColumn() {
*/
function testAlterSchemaIndexes() {
App::import('Core', 'Schema');
- $this->db->cacheSources = $this->db->testing = false;
+ $this->db->cacheSources = false;
$schema1 =& new CakeSchema(array(
'name' => 'AlterTest1',
@@ -574,5 +575,23 @@ function testAlterSchemaIndexes() {
$this->db->query($this->db->dropSchema($schema1));
}
+/**
+ * test saving and retrieval of blobs
+ *
+ * @return void
+ **/
+ function testBlobSaving() {
+ $this->db->cacheSources = false;
+ $data = "GIF87ab
+ Ò4A¿¿¿ˇˇˇ,b
+ ¢îè©ÀÌ#¥⁄ã≥fi:¯Ü‚Héá¶jV∂ÓúÎL≥çÀóËıÎ…>ï≈ vFE%ÒâLFI<†µw˝±≈£7˘ç^H“≤« >Éâ*∑ÇnÖA•Ù|flêèj£:=ÿ6óUàµ5'∂®àA¬ñ∆ˆGE(gt’≈àÚyÁó«7 ‚VìöÇ√˙Ç™
+ k”:;kÀAõ{*¡€Î˚˚[;;";
+
+ $model =& new AppModel(array('name' => 'BinaryTest', 'ds' => 'test_suite'));
+ $model->save(compact('data'));
+
+ $result = $model->find('first');
+ $this->assertEqual($result['BinaryTest']['data'], $data);
+ }
}
?>

0 comments on commit 79fdd8b

Please sign in to comment.