ContentTranslationSettingsApiTest.php

Same filename in other branches
  1. 9 core/modules/content_translation/tests/src/Kernel/ContentTranslationSettingsApiTest.php
  2. 10 core/modules/content_translation/tests/src/Kernel/ContentTranslationSettingsApiTest.php
  3. 11.x core/modules/content_translation/tests/src/Kernel/ContentTranslationSettingsApiTest.php

Namespace

Drupal\Tests\content_translation\Kernel

File

core/modules/content_translation/tests/src/Kernel/ContentTranslationSettingsApiTest.php

View source
<?php

namespace Drupal\Tests\content_translation\Kernel;

use Drupal\Core\Database\Database;
use Drupal\KernelTests\KernelTestBase;

/**
 * Tests the content translation settings API.
 *
 * @group content_translation
 */
class ContentTranslationSettingsApiTest extends KernelTestBase {
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    public static $modules = [
        'language',
        'content_translation',
        'user',
        'entity_test',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() {
        parent::setUp();
        $this->installEntitySchema('entity_test_mul');
    }
    
    /**
     * Tests that enabling translation via the API triggers schema updates.
     */
    public function testSettingsApi() {
        $this->container
            ->get('content_translation.manager')
            ->setEnabled('entity_test_mul', 'entity_test_mul', TRUE);
        $schema = Database::getConnection()->schema();
        $result = $schema->fieldExists('entity_test_mul_property_data', 'content_translation_source') && $schema->fieldExists('entity_test_mul_property_data', 'content_translation_outdated');
        $this->assertTrue($result, 'Schema updates correctly performed.');
    }

}

Classes

Title Deprecated Summary
ContentTranslationSettingsApiTest Tests the content translation settings API.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.