Skip to content

Commit

Permalink
UHF-8909: Added Kernel test for default language variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
khalima committed Jul 29, 2024
1 parent 36fa7c5 commit 115ce4d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 214 deletions.
2 changes: 1 addition & 1 deletion src/Language/DefaultLanguageResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Resolves default languages and fallbacks.
*/
final class DefaultLanguageResolver implements DefaultLanguageResolverInterface {
final class DefaultLanguageResolver {

/**
* Constructs a new instance.
Expand Down
69 changes: 0 additions & 69 deletions src/Language/DefaultLanguageResolverInterface.php

This file was deleted.

40 changes: 40 additions & 0 deletions tests/src/Kernel/Language/DefaultLanguageVariablesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\helfi_api_base\Kernel\Language;

use Drupal\KernelTests\KernelTestBase;

/**
* Tests helfi_api_base_template_preprocess_default_variables_alter().
*
* @group helfi_api_base
*/
class DefaultLanguageVariablesTest extends KernelTestBase {

/**
* {@inheritdoc}
*/
protected static $modules = [
'helfi_api_base',
];

/**
* Test helfi_api_base_template_preprocess_default_variables_alter().
*/
public function testDefaultLanguageVariables(): void {
// Prepare variables for the page template.
$render_array = [
'#theme' => 'page',
'#content' => ['#markup' => 'Test content'],
];
\Drupal::moduleHandler()->alter('template_preprocess_default_variables', $render_array);
\Drupal::moduleHandler()->invokeAll('preprocess_page', [&$render_array]);

// Check if variables are set correctly.
$this->assertInstanceOf('Drupal\Core\Language\Language', $render_array['language']);
$this->assertNotNull($render_array['alternative_language']);
}

}
144 changes: 0 additions & 144 deletions tests/src/Unit/Language/DefaultLanguageVariablesTest.php

This file was deleted.

0 comments on commit 115ce4d

Please sign in to comment.