Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 committed Jan 29, 2017
1 parent 17e96e1 commit 82d45df
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/TestCase/Cache/Engine/FileEngineTest.php
Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 82d45df

Please sign in to comment.