Browse Source

Make mocks more representative of actual behavior.

Mark Story 7 years ago
parent
commit
accce4770d

+ 1 - 1
src/Cache/Cache.php

@@ -337,7 +337,7 @@ class Cache
                     '%s cache was unable to write \'%s\' to %s cache',
                     $config,
                     $key,
-                    get_class($engine)
+                    get_class($backend)
                 ));
             }
         }

+ 8 - 3
tests/TestCase/Database/SchemaCacheTest.php

@@ -12,7 +12,7 @@
  * @since         3.6.0
  * @license       https://opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Test\TestCase\ORM;
+namespace Cake\Test\TestCase\Database;
 
 use Cake\Cache\Cache;
 use Cake\Cache\CacheEngine;
@@ -114,6 +114,8 @@ class SchemaCacheTest extends TestCase
     public function testBuildNoArgs()
     {
         $ds = ConnectionManager::get('test');
+        $this->cache->method('write')
+            ->will($this->returnValue(true));
         $this->cache->expects($this->at(3))
             ->method('write')
             ->with('test_articles');
@@ -133,7 +135,9 @@ class SchemaCacheTest extends TestCase
 
         $this->cache->expects($this->once())
             ->method('write')
-            ->with('test_articles');
+            ->with('test_articles')
+            ->will($this->returnValue(true));
+
         $this->cache->expects($this->never())
             ->method('delete');
 
@@ -152,7 +156,8 @@ class SchemaCacheTest extends TestCase
 
         $this->cache->expects($this->once())
             ->method('write')
-            ->with('test_articles');
+            ->with('test_articles')
+            ->will($this->returnValue(true));
         $this->cache->expects($this->never())
             ->method('read');
         $this->cache->expects($this->never())

+ 9 - 3
tests/TestCase/Shell/SchemaCacheShellTest.php

@@ -105,6 +105,9 @@ class SchemaCacheShellTest extends TestCase
      */
     public function testBuildNoArgs()
     {
+        $this->cache->expects($this->any())
+            ->method('write')
+            ->will($this->returnValue(true));
         $this->cache->expects($this->at(3))
             ->method('write')
             ->with('test_articles');
@@ -122,7 +125,8 @@ class SchemaCacheShellTest extends TestCase
     {
         $this->cache->expects($this->once())
             ->method('write')
-            ->with('test_articles');
+            ->with('test_articles')
+            ->will($this->returnValue(true));
         $this->cache->expects($this->never())
             ->method('delete');
 
@@ -139,7 +143,8 @@ class SchemaCacheShellTest extends TestCase
     {
         $this->cache->expects($this->once())
             ->method('write')
-            ->with('test_articles');
+            ->with('test_articles')
+            ->will($this->returnValue(true));
         $this->cache->expects($this->never())
             ->method('read');
         $this->cache->expects($this->never())
@@ -182,7 +187,8 @@ class SchemaCacheShellTest extends TestCase
     {
         $this->cache->expects($this->at(3))
             ->method('delete')
-            ->with('test_articles');
+            ->with('test_articles')
+            ->will($this->returnValue(true));
 
         $this->shell->params['connection'] = 'test';
         $this->shell->clear();

+ 6 - 3
tests/TestCase/View/CellTest.php

@@ -426,7 +426,8 @@ class CellTest extends TestCase
             ->will($this->returnValue(false));
         $mock->expects($this->once())
             ->method('write')
-            ->with('cell_test_app_view_cell_articles_cell_display_default', "dummy\n");
+            ->with('cell_test_app_view_cell_articles_cell_display_default', "dummy\n")
+            ->will($this->returnValue(true));
         Cache::setConfig('default', $mock);
 
         $cell = $this->View->cell('Articles', [], ['cache' => true]);
@@ -471,7 +472,8 @@ class CellTest extends TestCase
             ->will($this->returnValue(false));
         $mock->expects($this->once())
             ->method('write')
-            ->with('my_key', "dummy\n");
+            ->with('my_key', "dummy\n")
+            ->will($this->returnValue(true));
         Cache::setConfig('cell', $mock);
 
         $cell = $this->View->cell('Articles', [], [
@@ -496,7 +498,8 @@ class CellTest extends TestCase
             ->will($this->returnValue(false));
         $mock->expects($this->once())
             ->method('write')
-            ->with('cell_test_app_view_cell_articles_cell_customTemplate_default', "<h1>This is the alternate template</h1>\n");
+            ->with('cell_test_app_view_cell_articles_cell_customTemplate_default', "<h1>This is the alternate template</h1>\n")
+            ->will($this->returnValue(true));
         Cache::setConfig('default', $mock);
 
         $this->deprecated(function () {