Mercurial > hg > isophonics-drupal-site
comparison core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
54 | 54 |
55 /** | 55 /** |
56 * Ensures that entity URLs in a language have the right language prefix. | 56 * Ensures that entity URLs in a language have the right language prefix. |
57 */ | 57 */ |
58 public function testEntityUrlLanguage() { | 58 public function testEntityUrlLanguage() { |
59 $this->assertTrue(strpos($this->entity->urlInfo()->toString(), '/en/entity_test/' . $this->entity->id()) !== FALSE); | 59 $this->assertTrue(strpos($this->entity->toUrl()->toString(), '/en/entity_test/' . $this->entity->id()) !== FALSE); |
60 $this->assertTrue(strpos($this->entity->getTranslation('es')->urlInfo()->toString(), '/es/entity_test/' . $this->entity->id()) !== FALSE); | 60 $this->assertTrue(strpos($this->entity->getTranslation('es')->toUrl()->toString(), '/es/entity_test/' . $this->entity->id()) !== FALSE); |
61 $this->assertTrue(strpos($this->entity->getTranslation('fr')->urlInfo()->toString(), '/fr/entity_test/' . $this->entity->id()) !== FALSE); | 61 $this->assertTrue(strpos($this->entity->getTranslation('fr')->toUrl()->toString(), '/fr/entity_test/' . $this->entity->id()) !== FALSE); |
62 } | 62 } |
63 | 63 |
64 /** | 64 /** |
65 * Ensures correct entity URLs with the method language-content-entity enabled. | 65 * Ensures correct entity URLs with the method language-content-entity enabled. |
66 * | 66 * |
87 $this->setCurrentRequestForRoute('/entity_test/{entity_test}', 'entity.entity_test.canonical'); | 87 $this->setCurrentRequestForRoute('/entity_test/{entity_test}', 'entity.entity_test.canonical'); |
88 | 88 |
89 // The method language-content-entity should run before language-url and | 89 // The method language-content-entity should run before language-url and |
90 // append query parameter for the content language and prevent language-url | 90 // append query parameter for the content language and prevent language-url |
91 // from overwriting the url. | 91 // from overwriting the url. |
92 $this->assertTrue(strpos($this->entity->urlInfo('canonical')->toString(), '/en/entity_test/' . $this->entity->id() . '?' . LanguageNegotiationContentEntity::QUERY_PARAMETER . '=en') !== FALSE); | 92 $this->assertTrue(strpos($this->entity->toUrl('canonical')->toString(), '/en/entity_test/' . $this->entity->id() . '?' . LanguageNegotiationContentEntity::QUERY_PARAMETER . '=en') !== FALSE); |
93 $this->assertTrue(strpos($this->entity->getTranslation('es')->urlInfo('canonical')->toString(), '/en/entity_test/' . $this->entity->id() . '?' . LanguageNegotiationContentEntity::QUERY_PARAMETER . '=es') !== FALSE); | 93 $this->assertTrue(strpos($this->entity->getTranslation('es')->toUrl('canonical')->toString(), '/en/entity_test/' . $this->entity->id() . '?' . LanguageNegotiationContentEntity::QUERY_PARAMETER . '=es') !== FALSE); |
94 $this->assertTrue(strpos($this->entity->getTranslation('fr')->urlInfo('canonical')->toString(), '/en/entity_test/' . $this->entity->id() . '?' . LanguageNegotiationContentEntity::QUERY_PARAMETER . '=fr') !== FALSE); | 94 $this->assertTrue(strpos($this->entity->getTranslation('fr')->toUrl('canonical')->toString(), '/en/entity_test/' . $this->entity->id() . '?' . LanguageNegotiationContentEntity::QUERY_PARAMETER . '=fr') !== FALSE); |
95 | 95 |
96 // Define the method language-url with a higher priority than | 96 // Define the method language-url with a higher priority than |
97 // language-content-entity. This configuration should match the default one, | 97 // language-content-entity. This configuration should match the default one, |
98 // where the language-content-entity is turned off. | 98 // where the language-content-entity is turned off. |
99 $config->set('negotiation.language_content.enabled', [ | 99 $config->set('negotiation.language_content.enabled', [ |