LanguageConfigOverrideTest.php in Drupal 8
File
core/modules/language/tests/src/Unit/Config/LanguageConfigOverrideTest.php
View source
<?php
namespace Drupal\Tests\language\Unit\Config;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\language\Config\LanguageConfigOverride;
use Drupal\Tests\UnitTestCase;
class LanguageConfigOverrideTest extends UnitTestCase {
protected $configTranslation;
protected $storage;
protected $eventDispatcher;
protected $typedConfig;
protected $cacheTagsInvalidator;
protected function setUp() {
$this->storage = $this
->createMock('Drupal\\Core\\Config\\StorageInterface');
$this->eventDispatcher = $this
->createMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
$this->typedConfig = $this
->createMock('\\Drupal\\Core\\Config\\TypedConfigManagerInterface');
$this->configTranslation = new LanguageConfigOverride('config.test', $this->storage, $this->typedConfig, $this->eventDispatcher);
$this->cacheTagsInvalidator = $this
->createMock('Drupal\\Core\\Cache\\CacheTagsInvalidatorInterface');
$container = new ContainerBuilder();
$container
->set('cache_tags.invalidator', $this->cacheTagsInvalidator);
\Drupal::setContainer($container);
}
public function testSaveNew() {
$this->cacheTagsInvalidator
->expects($this
->once())
->method('invalidateTags')
->with([
'config:config.test',
]);
$this
->assertTrue($this->configTranslation
->isNew());
$this->configTranslation
->save();
}
public function testSaveExisting() {
$this->cacheTagsInvalidator
->expects($this
->once())
->method('invalidateTags')
->with([
'config:config.test',
]);
$this->configTranslation
->initWithData([]);
$this->configTranslation
->save();
}
public function testDelete() {
$this->cacheTagsInvalidator
->expects($this
->once())
->method('invalidateTags')
->with([
'config:config.test',
]);
$this->configTranslation
->initWithData([]);
$this->configTranslation
->delete();
}
}