3e148aaf488c568082caca99e32cca476e0e5ccc
[yaffs-website] / web / core / modules / node / tests / src / Kernel / Migrate / d7 / NodeTranslationRedirectTest.php
1 <?php
2
3 namespace Drupal\Tests\node\Kernel\Migrate\d7;
4
5 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
6 use Symfony\Component\HttpFoundation\Request;
7
8 /**
9  * Tests node translation redirections.
10  *
11  * @group migrate_drupal
12  * @group node
13  */
14 class NodeTranslationRedirectTest extends MigrateDrupal7TestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = [
20     'content_translation',
21     'language',
22     'menu_ui',
23     // Required for translation migrations.
24     'migrate_drupal_multilingual',
25     'node',
26     'text',
27   ];
28
29   /**
30    * {@inheritdoc}
31    */
32   protected function setUp() {
33     parent::setUp();
34
35     $this->installEntitySchema('node');
36     $this->installConfig('node');
37     $this->installSchema('node', ['node_access']);
38     $this->installSchema('system', ['key_value']);
39
40     $this->executeMigrations([
41       'language',
42       'd7_language_types',
43       'd7_language_negotiation_settings',
44       'd7_user_role',
45       'd7_user',
46       'd7_node_type',
47       'd7_node',
48       'd7_node_translation',
49     ]);
50   }
51
52   /**
53    * Tests that not found node translations are redirected.
54    */
55   public function testNodeTranslationRedirect() {
56     $kernel = $this->container->get('http_kernel');
57     $request = Request::create('/node/3');
58     $response = $kernel->handle($request);
59     $this->assertSame(301, $response->getStatusCode());
60     $this->assertSame('/node/2', $response->getTargetUrl());
61   }
62
63 }