-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from City-of-Helsinki/UHF-8909
UHF-8909: Preprocess refactoring
- Loading branch information
Showing
5 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/src/Kernel/Language/DefaultLanguageVariablesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters