Skip to content

Commit f16c471

Browse files
author
Berry Goudswaard
committed
Add test for TableRegistry::delete()
1 parent 16c36b1 commit f16c471

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/TestCase/ORM/TableRegistryTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,26 @@ public function testGenericInstances() {
345345
$this->assertEquals($expected, TableRegistry::genericInstances());
346346
}
347347

348+
/**
349+
* Tests deleting an instance
350+
*
351+
* @return void
352+
*/
353+
public function testDelete() {
354+
Plugin::load('TestPlugin');
355+
356+
$pluginTable = TableRegistry::get('TestPlugin.Comments');
357+
$cachedTable = TableRegistry::get('Comments');
358+
359+
$this->assertTrue(TableRegistry::exists('Comments'));
360+
$this->assertSame($pluginTable, $cachedTable);
361+
362+
TableRegistry::delete('Comments');
363+
$this->assertFalse(TableRegistry::exists('Comments'));
364+
365+
$appTable = TableRegistry::get('Comments');
366+
$this->assertTrue(TableRegistry::exists('Comments'));
367+
$this->assertNotSame($pluginTable, $appTable);
368+
}
369+
348370
}

0 commit comments

Comments
 (0)