Browse Source

Add a few more asserts

AD7six 11 years ago
parent
commit
f4d258d482
1 changed files with 32 additions and 29 deletions
  1. 32 29
      tests/TestCase/ORM/TableRegistryTest.php

+ 32 - 29
tests/TestCase/ORM/TableRegistryTest.php

@@ -239,8 +239,7 @@ class TableRegistryTest extends TestCase
         Plugin::load('TestPlugin');
         $table = TableRegistry::get('TestPlugin.TestPluginComments', ['connection' => 'test']);
 
-        $class = 'TestPlugin\Model\Table\TestPluginCommentsTable';
-        $this->assertInstanceOf($class, $table);
+        $this->assertInstanceOf('TestPlugin\Model\Table\TestPluginCommentsTable', $table);
         $this->assertFalse(
             TableRegistry::exists('TestPluginComments'),
             'Short form should NOT exist'
@@ -255,6 +254,35 @@ class TableRegistryTest extends TestCase
     }
 
     /**
+     * Test get() with same-alias models in different plugins
+     *
+     * There should be no internal cache-confusion
+     *
+     * @return void
+     */
+    public function testGetMultiplePlugins()
+    {
+        Plugin::load('TestPlugin');
+        Plugin::load('TestPluginTwo');
+
+        $app = TableRegistry::get('Comments');
+        $plugin1 = TableRegistry::get('TestPlugin.Comments');
+        $plugin2 = TableRegistry::get('TestPluginTwo.Comments');
+
+        $this->assertInstanceOf('Cake\ORM\Table', $app, 'Should be an app table instance');
+        $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $plugin1, 'Should be a plugin 1 table instance');
+        $this->assertInstanceOf('TestPluginTwo\Model\Table\CommentsTable', $plugin2, 'Should be a plugin 2 table instance');
+
+        $plugin2 = TableRegistry::get('TestPluginTwo.Comments');
+        $plugin1 = TableRegistry::get('TestPlugin.Comments');
+        $app = TableRegistry::get('Comments');
+
+        $this->assertInstanceOf('Cake\ORM\Table', $app, 'Should still be an app table instance');
+        $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $plugin1, 'Should still be a plugin 1 table instance');
+        $this->assertInstanceOf('TestPluginTwo\Model\Table\CommentsTable', $plugin2, 'Should still be a plugin 2 table instance');
+    }
+
+    /**
      * Test get() with plugin aliases + className option.
      *
      * @return void
@@ -269,6 +297,7 @@ class TableRegistryTest extends TestCase
         $class = 'TestPlugin\Model\Table\TestPluginCommentsTable';
         $this->assertInstanceOf($class, $table);
         $this->assertFalse(TableRegistry::exists('TestPluginComments'), 'Class name should not exist');
+        $this->assertFalse(TableRegistry::exists('TestPlugin.TestPluginComments'), 'Full class alias should not exist');
         $this->assertTrue(TableRegistry::exists('Comments'), 'Class name should exist');
 
         $second = TableRegistry::get('Comments');
@@ -290,37 +319,11 @@ class TableRegistryTest extends TestCase
         ]);
         $this->assertInstanceOf($class, $table);
         $this->assertFalse(TableRegistry::exists('TestPluginComments'), 'Class name should not exist');
+        $this->assertFalse(TableRegistry::exists('TestPlugin.TestPluginComments'), 'Full class alias should not exist');
         $this->assertTrue(TableRegistry::exists('Comments'), 'Class name should exist');
     }
 
     /**
-     * Test get() with same-alias models in different plugins
-     *
-     * @return void
-     */
-    public function testGetMultiplePlugins()
-    {
-        Plugin::load('TestPlugin');
-        Plugin::load('TestPluginTwo');
-
-        $app = TableRegistry::get('Comments');
-        $plugin1 = TableRegistry::get('TestPlugin.Comments');
-        $plugin2 = TableRegistry::get('TestPluginTwo.Comments');
-
-        $this->assertInstanceOf('Cake\ORM\Table', $app, 'Should be an app table instance');
-        $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $plugin1, 'Should be a plugin 1 table instance');
-        $this->assertInstanceOf('TestPluginTwo\Model\Table\CommentsTable', $plugin2, 'Should be a plugin 2 table instance');
-
-        $plugin2 = TableRegistry::get('TestPluginTwo.Comments');
-        $plugin1 = TableRegistry::get('TestPlugin.Comments');
-        $app = TableRegistry::get('Comments');
-
-        $this->assertInstanceOf('Cake\ORM\Table', $app, 'Should still be an app table instance');
-        $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $plugin1, 'Should still be a plugin 1 table instance');
-        $this->assertInstanceOf('TestPluginTwo\Model\Table\CommentsTable', $plugin2, 'Should still be a plugin 2 table instance');
-    }
-
-    /**
      * Tests that table options can be pre-configured for the factory method
      *
      * @return void