diff --git a/core/modules/node/src/Tests/NodeTranslationUITest.php b/core/modules/node/src/Tests/NodeTranslationUITest.php index a0d2b68..59416a3 100644 --- a/core/modules/node/src/Tests/NodeTranslationUITest.php +++ b/core/modules/node/src/Tests/NodeTranslationUITest.php @@ -194,6 +194,9 @@ function testTranslationLinkTheme() { $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); $this->drupalGet('node/' . $article->id() . '/translations'); $this->assertNoRaw('"theme":"seven"', 'Translation uses frontend theme if edit is frontend.'); + + // Assert presence of translation page itself (vs. DisabledBundle below). + $this->assertResponse(200); } /** @@ -205,11 +208,15 @@ public function testDisabledBundle() { $this->drupalCreateContentType(array('type' => $disabledBundle, 'name' => $disabledBundle)); // Create a node for each bundle. - $this->drupalCreateNode(array('type' => $this->bundle)); + $node = $this->drupalCreateNode(array('type' => $this->bundle)); // Make sure that nothing was inserted into the {content_translation} table. $rows = db_query('SELECT * FROM {content_translation}')->fetchAll(); $this->assertEqual(0, count($rows)); + + // Ensure the translation tab is not accessible. + $this->drupalGet('node/' . $node->id() . '/translations'); + $this->assertResponse(403); } /** diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php index 047e574..15ad05d 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -136,15 +136,20 @@ protected function setUp() { ->method('getPropertyInstance') ->will($this->returnValue($typed_data)); - $language = new Language(array('id' => 'en')); + $english = new Language(array('id' => 'en')); + $not_specified = new Language(array('id' => LanguageInterface::LANGCODE_NOT_SPECIFIED)); $this->languageManager = $this->getMock('\Drupal\Core\Language\LanguageManagerInterface'); $this->languageManager->expects($this->any()) ->method('getLanguages') - ->will($this->returnValue(array('en' => $language, LanguageInterface::LANGCODE_NOT_SPECIFIED => new Language(LanguageInterface::LANGCODE_NOT_SPECIFIED)))); + ->will($this->returnValue(array('en' => $english, LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified))); $this->languageManager->expects($this->any()) ->method('getLanguage') ->with('en') - ->will($this->returnValue($language)); + ->will($this->returnValue($english)); + $this->languageManager->expects($this->any()) + ->method('getLanguage') + ->with(LanguageInterface::LANGCODE_NOT_SPECIFIED) + ->will($this->returnValue($not_specified)); $this->fieldTypePluginManager = $this->getMockBuilder('\Drupal\Core\Field\FieldTypePluginManager') ->disableOriginalConstructor() @@ -252,7 +257,7 @@ public function testGetRevisionId() { * @covers ::isTranslatable */ public function testIsTranslatable() { - $this->entityManager->expects($this->at(0)) + $this->entityManager->expects($this->any()) ->method('getBundleInfo') ->with($this->entityTypeId) ->will($this->returnValue(array( @@ -260,11 +265,19 @@ public function testIsTranslatable() { 'translatable' => TRUE, ), ))); - $this->languageManager->expects($this->at(0)) + $this->languageManager->expects($this->any()) ->method('isMultilingual') ->will($this->returnValue(TRUE)); - $this->assertTrue($this->entity->isTranslatable()); + } + + /** + * @covers ::isTranslatable + */ + public function testIsTranslatableForMonolingual() { + $this->languageManager->expects($this->any()) + ->method('isMultilingual') + ->will($this->returnValue(FALSE)); $this->assertFalse($this->entity->isTranslatable()); } @@ -272,7 +285,7 @@ public function testIsTranslatable() { * @covers ::isTranslatable */ public function testIsTranslatableForUndefined() { - $this->entityManager->expects($this->at(0)) + $this->entityManager->expects($this->any()) ->method('getBundleInfo') ->with($this->entityTypeId) ->will($this->returnValue(array(