comparison core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
55 */ 55 */
56 public function testTranslatedBreadcrumbs() { 56 public function testTranslatedBreadcrumbs() {
57 // Ensure non-translated breadcrumb is correct. 57 // Ensure non-translated breadcrumb is correct.
58 $breadcrumb = [Url::fromRoute('<front>')->toString() => 'Home']; 58 $breadcrumb = [Url::fromRoute('<front>')->toString() => 'Home'];
59 foreach ($this->terms as $term) { 59 foreach ($this->terms as $term) {
60 $breadcrumb[$term->url()] = $term->label(); 60 $breadcrumb[$term->toUrl()->toString()] = $term->label();
61 } 61 }
62 // The last item will not be in the breadcrumb. 62 // The last item will not be in the breadcrumb.
63 array_pop($breadcrumb); 63 array_pop($breadcrumb);
64 64
65 // Check the breadcrumb on the leaf term page. 65 // Check the breadcrumb on the leaf term page.
66 $term = $this->getLeafTerm(); 66 $term = $this->getLeafTerm();
67 $this->assertBreadcrumb($term->urlInfo(), $breadcrumb, $term->label()); 67 $this->assertBreadcrumb($term->toUrl(), $breadcrumb, $term->label());
68 68
69 $languages = \Drupal::languageManager()->getLanguages(); 69 $languages = \Drupal::languageManager()->getLanguages();
70 70
71 // Construct the expected translated breadcrumb. 71 // Construct the expected translated breadcrumb.
72 $breadcrumb = [Url::fromRoute('<front>', [], ['language' => $languages[$this->translateToLangcode]])->toString() => 'Home']; 72 $breadcrumb = [Url::fromRoute('<front>', [], ['language' => $languages[$this->translateToLangcode]])->toString() => 'Home'];
73 foreach ($this->terms as $term) { 73 foreach ($this->terms as $term) {
74 $translated = $term->getTranslation($this->translateToLangcode); 74 $translated = $term->getTranslation($this->translateToLangcode);
75 $url = $translated->url('canonical', ['language' => $languages[$this->translateToLangcode]]); 75 $url = $translated->toUrl('canonical', ['language' => $languages[$this->translateToLangcode]])->toString();
76 $breadcrumb[$url] = $translated->label(); 76 $breadcrumb[$url] = $translated->label();
77 } 77 }
78 array_pop($breadcrumb); 78 array_pop($breadcrumb);
79 79
80 // Check for the translated breadcrumb on the translated leaf term page. 80 // Check for the translated breadcrumb on the translated leaf term page.
81 $term = $this->getLeafTerm(); 81 $term = $this->getLeafTerm();
82 $translated = $term->getTranslation($this->translateToLangcode); 82 $translated = $term->getTranslation($this->translateToLangcode);
83 $this->assertBreadcrumb($translated->urlInfo('canonical', ['language' => $languages[$this->translateToLangcode]]), $breadcrumb, $translated->label()); 83 $this->assertBreadcrumb($translated->toUrl('canonical', ['language' => $languages[$this->translateToLangcode]]), $breadcrumb, $translated->label());
84 84
85 } 85 }
86 86
87 /** 87 /**
88 * Test translation of terms are showed in the node. 88 * Test translation of terms are showed in the node.