88cc2ade7bd03c61a6101286ef03884bf8c8656b
[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     'node',
24     'text',
25   ];
26
27   /**
28    * {@inheritdoc}
29    */
30   protected function setUp() {
31     parent::setUp();
32
33     $this->installEntitySchema('node');
34     $this->installConfig('node');
35     $this->installSchema('node', ['node_access']);
36     $this->installSchema('system', ['key_value']);
37
38     $this->executeMigrations([
39       'language',
40       'd7_language_types',
41       'd7_language_negotiation_settings',
42       'd7_user_role',
43       'd7_user',
44       'd7_node_type',
45       'd7_node',
46       'd7_node_translation',
47     ]);
48   }
49
50   /**
51    * Tests that not found node translations are redirected.
52    */
53   public function testNodeTranslationRedirect() {
54     $kernel = $this->container->get('http_kernel');
55     $request = Request::create('/node/3');
56     $response = $kernel->handle($request);
57     $this->assertSame(301, $response->getStatusCode());
58     $this->assertSame('/node/2', $response->getTargetUrl());
59   }
60
61 }