Skip to content

Commit

Permalink
Merge pull request #288 from localgovdrupal/fix/287-php-phpstan-issues
Browse files Browse the repository at this point in the history
fix: phpstan issues
  • Loading branch information
finnlewis authored Oct 2, 2023
2 parents 2524857 + 4c381bc commit 93f9a15
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Form/AlertBannerEntityForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ public function save(array $form, FormStateInterface $form_state) {
else {
$form_state->setRedirect('entity.localgov_alert_banner.collection', ['localgov_alert_banner' => $entity->id()]);
}

return $status;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function prepareRevertedRevision(AlertBannerEntityInterface $revision,
$revert_untranslated_fields = $form_state->getValue('revert_untranslated_fields');

/** @var \Drupal\localgov_alert_banner\Entity\AlertBannerEntityInterface $default_revision */
$latest_revision = $this->AlertBannerEntityStorage->load($revision->id());
$latest_revision = $this->alertBannerEntityStorage->load($revision->id());
$latest_revision_translation = $latest_revision->getTranslation($this->langcode);

$revision_translation = $revision->getTranslation($this->langcode);
Expand Down
2 changes: 2 additions & 0 deletions src/Form/AlertBannerEntityTypeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public function save(array $form, FormStateInterface $form_state) {
]));
}
$form_state->setRedirectUrl($localgov_alert_banner_type->toUrl('collection'));

return $status;
}

}
2 changes: 1 addition & 1 deletion tests/src/Functional/AlertBannerBlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function placeAlterBlock(array $settings = []) {
$this->adminUser = $this->drupalCreateUser(['administer blocks']);
$this->drupalLogin($this->adminUser);
$block = $this->drupalPlaceBlock('localgov_alert_banner_block', $settings);
$this->drupalLogout($this->adminUser);
$this->drupalLogout();
return $block;
}

Expand Down
9 changes: 8 additions & 1 deletion tests/src/Functional/PermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ class PermissionsTest extends BrowserTestBase {
'user',
];

/**
* A user with the 'administer blocks' permission.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -71,7 +78,7 @@ public function setUp(): void {
$this->adminUser = $this->drupalCreateUser(['administer blocks']);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('localgov_alert_banner_block', []);
$this->drupalLogout($this->adminUser);
$this->drupalLogout();
}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/src/Kernel/AlertBannerBlockOrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function testAlertBannerBlockOrder() {
];

// Set up alert banners.
$alert = [];
foreach ($alert_details as $key => $value) {
$alert_entity = $this->container->get('entity_type.manager')->getStorage('localgov_alert_banner')
->create([
Expand All @@ -90,6 +91,7 @@ public function testAlertBannerBlockOrder() {

// Render the block and get the alert banner IDs as an array.
$render = $plugin_block->build();
$result = [];
foreach ($render as $render_value) {
$result[] = $render_value['#localgov_alert_banner']->id();
}
Expand All @@ -100,6 +102,7 @@ public function testAlertBannerBlockOrder() {
$this->assertEquals($expected, $result);

// More banners - Order should be type then most recent first.
$alert_new = [];
foreach ($alert_details as $key => $value) {
$alert_entity = $this->container->get('entity_type.manager')->getStorage('localgov_alert_banner')
->create([
Expand All @@ -116,6 +119,7 @@ public function testAlertBannerBlockOrder() {
// Create and render the block and get the alert banner IDs as an array.
$plugin_block = $block_manager->createInstance('localgov_alert_banner_block', $config);
$render = $plugin_block->build();
$result_2 = [];
foreach ($render as $render_value) {
$result_2[] = $render_value['#localgov_alert_banner']->id();
}
Expand All @@ -141,6 +145,7 @@ public function testAlertBannerBlockOrder() {
// Create and render the block and get the alert banner IDs as an array.
$plugin_block = $block_manager->createInstance('localgov_alert_banner_block', $config);
$render = $plugin_block->build();
$result_3 = [];
foreach ($render as $render_value) {
$result_3[] = $render_value['#localgov_alert_banner']->id();
}
Expand Down Expand Up @@ -184,6 +189,7 @@ public function testAlertBannerBlockOrderWithoutTypeOfAlert() {
];

// Set up alert banners.
$alert = [];
foreach ($alert_times as $changed) {
$alert_entity = $this->container->get('entity_type.manager')->getStorage('localgov_alert_banner')
->create([
Expand All @@ -201,6 +207,7 @@ public function testAlertBannerBlockOrderWithoutTypeOfAlert() {
$config = [];
$plugin_block = $block_manager->createInstance('localgov_alert_banner_block', $config);
$render = $plugin_block->build();
$result = [];
foreach ($render as $render_value) {
$result[] = $render_value['#localgov_alert_banner']->id();
}
Expand Down

0 comments on commit 93f9a15

Please sign in to comment.