public function MigrateSourceTest::testCountCacheKey in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\MigrateSourceTest::testCountCacheKey()
Test that the key can be set for the count cache.
@covers ::count
File
- core/
modules/ migrate/ tests/ src/ Unit/ MigrateSourceTest.php, line 206 - Contains \Drupal\Tests\migrate\Unit\MigrateSourceTest.
Class
- MigrateSourceTest
- @coversDefaultClass \Drupal\migrate\Plugin\migrate\source\SourcePluginBase @group migrate
Namespace
Drupal\Tests\migrate\UnitCode
public function testCountCacheKey() {
// Mock the cache to validate set() receives appropriate arguments.
$container = new ContainerBuilder();
$cache = $this
->createMock(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());
}