array('field' => 'uuid')); } /** * Uuid Behavior test case. * * @author Billy Gunn * @package app * @subpackage app.tests.cases.behaviors */ class UuidTestCase extends CakeTestCase { var $fixtures = array( 'uuid_test' ); /** * testCreateRecord * * Create a new record and verify that a valid uuid * was added to the the uuid field. * * @access public * @return void */ function testCreateRecord() { $this->Record =& new UuidTest(); $data = array('UuidTest' => array('id' => 4, 'uuid' => null, 'name' => 'New record') ); $this->Record->save($data); $result = $this->Record->read(null, 4); $match = preg_match("/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/", $result['UuidTest']['uuid']); $this->assertEqual($match, 1); } /** * testUpdateRecord * * An existing record should not have its uuid updated on save * * @access public * @return void */ function testUpdateRecord() { $this->Record =& new UuidTest(); $data = array('UuidTest' => array ( 'id' => 1, 'uuid' => '758372bc-6fd4-102a-ae1c-00065becda85', 'description' => 'modified record')); $this->Record->save($data); $result = $this->Record->findAll(null, array('id', 'uuid', 'name', 'description')); $expected = array( array('UuidTest' => array( 'id' => 1, 'uuid' => '758372bc-6fd4-102a-ae1c-00065becda85', 'name' => 'First record', 'description' => 'modified record' )) ); $this->assertEqual($result, $expected); } } ?>