Browse Source

Add test for TableRegistry::delete()

Berry Goudswaard 11 years ago
parent
commit
f16c471458
1 changed files with 22 additions and 0 deletions
  1. 22 0
      tests/TestCase/ORM/TableRegistryTest.php

+ 22 - 0
tests/TestCase/ORM/TableRegistryTest.php

@@ -345,4 +345,26 @@ class TableRegistryTest extends TestCase {
 		$this->assertEquals($expected, TableRegistry::genericInstances());
 	}
 
+/**
+ * Tests deleting an instance
+ *
+ * @return void
+ */
+	public function testDelete() {
+		Plugin::load('TestPlugin');
+
+		$pluginTable = TableRegistry::get('TestPlugin.Comments');
+		$cachedTable = TableRegistry::get('Comments');
+
+		$this->assertTrue(TableRegistry::exists('Comments'));
+		$this->assertSame($pluginTable, $cachedTable);
+
+		TableRegistry::delete('Comments');
+		$this->assertFalse(TableRegistry::exists('Comments'));
+
+		$appTable = TableRegistry::get('Comments');
+		$this->assertTrue(TableRegistry::exists('Comments'));
+		$this->assertNotSame($pluginTable, $appTable);
+	}
+
 }