|
|
@@ -32,7 +32,8 @@ class TableUuidTest extends TestCase
|
|
|
* @var array
|
|
|
*/
|
|
|
public $fixtures = [
|
|
|
- 'core.uuiditems', 'core.uuidportfolios'
|
|
|
+ 'core.binary_uuiditems',
|
|
|
+ 'core.uuiditems',
|
|
|
];
|
|
|
|
|
|
/**
|
|
|
@@ -59,17 +60,28 @@ class TableUuidTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Provider for testing that string and binary uuids work the same
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function uuidTableProvider()
|
|
|
+ {
|
|
|
+ return [['uuiditems'], ['binary_uuiditems']];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Test saving new records sets uuids
|
|
|
*
|
|
|
+ * @dataProvider uuidTableProvider
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testSaveNew()
|
|
|
+ public function testSaveNew($tableName)
|
|
|
{
|
|
|
$entity = new Entity([
|
|
|
'name' => 'shiny new',
|
|
|
'published' => true,
|
|
|
]);
|
|
|
- $table = TableRegistry::get('uuiditems');
|
|
|
+ $table = TableRegistry::get($tableName);
|
|
|
$this->assertSame($entity, $table->save($entity));
|
|
|
$this->assertRegExp('/^[a-f0-9-]{36}$/', $entity->id, 'Should be 36 characters');
|
|
|
|
|
|
@@ -81,9 +93,10 @@ class TableUuidTest extends TestCase
|
|
|
/**
|
|
|
* Test saving new records allows manual uuids
|
|
|
*
|
|
|
+ * @dataProvider uuidTableProvider
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testSaveNewSpecificId()
|
|
|
+ public function testSaveNewSpecificId($tableName)
|
|
|
{
|
|
|
$id = Text::uuid();
|
|
|
$entity = new Entity([
|
|
|
@@ -91,7 +104,7 @@ class TableUuidTest extends TestCase
|
|
|
'name' => 'shiny and new',
|
|
|
'published' => true,
|
|
|
]);
|
|
|
- $table = TableRegistry::get('uuiditems');
|
|
|
+ $table = TableRegistry::get($tableName);
|
|
|
$this->assertSame($entity, $table->save($entity));
|
|
|
$this->assertSame($id, $entity->id);
|
|
|
|
|
|
@@ -104,9 +117,10 @@ class TableUuidTest extends TestCase
|
|
|
/**
|
|
|
* Test saving existing records works
|
|
|
*
|
|
|
+ * @dataProvider uuidTableProvider
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testSaveUpdate()
|
|
|
+ public function testSaveUpdate($tableName)
|
|
|
{
|
|
|
$id = '481fc6d0-b920-43e0-a40d-6d1740cf8569';
|
|
|
$entity = new Entity([
|
|
|
@@ -115,7 +129,7 @@ class TableUuidTest extends TestCase
|
|
|
'published' => true,
|
|
|
]);
|
|
|
|
|
|
- $table = TableRegistry::get('uuiditems');
|
|
|
+ $table = TableRegistry::get($tableName);
|
|
|
$this->assertSame($entity, $table->save($entity));
|
|
|
$this->assertEquals($id, $entity->id, 'Should be 36 characters');
|
|
|
|
|
|
@@ -127,12 +141,13 @@ class TableUuidTest extends TestCase
|
|
|
/**
|
|
|
* Test delete with string pk.
|
|
|
*
|
|
|
+ * @dataProvider uuidTableProvider
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testDelete()
|
|
|
+ public function testDelete($tableName)
|
|
|
{
|
|
|
$id = '481fc6d0-b920-43e0-a40d-6d1740cf8569';
|
|
|
- $table = TableRegistry::get('uuiditems');
|
|
|
+ $table = TableRegistry::get($tableName);
|
|
|
$entity = $table->find('all')->where(['id' => $id])->first();
|
|
|
|
|
|
$this->assertTrue($table->delete($entity));
|
|
|
@@ -143,12 +158,13 @@ class TableUuidTest extends TestCase
|
|
|
/**
|
|
|
* Tests that sql server does not error when an empty uuid is bound
|
|
|
*
|
|
|
+ * @dataProvider uuidTableProvider
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testEmptyUuid()
|
|
|
+ public function testEmptyUuid($tableName)
|
|
|
{
|
|
|
$id = '';
|
|
|
- $table = TableRegistry::get('uuiditems');
|
|
|
+ $table = TableRegistry::get($tableName);
|
|
|
$entity = $table->find('all')
|
|
|
->where(['id' => $id])
|
|
|
->first();
|