Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Tests\path\Kernel;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\content_translation_test\Entity\EntityTestTranslatableUISkip;
|
Chris@0
|
6 use Drupal\KernelTests\KernelTestBase;
|
Chris@0
|
7 use Drupal\language\Entity\ConfigurableLanguage;
|
Chris@0
|
8
|
Chris@0
|
9 /**
|
Chris@0
|
10 * Tests path alias deletion when there is no canonical link template.
|
Chris@0
|
11 *
|
Chris@0
|
12 * @group path
|
Chris@0
|
13 */
|
Chris@0
|
14 class PathNoCanonicalLinkTest extends KernelTestBase {
|
Chris@0
|
15
|
Chris@0
|
16 /**
|
Chris@0
|
17 * Modules to enable.
|
Chris@0
|
18 *
|
Chris@0
|
19 * @var array
|
Chris@0
|
20 */
|
Chris@0
|
21 public static $modules = ['path', 'content_translation_test', 'language', 'entity_test', 'user', 'system'];
|
Chris@0
|
22
|
Chris@0
|
23 protected function setUp() {
|
Chris@0
|
24 parent::setUp();
|
Chris@0
|
25
|
Chris@0
|
26 $this->installEntitySchema('entity_test');
|
Chris@0
|
27 $this->installEntitySchema('entity_test_mul');
|
Chris@0
|
28 \Drupal::service('router.builder')->rebuild();
|
Chris@0
|
29
|
Chris@0
|
30 // Adding german language.
|
Chris@0
|
31 ConfigurableLanguage::create(['id' => 'de'])->save();
|
Chris@0
|
32
|
Chris@0
|
33 $this->config('language.types')->setData([
|
Chris@0
|
34 'configurable' => ['language_interface'],
|
Chris@0
|
35 'negotiation' => ['language_interface' => ['enabled' => ['language-url' => 0]]],
|
Chris@0
|
36 ])->save();
|
Chris@0
|
37 }
|
Chris@0
|
38
|
Chris@0
|
39 /**
|
Chris@0
|
40 * Tests for no canonical link templates.
|
Chris@0
|
41 */
|
Chris@0
|
42 public function testNoCanonicalLinkTemplate() {
|
Chris@0
|
43 $entity_type = EntityTestTranslatableUISkip::create([
|
Chris@0
|
44 'name' => 'name english',
|
Chris@17
|
45 'language' => 'en',
|
Chris@0
|
46 ]);
|
Chris@0
|
47 $entity_type->save();
|
Chris@0
|
48
|
Chris@0
|
49 $entity_type->addTranslation('de', ['name' => 'name german']);
|
Chris@0
|
50 $entity_type->save();
|
Chris@0
|
51 $this->assertEqual(count($entity_type->getTranslationLanguages()), 2);
|
Chris@0
|
52
|
Chris@0
|
53 $entity_type->removeTranslation('de');
|
Chris@0
|
54 $entity_type->save();
|
Chris@0
|
55 $this->assertEqual(count($entity_type->getTranslationLanguages()), 1);
|
Chris@0
|
56 }
|
Chris@0
|
57
|
Chris@0
|
58 }
|