Skip to content
Permalink
Browse files

adds test for caching result set with file engine. References issue #…

…10111 and this test is failing for me on PHP 7.1.1
  • Loading branch information...
thinkingmedia
thinkingmedia committed Jan 29, 2017
1 parent 17e96e1 commit 82d45df5c2b08fa3ffaeb843cda0ba84566a0e27
Showing with 42 additions and 0 deletions.
  1. +42 −0 tests/TestCase/Cache/Engine/FileEngineTest.php
@@ -17,13 +17,27 @@
use Cake\Cache\Cache;
use Cake\Cache\Engine\FileEngine;
use Cake\Core\Configure;
use Cake\ORM\ResultSet;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use TestApp\Model\Table\ArticlesTable;
/**
* FileEngineTest class
*/
class FileEngineTest extends TestCase
{
/**
* @var array
*/
public $fixtures = [
'core.articles'
];
/**
* @var bool
*/
public $autoFixtures = false;
/**
* setUp method
@@ -192,6 +206,34 @@ public function testSerialize()
$this->assertSame(unserialize($read), $data);
}
/**
* Verify across PHP versions that caching of ResultSet objects works as expected.
*
* @see https://github.com/cakephp/cakephp/issues/10111
* @return void
*/
public function testResultSetCache()
{
Configure::write('App.namespace', 'TestApp');
$this->loadFixtures('Articles');
/* @var ArticlesTable $articles */
$articles = TableRegistry::get('Articles');
$query = $articles->find()->all();
$this->assertInstanceOf(ResultSet::class, $query);
$this->assertSame(3, count($query->toArray()));
$this->_configCache(['serialize' => true]);
$write = Cache::write('articles', $query, 'file_test');
$this->assertTrue($write);
$read = Cache::read('articles', 'file_test');
$this->assertInstanceOf(ResultSet::class, $read);
$this->assertSame(3, count($read->toArray()));
TableRegistry::clear();
}
/**
* testClear method
*

0 comments on commit 82d45df

Please sign in to comment.
You can’t perform that action at this time.