-
Notifications
You must be signed in to change notification settings - Fork 5
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 #814 from City-of-Helsinki/UHF-8670
UHF-8670 Hero image author
- Loading branch information
Showing
12 changed files
with
435 additions
and
4 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
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
3 changes: 3 additions & 0 deletions
3
...agraphs_hero/tests/modules/helfi_paragraphs_hero_test/helfi_paragraphs_hero_test.info.yml
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,3 @@ | ||
name: 'Helfi Paragraphs Hero Test' | ||
core_version_requirement: '^10 || ^11' | ||
type: module |
15 changes: 15 additions & 0 deletions
15
...aragraphs_hero/tests/modules/helfi_paragraphs_hero_test/helfi_paragraphs_hero_test.module
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,15 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains test alter for helfi_paragraphs_hero. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Implements hook_helfi_hero_design_alter(). | ||
*/ | ||
function helfi_paragraphs_hero_test_helfi_hero_design_alter(array &$designs) { | ||
$designs['test-design'] = t('Test design'); | ||
} |
51 changes: 51 additions & 0 deletions
51
modules/helfi_paragraphs_hero/tests/src/Kernel/HeroDesignAllowedValuesAlterTest.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,51 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\helfi_paragraphs_hero\Kernel; | ||
|
||
use Drupal\Core\Entity\FieldableEntityInterface; | ||
use Drupal\Core\Field\FieldStorageDefinitionInterface; | ||
use Drupal\Core\StringTranslation\StringTranslationTrait; | ||
use Drupal\KernelTests\KernelTestBase; | ||
|
||
/** | ||
* Tests allowed values alter for hero design. | ||
* | ||
* @group helfi_paragraphs_hero | ||
*/ | ||
class HeroDesignAllowedValuesAlterTest extends KernelTestBase { | ||
|
||
use StringTranslationTrait; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static $modules = [ | ||
'helfi_paragraphs_hero', | ||
'helfi_paragraphs_hero_test', | ||
'field', | ||
'entity', | ||
'user', | ||
]; | ||
|
||
/** | ||
* Test the hero design allowed values alter. | ||
*/ | ||
public function testHeroDesignAlter() { | ||
// Load the required definition and entity mocks. | ||
$definition = $this->createMock(FieldStorageDefinitionInterface::class); | ||
$entity = $this->createMock(FieldableEntityInterface::class); | ||
|
||
// Call the allowed designs function. | ||
$allowed_designs = helfi_paragraphs_hero_design_allowed_values($definition, $entity); | ||
|
||
// Call the function that triggers the drupal_alter. | ||
helfi_paragraphs_hero_test_helfi_hero_design_alter($allowed_designs); | ||
|
||
// Define the expected outcome after the alter hook. | ||
$expected_designs = $allowed_designs + ['test-design' => $this->t('Test design')]; | ||
|
||
// Assert that the design data has been altered as expected. | ||
$this->assertEquals($expected_designs, $allowed_designs); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
modules/helfi_paragraphs_hero/tests/src/Kernel/HeroDesignAllowedValuesTest.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,53 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\helfi_paragraphs_hero\Kernel; | ||
|
||
use Drupal\Core\Entity\FieldableEntityInterface; | ||
use Drupal\Core\Field\FieldStorageDefinitionInterface; | ||
use Drupal\Core\StringTranslation\StringTranslationTrait; | ||
use Drupal\KernelTests\KernelTestBase; | ||
|
||
/** | ||
* Tests allowed values for hero design. | ||
* | ||
* @group helfi_paragraphs_hero | ||
*/ | ||
class HeroDesignAllowedValuesTest extends KernelTestBase { | ||
|
||
use StringTranslationTrait; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static $modules = [ | ||
'helfi_paragraphs_hero', | ||
'field', | ||
'entity', | ||
'user', | ||
]; | ||
|
||
/** | ||
* Test the hero design allowed values function. | ||
*/ | ||
public function testAllowedValues() { | ||
// Load the required definition and entity mocks. | ||
$definition = $this->createMock(FieldStorageDefinitionInterface::class); | ||
$entity = $this->createMock(FieldableEntityInterface::class); | ||
|
||
// Call the allowed designs function. | ||
$allowed_designs = helfi_paragraphs_hero_design_allowed_values($definition, $entity); | ||
|
||
// Define the expected allowed designs. | ||
$expected_designs = [ | ||
'without-image-left' => $this->t('Without image, align left'), | ||
'with-image-right' => $this->t('Image on the right'), | ||
'with-image-left' => $this->t('Image on the left'), | ||
'with-image-bottom' => $this->t('Image on the bottom'), | ||
'diagonal' => $this->t('Diagonal'), | ||
]; | ||
|
||
// Assert that the allowed values match the expected values. | ||
$this->assertEquals($expected_designs, $allowed_designs); | ||
} | ||
|
||
} |
Oops, something went wrong.