ContentTranslationLocalTasksTest.php 2.33 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\Tests\content_translation\Unit\Menu\ContentTranslationLocalTasksTest.
6 7
 */

8
namespace Drupal\Tests\content_translation\Unit\Menu;
9

10
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
11 12

/**
13
 * Tests content translation local tasks.
14
 *
15
 * @group content_translation
16
 */
17
class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTestBase {
18

19
  protected function setUp() {
20 21 22
    $this->directoryList = array(
      'content_translation' => 'core/modules/content_translation',
      'node' => 'core/modules/node',
23 24 25
    );
    parent::setUp();

26 27 28 29
    $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
    $entity_type->expects($this->any())
      ->method('getLinkTemplate')
      ->will($this->returnValueMap(array(
30
        array('canonical', 'entity.node.canonical'),
31
        array('drupal:content-translation-overview', 'entity.node.content_translation_overview'),
32
      )));
33 34 35
    $content_translation_manager = $this->getMock('Drupal\content_translation\ContentTranslationManagerInterface');
    $content_translation_manager->expects($this->any())
      ->method('getSupportedEntityTypes')
36
      ->will($this->returnValue(array(
37
        'node' => $entity_type,
38
      )));
39
    \Drupal::getContainer()->set('content_translation.manager', $content_translation_manager);
40
    \Drupal::getContainer()->set('string_translation', $this->getStringTranslationStub());
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
  }

  /**
   * Tests the block admin display local tasks.
   *
   * @dataProvider providerTestBlockAdminDisplay
   */
  public function testBlockAdminDisplay($route, $expected) {
    $this->assertLocalTasks($route, $expected);
  }

  /**
   * Provides a list of routes to test.
   */
  public function providerTestBlockAdminDisplay() {
    return array(
57
      array('entity.node.canonical', array(array(
58
        'content_translation.local_tasks:entity.node.content_translation_overview',
59 60 61 62
        'entity.node.canonical',
        'entity.node.edit_form',
        'entity.node.delete_form',
        'entity.node.version_history',
63
      ))),
64 65
      array('entity.node.content_translation_overview', array(array(
        'content_translation.local_tasks:entity.node.content_translation_overview',
66 67 68 69
        'entity.node.canonical',
        'entity.node.edit_form',
        'entity.node.delete_form',
        'entity.node.version_history',
70 71 72 73 74
      ))),
    );
  }

}