annotate core/modules/locale/tests/src/Unit/LocaleTranslationTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Tests\locale\Unit;
Chris@0 4
Chris@0 5 use Drupal\locale\LocaleTranslation;
Chris@0 6 use Drupal\Tests\UnitTestCase;
Chris@0 7 use Symfony\Component\HttpFoundation\RequestStack;
Chris@0 8
Chris@0 9 /**
Chris@0 10 * @coversDefaultClass \Drupal\locale\LocaleTranslation
Chris@0 11 * @group locale
Chris@0 12 */
Chris@0 13 class LocaleTranslationTest extends UnitTestCase {
Chris@0 14
Chris@0 15 /**
Chris@0 16 * A mocked storage to use when instantiating LocaleTranslation objects.
Chris@0 17 *
Chris@0 18 * @var \PHPUnit_Framework_MockObject_MockObject
Chris@0 19 */
Chris@0 20 protected $storage;
Chris@0 21
Chris@0 22 /**
Chris@0 23 * A mocked language manager built from LanguageManagerInterface.
Chris@0 24 *
Chris@0 25 * @var \Drupal\Core\Language\LanguageManagerInterface|\PHPUnit_Framework_MockObject_MockObject
Chris@0 26 */
Chris@0 27 protected $languageManager;
Chris@0 28
Chris@0 29 /**
Chris@0 30 * The request stack.
Chris@0 31 *
Chris@0 32 * @var \Symfony\Component\HttpFoundation\RequestStack
Chris@0 33 */
Chris@0 34 protected $requestStack;
Chris@0 35
Chris@0 36 /**
Chris@0 37 * {@inheritdoc}
Chris@0 38 */
Chris@0 39 protected function setUp() {
Chris@0 40 $this->storage = $this->getMock('Drupal\locale\StringStorageInterface');
Chris@0 41 $this->cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
Chris@0 42 $this->lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
Chris@0 43 $this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
Chris@0 44 $this->requestStack = new RequestStack();
Chris@0 45 }
Chris@0 46
Chris@0 47 /**
Chris@0 48 * Tests for \Drupal\locale\LocaleTranslation::destruct().
Chris@0 49 */
Chris@0 50 public function testDestruct() {
Chris@0 51 $translation = new LocaleTranslation($this->storage, $this->cache, $this->lock, $this->getConfigFactoryStub(), $this->languageManager, $this->requestStack);
Chris@0 52 // Prove that destruction works without errors when translations are empty.
Chris@0 53 $this->assertAttributeEmpty('translations', $translation);
Chris@0 54 $translation->destruct();
Chris@0 55 }
Chris@0 56
Chris@0 57 }