@@ -76,7 +76,7 @@ class SqliteTest extends CakeTestCase {
76
76
*
77
77
* @var object
78
78
*/
79
- public $ fixtures = array ('core.user ' );
79
+ public $ fixtures = array ('core.user ' , ' core.uuid ' );
80
80
81
81
/**
82
82
* Actual DB connection used in testing
@@ -321,6 +321,20 @@ public function testDescribeWithUuidPrimaryKey() {
321
321
);
322
322
$ this ->assertEqual ($ result ['id ' ], $ expected );
323
323
$ this ->Dbo ->query ('DROP TABLE ' . $ tableName );
324
+
325
+ $ tableName = 'uuid_tests ' ;
326
+ $ this ->Dbo ->query ("CREATE TABLE {$ tableName } (id CHAR(36) PRIMARY KEY, name VARCHAR, created DATETIME, modified DATETIME) " );
327
+ $ Model = new Model (array ('name ' => 'UuidTest ' , 'ds ' => 'test ' , 'table ' => 'uuid_tests ' ));
328
+ $ result = $ this ->Dbo ->describe ($ Model );
329
+ $ expected = array (
330
+ 'type ' => 'string ' ,
331
+ 'length ' => 36 ,
332
+ 'null ' => false ,
333
+ 'default ' => null ,
334
+ 'key ' => 'primary ' ,
335
+ );
336
+ $ this ->assertEqual ($ result ['id ' ], $ expected );
337
+ $ this ->Dbo ->query ('DROP TABLE ' . $ tableName );
324
338
}
325
339
326
340
/**
@@ -338,4 +352,27 @@ public function testVirtualFieldWithFunction() {
338
352
));
339
353
$ this ->assertEquals ('ett ' , $ result ['User ' ]['name ' ]);
340
354
}
355
+
356
+ /**
357
+ * Test that records can be inserted with uuid primary keys, and
358
+ * that the primary key is not blank
359
+ *
360
+ * @return void
361
+ */
362
+ public function testUuidPrimaryKeyInsertion () {
363
+ $ this ->loadFixtures ('Uuid ' );
364
+ $ Model = ClassRegistry::init ('Uuid ' );
365
+
366
+ $ data = array (
367
+ 'title ' => 'A uuid should work ' ,
368
+ 'count ' => 10
369
+ );
370
+ $ Model ->create ($ data );
371
+ $ this ->assertTrue ((bool )$ Model ->save ());
372
+ $ result = $ Model ->read ();
373
+
374
+ $ this ->assertEquals ($ data ['title ' ], $ result ['Uuid ' ]['title ' ]);
375
+ $ this ->assertTrue (Validation::uuid ($ result ['Uuid ' ]['id ' ]), 'Not a uuid ' );
376
+ }
377
+
341
378
}
0 commit comments