Created on 3 December 2024, 19 days ago

Problem/Motivation

With πŸ“Œ Integration with Gitlab CI Active in place, PHPUnit. There is a report now for the issues we can fix.

There were 2 PHPUnit test runner warnings:
1) Class Drupal\Tests\mask\Kernel\MaskKernelTest declared in /builds/project/mask/tests/src/Kernel/MaskKernelTest.php is abstract
2) Class Drupal\Tests\mask\Unit\MaskUnitTest declared in /builds/project/mask/tests/src/Unit/MaskUnitTest.php is abstract
--
There were 2 failures:
1) Drupal\Tests\mask\Unit\ElementHelperTest::testInfoAlter
Failed asserting that false is true.
/builds/project/mask/tests/src/Unit/ElementHelperTest.php:32
/builds/project/mask/vendor/bin/phpunit:122
2) Drupal\Tests\mask\Unit\FieldWidgetPluginTest::testFieldWidgetFormAlter
Failed asserting that false is true.
/builds/project/mask/tests/src/Unit/FieldWidgetPluginTest.php:65
/builds/project/mask/vendor/bin/phpunit:122
FAILURES!
Tests: 8, Assertions: 18, Failures: 2, Warnings: 2.                                  

Steps to reproduce

See https://git.drupalcode.org/project/mask/-/jobs/3576798

Proposed resolution

-

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

πŸ“Œ Task
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @tim-diels
  • Merge request !20Resolve #3491425 "Fix tests" β†’ (Merged) created by anish.ir
  • Pipeline finished with Failed
    16 days ago
    Total: 141s
    #361036
  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    This should be done for the 2.1.x branch. I know the default was 2.0.x but I don't have the correct right to change. I'll ask the maintainer to change this.

  • Pipeline finished with Failed
    16 days ago
    #361066
  • Hi @tim-diels,

    I have fixed one of the test's error, working on the other one.
    I'm getting warnings that MaskKernelTest and MaskUnitTest are abstract, but they're being used directly. I'm currently extending MaskUnitTest in FieldWidgetPluginTest, (and many more places) which works fine, but the warnings persist.

    Should I:
    1. Ensure these abstract classes are only extended and not instantiated directly (seems most likely)?
    2. Remove the abstract keyword if it's unnecessary?
    Which approach would you recommend to resolve this issue?

    Thanks for your help!

  • Pipeline finished with Failed
    13 days ago
    Total: 174s
    #363004
  • Pipeline finished with Failed
    13 days ago
    Total: 165s
    #363018
  • Pipeline finished with Failed
    11 days ago
    Total: 136s
    #365027
  • Hey,

    I have resolved the issues and warnings stated above, but there is a warning stating that : No tests found in some classes.

    There were 2 PHPUnit test runner warnings:
    1) No tests found in class "Drupal\Tests\mask\Kernel\MaskKernelTest".
    2) No tests found in class "Drupal\Tests\mask\Unit\MaskUnitTest".
    WARNINGS!
    Tests: 8, Assertions: 21, Warnings: 2.

    I think we need to add some tests in these classes.
    Thank you !

  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    The change of just removing the abstract is not correct. Please see https://www.drupal.org/project/drupal/issues/2973127 β†’ for more info on this.
    So I would suggest changing the base tests to include *Base and change the other files extending these base classes.

    • MaskKernelTestBase.php
    • MaskUnitTestBase.php

    And then start from there to fix the tests. So maybe revert the changes or start fresh?
    Because I'm not sure what you changed to get everything working...

  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    Ok the changes done in tests/src/Unit/ElementHelperTest.php seems correct so you can keep those. Very good work!

    Need to review the others.

  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    Other changes are indeed ok. So only the changes for the abstract needs to be looked at. Great work!

  • Pipeline finished with Success
    2 days ago
    Total: 243s
    #374609
  • Hey @tim-diels,

    I have implemented the suggestion you have made, please have a look. There are no pipeline issues and it is fixed too.

    I have refactored the MaskUnitTest by creating a MaskUnitTestBase class for shared setup logic and moved the concrete test cases to MaskUnitTest. This follows the same structure as MaskKernelTest.

    Please let me know if any changes are needed!

  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    Hi @anish.ir, Thanks for the follow up.

    But why are you creating tests that do nothing like the examples? I do understand it shows it works, but is not needed.

    I'm also not getting the extra MaskKernelTest.php that only has the exampled and why LibraryInfoAlterTest.php is extending this instead of the MaskKernelTestBase.php. And the same for MaskUnitTest.php. Can you elaborate on why you did this?

  • Thank you for the feedback!

    The initial tests were placeholders to verify the test setup, I’ll remove the example tests and the MaskKernelTest.php too, and have tests extend MaskKernelTestBase.php directly. I created this as a concrete test class to provide a base for tests, but I now realize it’s redundant.

    I mistakenly had LibraryInfoAlterTest.php extend MaskKernelTest.php. It should extend MaskKernelTestBase.php directly, and I’ll correct this.

    I’ll restructure the tests. Thanks again for pointing this out!

  • Pipeline finished with Success
    2 days ago
    Total: 161s
    #374743
  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    I'm glad you continue to help. For me everything is ok now. Test seems to pass correctly also.
    So thank you for the work here as this is very helpful for the other issues to get accepted or work on!

  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ
Production build 0.71.5 2024