Browse Source

Fixing tests affected by the Orm/SchemaCache changes

Florian Krämer 8 years ago
parent
commit
772f80df4d

+ 2 - 9
src/Shell/OrmCacheShell.php

@@ -22,17 +22,10 @@ namespace Cake\Shell;
  * can prevent thundering herd effects on the metadata cache when new
  * versions of your application are deployed, or when migrations
  * requiring updated metadata are required.
+ *
+ * @deprecated Use \Cake\Shell\SchemaCacheShell instead
  */
 class OrmCacheShell extends SchemaCacheShell
 {
 
-    /**
-     * @inheritDoc
-     */
-    public function initialize()
-    {
-        parent::initialize();
-
-        trigger_error('OrmCache shell is deprecated, use SchemaCache shell instead.', E_USER_DEPRECATED);
-    }
 }

+ 4 - 4
src/Shell/SchemaCacheShell.php

@@ -45,7 +45,7 @@ class SchemaCacheShell extends Shell
      */
     public function build($name = null)
     {
-        $cache = $this->_getOrmCache();
+        $cache = $this->_getSchemaCache();
         $tables = $cache->build($name);
 
         foreach ($tables as $table) {
@@ -65,7 +65,7 @@ class SchemaCacheShell extends Shell
      */
     public function clear($name = null)
     {
-        $cache = $this->_getOrmCache();
+        $cache = $this->_getSchemaCache();
         $tables = $cache->clear($name);
 
         foreach ($tables as $table) {
@@ -80,9 +80,9 @@ class SchemaCacheShell extends Shell
     /**
      * Gets the Schema Cache instance
      *
-     * @return \Cake\ORM\OrmCache
+     * @return \Cake\Database\SchemaCache
      */
-    protected function _getOrmCache()
+    protected function _getSchemaCache()
     {
         try {
             return new SchemaCache($this->params['connection']);

+ 13 - 13
tests/TestCase/Database/SchemaCacheTest.php

@@ -16,15 +16,15 @@ namespace Cake\Test\TestCase\ORM;
 
 use Cake\Cache\Cache;
 use Cake\Cache\CacheEngine;
+use Cake\Database\SchemaCache;
 use Cake\Database\Schema\CachedCollection;
 use Cake\Datasource\ConnectionManager;
-use Cake\ORM\OrmCache;
 use Cake\TestSuite\TestCase;
 
 /**
- * OrmCache test.
+ * SchemaCache test.
  */
-class OrmCacheTest extends TestCase
+class SchemaCacheTest extends TestCase
 {
 
     /**
@@ -84,7 +84,7 @@ class OrmCacheTest extends TestCase
         $ds = ConnectionManager::get('test');
         $ds->cacheMetadata(false);
 
-        $ormCache = new OrmCache('test');
+        $ormCache = new SchemaCache('test');
         $ormCache->clear();
 
         $this->assertInstanceOf('Cake\Database\Schema\CachedCollection', $ds->schemaCollection());
@@ -100,7 +100,7 @@ class OrmCacheTest extends TestCase
         $ds = ConnectionManager::get('test');
         $ds->cacheMetadata(false);
 
-        $ormCache = new OrmCache('test');
+        $ormCache = new SchemaCache('test');
         $ormCache->build();
 
         $this->assertInstanceOf('Cake\Database\Schema\CachedCollection', $ds->schemaCollection());
@@ -117,7 +117,7 @@ class OrmCacheTest extends TestCase
             ->method('write')
             ->with('test_articles');
 
-        $ormCache = new OrmCache('test');
+        $ormCache = new SchemaCache('test');
         $ormCache->build();
     }
 
@@ -134,7 +134,7 @@ class OrmCacheTest extends TestCase
         $this->cache->expects($this->never())
             ->method('delete');
 
-        $ormCache = new OrmCache('test');
+        $ormCache = new SchemaCache('test');
         $ormCache->build('articles');
     }
 
@@ -153,7 +153,7 @@ class OrmCacheTest extends TestCase
         $this->cache->expects($this->never())
             ->method('delete');
 
-        $ormCache = new OrmCache('test');
+        $ormCache = new SchemaCache('test');
         $ormCache->build('articles');
     }
 
@@ -165,7 +165,7 @@ class OrmCacheTest extends TestCase
      */
     public function testInvalidConnection()
     {
-        new OrmCache('invalid-connection');
+        new SchemaCache('invalid-connection');
     }
 
     /**
@@ -179,7 +179,7 @@ class OrmCacheTest extends TestCase
             ->method('delete')
             ->with('test_articles');
 
-        $ormCache = new OrmCache('test');
+        $ormCache = new SchemaCache('test');
         $ormCache->clear();
     }
 
@@ -196,7 +196,7 @@ class OrmCacheTest extends TestCase
             ->method('delete')
             ->with('test_articles');
 
-        $ormCache = new OrmCache('test');
+        $ormCache = new SchemaCache('test');
         $ormCache->clear('articles');
     }
 
@@ -209,7 +209,7 @@ class OrmCacheTest extends TestCase
     {
         $ds = ConnectionManager::get('test');
 
-        $ormCache = new OrmCache($ds);
+        $ormCache = new SchemaCache($ds);
         $result = $ormCache->getSchema($ds);
 
         $this->assertInstanceOf(CachedCollection::class, $result);
@@ -224,6 +224,6 @@ class OrmCacheTest extends TestCase
      */
     public function testPassingInvalidObject()
     {
-        new OrmCache(new \stdClass());
+        new SchemaCache(new \stdClass());
     }
 }

+ 2 - 2
tests/TestCase/Shell/CommandListShellTest.php

@@ -79,7 +79,7 @@ class CommandListShellTest extends TestCase
         $expected = "/\[.*TestPluginTwo.*\] example, unique, welcome/";
         $this->assertRegExp($expected, $output);
 
-        $expected = "/\[.*CORE.*\] cache, help, i18n, orm_cache, plugin, routes, server/";
+        $expected = "/\[.*CORE.*\] cache, help, i18n, orm_cache, plugin, routes, schema_cache, server/";
         $this->assertRegExp($expected, $output);
 
         $expected = "/\[.*app.*\] i18m, integration, sample/";
@@ -100,7 +100,7 @@ class CommandListShellTest extends TestCase
         $output = implode("\n", $output);
         rename(APP . 'Shell' . DS . 'I18nShell.php', APP . 'Shell' . DS . 'I18mShell.php');
 
-        $expected = "/\[.*CORE.*\] cache, help, orm_cache, plugin, routes, server/";
+        $expected = "/\[.*CORE.*\] cache, help, orm_cache, plugin, routes, schema_cache, server/";
         $this->assertRegExp($expected, $output);
 
         $expected = "/\[.*app.*\] i18n, integration, sample/";

+ 1 - 1
tests/TestCase/Shell/CompletionShellTest.php

@@ -116,7 +116,7 @@ class CompletionShellTest extends TestCase
         $output = $this->out->output;
 
         $expected = 'TestPlugin.example TestPlugin.sample TestPluginTwo.example unique welcome ' .
-            "cache help i18n orm_cache plugin routes server version i18m integration sample testing_dispatch\n";
+            "cache help i18n orm_cache plugin routes schema_cache server version i18m integration sample testing_dispatch\n";
         $this->assertTextEquals($expected, $output);
     }