Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add a more comprehensive plugin-delete test
  • Loading branch information
AD7six committed Feb 10, 2015
1 parent f2a61e2 commit eced506
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/TestCase/ORM/TableRegistryTest.php
Expand Up @@ -466,4 +466,51 @@ public function testRemove()
$this->assertNotSame($first, $second, 'Should be different objects, as the reference to the first was destroyed');
$this->assertTrue(TableRegistry::exists('Comments'));
}

/**
* testRemovePlugin
*
* Removing a plugin-prefixed model should not affect any other
* plugin-prefixed model, or app model.
* Removing an app model should not affect any other
* plugin-prefixed model.
*
* @return void
*/
public function testRemovePlugin()
{
Plugin::load('TestPlugin');
Plugin::load('TestPluginTwo');

$app = TableRegistry::get('Comments');
TableRegistry::get('TestPlugin.Comments');
$plugin = TableRegistry::get('TestPluginTwo.Comments');

$this->assertTrue(TableRegistry::exists('Comments'));
$this->assertTrue(TableRegistry::exists('TestPlugin.Comments'));
$this->assertTrue(TableRegistry::exists('TestPluginTwo.Comments'));

TableRegistry::remove('TestPlugin.Comments');

$this->assertTrue(TableRegistry::exists('Comments'));
$this->assertFalse(TableRegistry::exists('TestPlugin.Comments'));
$this->assertTrue(TableRegistry::exists('TestPluginTwo.Comments'));

$app2 = TableRegistry::get('Comments');
$plugin2 = TableRegistry::get('TestPluginTwo.Comments');

$this->assertSame($app, $app2, 'Should be the same Comments object');
$this->assertSame($plugin, $plugin2, 'Should be the same TestPluginTwo.Comments object');

TableRegistry::remove('Comments');

$this->assertFalse(TableRegistry::exists('Comments'));
$this->assertFalse(TableRegistry::exists('TestPlugin.Comments'));
$this->assertTrue(TableRegistry::exists('TestPluginTwo.Comments'));

$plugin3 = TableRegistry::get('TestPluginTwo.Comments');

$this->assertSame($plugin, $plugin3, 'Should be the same TestPluginTwo.Comments object');
}

}

0 comments on commit eced506

Please sign in to comment.