3 namespace Drupal\Tests\language\Unit\Config;
5 use Drupal\Core\DependencyInjection\ContainerBuilder;
6 use Drupal\language\Config\LanguageConfigOverride;
7 use Drupal\Tests\UnitTestCase;
10 * @coversDefaultClass \Drupal\language\Config\LanguageConfigOverride
14 class LanguageConfigOverrideTest extends UnitTestCase {
17 * Language configuration override.
19 * @var \Drupal\language\Config\LanguageConfigOverride
21 protected $configTranslation;
26 * @var \Drupal\Core\Config\StorageInterface|\PHPUnit_Framework_MockObject_MockObject
33 * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject
35 protected $eventDispatcher;
40 * @var \Drupal\Core\Config\TypedConfigManagerInterface|\PHPUnit_Framework_MockObject_MockObject
42 protected $typedConfig;
45 * The mocked cache tags invalidator.
47 * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface|\PHPUnit_Framework_MockObject_MockObject
49 protected $cacheTagsInvalidator;
54 protected function setUp() {
55 $this->storage = $this->getMock('Drupal\Core\Config\StorageInterface');
56 $this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
57 $this->typedConfig = $this->getMock('\Drupal\Core\Config\TypedConfigManagerInterface');
58 $this->configTranslation = new LanguageConfigOverride('config.test', $this->storage, $this->typedConfig, $this->eventDispatcher);
59 $this->cacheTagsInvalidator = $this->getMock('Drupal\Core\Cache\CacheTagsInvalidatorInterface');
61 $container = new ContainerBuilder();
62 $container->set('cache_tags.invalidator', $this->cacheTagsInvalidator);
63 \Drupal::setContainer($container);
69 public function testSaveNew() {
70 $this->cacheTagsInvalidator->expects($this->once())
71 ->method('invalidateTags')
72 ->with(['config:config.test']);
73 $this->assertTrue($this->configTranslation->isNew());
74 $this->configTranslation->save();
80 public function testSaveExisting() {
81 $this->cacheTagsInvalidator->expects($this->once())
82 ->method('invalidateTags')
83 ->with(['config:config.test']);
84 $this->configTranslation->initWithData([]);
85 $this->configTranslation->save();
91 public function testDelete() {
92 $this->cacheTagsInvalidator->expects($this->once())
93 ->method('invalidateTags')
94 ->with(['config:config.test']);
95 $this->configTranslation->initWithData([]);
96 $this->configTranslation->delete();