Issue #2723115 by Stefan Freudenberg, mayurjadhav: Count cache configuration does not work as expected
parent
7844d0413b
commit
3993ef3313
|
@ -143,7 +143,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
|
|||
// Set up some defaults based on the source configuration.
|
||||
$this->cacheCounts = !empty($configuration['cache_counts']);
|
||||
$this->skipCount = !empty($configuration['skip_count']);
|
||||
$this->cacheKey = !empty($configuration['cache_key']) ? !empty($configuration['cache_key']) : NULL;
|
||||
$this->cacheKey = !empty($configuration['cache_key']) ? $configuration['cache_key'] : NULL;
|
||||
$this->trackChanges = !empty($configuration['track_changes']) ? $configuration['track_changes'] : FALSE;
|
||||
$this->idMap = $this->migration->getIdMap();
|
||||
|
||||
|
|
|
@ -170,6 +170,25 @@ class MigrateSourceTest extends MigrateTestCase {
|
|||
$this->assertEquals(-1, $source->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the key can be set for the count cache.
|
||||
*
|
||||
* @covers ::count
|
||||
*/
|
||||
public function testCountCacheKey() {
|
||||
// Mock the cache to validate set() receives appropriate arguments.
|
||||
$container = new ContainerBuilder();
|
||||
$cache = $this->getMock(CacheBackendInterface::class);
|
||||
$cache->expects($this->any())->method('set')
|
||||
->with('test_key', $this->isType('int'), $this->isType('int'));
|
||||
$container->set('cache.migrate', $cache);
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
// Test caching the count with a configured key works.
|
||||
$source = $this->getSource(['cache_counts' => TRUE, 'cache_key' => 'test_key']);
|
||||
$this->assertEquals(1, $source->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that we don't get a row if prepareRow() is false.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue