Loading core/modules/migrate/tests/src/Unit/MigrateSourceTest.php +16 −17 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ protected function getSource($configuration = [], $migrate_config = [], $status ->willReturn($key_value); $container->set('keyvalue', $key_value_factory); $container->set('cache.migrate', $this->createMock(CacheBackendInterface::class)); $container->set('cache.migrate', $this->createStub(CacheBackendInterface::class)); $this->migrationConfiguration = $this->defaultMigrationConfiguration + $migrate_config; $this->migration = parent::getMigration(); Loading Loading @@ -170,20 +170,20 @@ public function testHighwaterTrackChangesIncompatible(): void { * Tests that the source count is correct. */ public function testCount(): void { // Mock the cache to validate set() receives appropriate arguments. $container = new ContainerBuilder(); $cache = $this->createMock(CacheBackendInterface::class); $cache->expects($this->any())->method('set') ->with($this->isString(), $this->isInt(), $this->isInt()); $container->set('cache.migrate', $cache); \Drupal::setContainer($container); // Test that the basic count works. $source = $this->getSource(); $this->assertEquals(1, $source->count()); // Test caching the count works. $source = $this->getSource(['cache_counts' => TRUE]); // Override the stubbed cache service to validate that set() receives // appropriate arguments. $cache = $this->createMock(CacheBackendInterface::class); $cache->expects($this->once()) ->method('set') ->with($this->isString(), $this->isInt(), $this->isInt()); \Drupal::getContainer()->set('cache.migrate', $cache); $this->assertEquals(1, $source->count()); // Test the skip argument. Loading @@ -206,16 +206,15 @@ public function testCount(): void { * Tests that the key can be set for the count cache. */ public function testCountCacheKey(): void { // 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->isInt(), $this->isInt()); $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']); // Override the stubbed cache service to validate that set() receives // appropriate arguments. $cache = $this->createMock(CacheBackendInterface::class); $cache->expects($this->once()) ->method('set') ->with('test_key', $this->isInt(), $this->isInt()); \Drupal::getContainer()->set('cache.migrate', $cache); $this->assertEquals(1, $source->count()); } Loading Loading
core/modules/migrate/tests/src/Unit/MigrateSourceTest.php +16 −17 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ protected function getSource($configuration = [], $migrate_config = [], $status ->willReturn($key_value); $container->set('keyvalue', $key_value_factory); $container->set('cache.migrate', $this->createMock(CacheBackendInterface::class)); $container->set('cache.migrate', $this->createStub(CacheBackendInterface::class)); $this->migrationConfiguration = $this->defaultMigrationConfiguration + $migrate_config; $this->migration = parent::getMigration(); Loading Loading @@ -170,20 +170,20 @@ public function testHighwaterTrackChangesIncompatible(): void { * Tests that the source count is correct. */ public function testCount(): void { // Mock the cache to validate set() receives appropriate arguments. $container = new ContainerBuilder(); $cache = $this->createMock(CacheBackendInterface::class); $cache->expects($this->any())->method('set') ->with($this->isString(), $this->isInt(), $this->isInt()); $container->set('cache.migrate', $cache); \Drupal::setContainer($container); // Test that the basic count works. $source = $this->getSource(); $this->assertEquals(1, $source->count()); // Test caching the count works. $source = $this->getSource(['cache_counts' => TRUE]); // Override the stubbed cache service to validate that set() receives // appropriate arguments. $cache = $this->createMock(CacheBackendInterface::class); $cache->expects($this->once()) ->method('set') ->with($this->isString(), $this->isInt(), $this->isInt()); \Drupal::getContainer()->set('cache.migrate', $cache); $this->assertEquals(1, $source->count()); // Test the skip argument. Loading @@ -206,16 +206,15 @@ public function testCount(): void { * Tests that the key can be set for the count cache. */ public function testCountCacheKey(): void { // 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->isInt(), $this->isInt()); $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']); // Override the stubbed cache service to validate that set() receives // appropriate arguments. $cache = $this->createMock(CacheBackendInterface::class); $cache->expects($this->once()) ->method('set') ->with('test_key', $this->isInt(), $this->isInt()); \Drupal::getContainer()->set('cache.migrate', $cache); $this->assertEquals(1, $source->count()); } Loading