assertTrue() and assertFalse() now only accept boolean values, which is fair enough. We need to either alter the assertions to test a boolean value, or better use assertNotEmpty() and assertEmpty() or some other assertions.

21x: Support for asserting against non-boolean values in ::assertTrue is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use a different assert method, for example, ::assertNotEmpty(). See https://www.drupal.org/node/3082086

which appear in the following files:

    9x in SchedulerFieldsDisplayTest::testVerticalTabOrFieldset from Drupal\Tests\scheduler\Functional
    4x in SchedulerApiTest::testHideField from Drupal\Tests\scheduler\Functional
    4x in SchedulerApiTest::testHookPublishUnpublishAction from Drupal\Tests\scheduler\Functional
    2x in SchedulerBasicTest::testPublishingAndUnpublishing from Drupal\Tests\scheduler\Functional
    2x in SchedulerFieldsDisplayTest::testDisabledFields from Drupal\Tests\scheduler\Functional

and

9x: Support for asserting against non-boolean values in ::assertFalse is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use a different assert method, for example, ::assertEmpty(). See https://www.drupal.org/node/3082086

which appear in the following files:

    4x in SchedulerApiTest::testHideField from Drupal\Tests\scheduler\Functional
    2x in SchedulerApiTest::testHookPublishUnpublishAction from Drupal\Tests\scheduler\Functional
    1x in SchedulerFieldsDisplayTest::testVerticalTabOrFieldset from Drupal\Tests\scheduler\Functional
    1x in SchedulerFieldsDisplayTest::testDisabledFields from Drupal\Tests\scheduler\Functional
    1x in SchedulerMetaInformationTest::testMetaInformation from Drupal\Tests\scheduler\Functional

Change Record https://www.drupal.org/node/3082086

Comments

jonathan1055 created an issue. See original summary.

gnanagowthaman sankar’s picture

Hi @jonathan1055,

Here is the patch. Please let me know for any changes.

Thanks & Regards,
Gnanagowthaman sankar

gnanagowthaman sankar’s picture

Status: Active » Needs review
StatusFileSize
new17.3 KB

Patch

Thanks & Regards,
Gnanagowthaman sankar

jonathan1055’s picture

Status: Needs review » Needs work

Thank you for the working on this and for the patch. Good in general but you have actually changed more than is required. You have changed 37 lines overall but there should only be 30 changed lines - 21 for assertNotEmpty() and 9 for assertEmpty(). You have changed the lines which were testing a boolen value $node->isPublished() which is OK. There are 8 of these in yout patch, which should be removed please.

[edit] That might mean that you have missed one other, because 37 - 8 = 29 and there are 30 warnings. The best way to find these is to I think that you have not missed any, one warning in BasicTest is produced twice for the same code line. So only 29 lines need to be fixed.

To prove that the deprecation warnings have been fixed, add a temporary change to drupalci.yml with suppress-deprecations: false and add this to your patch (it wont get committed, it is just for the testing) - See my patch in #3093399-3: Deprecation: add $defaultTheme to BrowserTestBase for an example.

gnanagowthaman sankar’s picture

Status: Needs work » Needs review
StatusFileSize
new3.8 KB
new15.92 KB

Hi @jonathan1055,

You are welcome. I made changes in this patch. Please let me know for any changes.

Thanks & Regards,
Gnanagowthaman sankar

jonathan1055’s picture

Patch looks great. Results show no text "Support for asserting against non-boolean" so this looks good.

It is unfortunate that there is no way (yet) to suppress just one deprecation message in .drupalci.yml, it is either all or none (as far as I am aware). Those other deprecations are from #3093399: Deprecation: add $defaultTheme to BrowserTestBase

I am about to commit that other fix. The you can re-run your patch and it should pass all green.

gnanagowthaman sankar’s picture

Ok sure @jonathan1055

Thanks & Regards,
Gnanagowthaman sankar

jonathan1055’s picture

Thanks for re-testing. Nice to see a green block.

I realised that instead of the multipe nested $this->assertNotEmpty($this->xpath( ... ) it is better to use the single function $assert->ElementExists('xpath', ... ). This is more direct and also clearer to understand.

gnanagowthaman sankar’s picture

ok sure @jonathan1055 let me make changes and let you know.

Thanks & Regards,
Gnanagowthaman sankar

jonathan1055’s picture

I have already made those changes in the patch in #8 so there is nothing more you need to do. Thank you for your work on this.

gnanagowthaman sankar’s picture

ok @jonathan1055, you are welcome.

jonathan1055’s picture

StatusFileSize
new15.43 KB

Here's a patch to try out testing with core 8.6.

gnanagowthaman sankar’s picture

ok @jonathan1055, let me check.

jonathan1055’s picture

Status: Needs review » Fixed

Thank you. Committed and fixed.

Status: Fixed » Closed (fixed)

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

jonathan1055’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new6.09 KB

The RulesActions test contains assertTrue() and assertFalse() using date values. These were missed when fixing the others (no deprecation warning messages were producded at core 8.8 and 8.9). But now that we can run the Rules tests at core 9.0 we get test failures:
Node is not scheduled for publishing. Failed asserting that null is false.
https://www.drupal.org/pift-ci-job/1794635

  • jonathan1055 committed 6f52c30 on 8.x-1.x
    Issue #3097919 by jonathan1055: Replace non-boolean use of assertTrue()...
jonathan1055’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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