drupal-check simple_block
 8/8 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ -------------------------------------------------------------------- 
  Line   src/Tests/SimpleBlockTest.php                                       
 ------ -------------------------------------------------------------------- 
  12     Class Drupal\simple_block\Tests\SimpleBlockTest extends deprecated  
         class Drupal\simpletest\WebTestBase:                                
         in drupal:8.8.0 and is removed from drupal:9.0.0. Instead,          
         use \Drupal\Tests\BrowserTestBase. See                              
         https://www.drupal.org/node/3030340.                                
 ------ -------------------------------------------------------------------- 

 [ERROR] Found 1 error 

Comments

ravimane23 created an issue. See original summary.

ravimane23’s picture

StatusFileSize
new1.93 KB

With reference of WebTestBase is deprecated created a patch.

ravimane23’s picture

Assigned: ravimane23 » Unassigned
Status: Active » Needs review
luca_loguercio’s picture

StatusFileSize
new1.8 KB

For anyone wanting to apply on top of beta1

devdesagar’s picture

Patch#2 is working for me . Tested on Drupal 8 and Drupal 9

devdesagar’s picture

Status: Needs review » Reviewed & tested by the community
neslee canil pinto’s picture

Status: Reviewed & tested by the community » Needs work

Patch failed to apply

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1843  100  1843    0     0   1169      0  0:00:01  0:00:01 --:--:--  1169
error: patch failed: simple_block.info.yml:3
error: simple_block.info.yml: patch does not apply
error: patch failed: tests/modules/simple_block_test/simple_block_test.info.yml:3
error: tests/modules/simple_block_test/simple_block_test.info.yml: patch does not apply
neslee canil pinto’s picture

StatusFileSize
new3.18 KB

  • Neslee Canil Pinto committed 060b79d on 8.x-1.x
    Issue #3156053 by ravimane23, Neslee Canil Pinto, luca_loguercio: Drupal...
neslee canil pinto’s picture

Status: Needs work » Fixed
claudiu.cristea’s picture

Status: Fixed » Needs review

It may go in a follow-up?

  1. +++ b/src/SimpleBlockEditForm.php
    @@ -68,13 +68,13 @@ class SimpleBlockEditForm extends EntityForm implements ContainerInjectionInterf
    -      drupal_set_message($this->t('Block %id has been added.', ['%id' => $simple_block->id()]));
    +      \Drupal::messenger()->addMessage($this->t('Block %id has been added.', ['%id' => $simple_block->id()]));
    ...
    -      drupal_set_message($this->t('Block %id has been updated.', ['%id' => $simple_block->id()]));
    +      \Drupal::messenger()->addMessage($this->t('Block %id has been updated.', ['%id' => $simple_block->id()]));
    ...
    -      drupal_set_message($this->t('Block %id was not saved.', ['%id' => $simple_block->id()]), 'warning');
    +      \Drupal::messenger()->addMessage($this->t('Block %id was not saved.', ['%id' => $simple_block->id()]), 'warning');
    

    This should use the class method: $this->messenger().

  2. +++ b/tests/src/Functional/SimpleBlockTest.php
    @@ -0,0 +1,46 @@
    +namespace Drupal\Tests\simple_block\Functional;
    ...
    +  protected function setUp() {
    ...
    +  public function testBlockDisplay() {
    

    Let's add strict typing, including the declare() statement, as this is a new class and there's no BC break danger.

  3. +++ b/tests/src/Functional/SimpleBlockTest.php
    @@ -0,0 +1,46 @@
    +  public static $modules = ['simple_block_test', 'simple_block', 'filter'];
    

    s/public/protected

    Also, as simple_block_test has already a dependency on simple_block, we cam omit the later.

neslee canil pinto’s picture

@claudiu.cristea ok i will do the changes as per #11

claudiu.cristea’s picture

@Neslee Canil Pinto any news here?

neslee canil pinto’s picture

Status: Needs review » Needs work
Pooja Ganjage’s picture

StatusFileSize
new2.77 KB

Hi,

Creating a patch for this issue.

Please review the patch.

Let me know if any suggestions.

Thanks.

Pooja Ganjage’s picture

Status: Needs work » Needs review
claudiu.cristea’s picture

Status: Needs review » Needs work
+++ b/src/SimpleBlockEditForm.php
@@ -16,6 +18,32 @@ class SimpleBlockEditForm extends EntityForm implements ContainerInjectionInterf
+  protected $messenger;
...
+  public function __construct(MessengerInterface $messenger) {
+    $this->messenger = $messenger;
+  }

@@ -68,13 +96,13 @@ class SimpleBlockEditForm extends EntityForm implements ContainerInjectionInterf
+      $this->messenger->addMessage($this->t('Block %id has been added.', ['%id' => $simple_block->id()]));
...
+      $this->messenger->addMessage($this->t('Block %id has been updated.', ['%id' => $simple_block->id()]));
...
+      $this->messenger->addMessage($this->t('Block %id was not saved.', ['%id' => $simple_block->id()]), 'warning');

--- a/tests/src/Functional/SimpleBlockTest.php
+++ b/tests/src/Functional/SimpleBlockTest.php

The parent class is already exposing the ->messenger() method, so we don't need to inject again this service.

Pooja Ganjage’s picture

StatusFileSize
new1.73 KB

Hi,

Creating a patch for this issue as suggested in #16 patch.

Please review the patch.

Thanks.

Pooja Ganjage’s picture

Status: Needs work » Needs review
neslee canil pinto’s picture

Status: Needs review » Reviewed & tested by the community
claudiu.cristea’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/src/SimpleBlockEditForm.php
@@ -68,13 +68,13 @@ class SimpleBlockEditForm extends EntityForm implements ContainerInjectionInterf
+      $this->messenger->addMessage($this->t('Block %id has been added.', ['%id' => $simple_block->id()]));
...
+      $this->messenger->addMessage($this->t('Block %id has been updated.', ['%id' => $simple_block->id()]));
...
+      $this->messenger->addMessage($this->t('Block %id was not saved.', ['%id' => $simple_block->id()]), 'warning');

@Neslee Canil Pinto, How can you RTBC without testing?

As I've mentioned in #17, We should use the method $this->messenger() not the property. With the patch from #18, you'll get:

Error: Call to a member function addMessage() on null in Drupal\simple_block\SimpleBlockEditForm->save()
claudiu.cristea’s picture

Also, @Pooja Ganjage, please provide an interdiff for each change you make. Otherwise is difficut for reviewer to understand your changes. Alternatively, you can create a merge request, then each change can be reviewed as separate commit.

Pooja Ganjage’s picture

StatusFileSize
new1.7 KB
new1.06 KB

Hi,

Attached updated patch with interdiff.

Please review once.

Thanks.

Pooja Ganjage’s picture

Status: Needs work » Needs review
claudiu.cristea’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

It seems another change which hasn't been manually tested. Now, I really think we should provide a functional test to prove that everything works.

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new5.54 KB
new5.68 KB

Fixed ^^^ issues.

  • claudiu.cristea committed d8cec8c on 8.x-1.x
    Issue #3156053 by Pooja Ganjage, claudiu.cristea, Neslee Canil Pinto,...
claudiu.cristea’s picture

Status: Needs review » Fixed

Thanks all. Fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.