The abstract Drupal\serialization\Normalizer\NormalizerBase class only contains a supportsNormalization() method. This is a simple method with simple logic, but nonetheless, it should be unit tested. Especially as pretty much all normalizers rely on this logic in some way.

Comments

dawehner’s picture

  1. +++ b/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/NormalizerBaseTest.php
    @@ -0,0 +1,76 @@
    +
    ...
    + *
    + * @group Serialization
    

    Same as before :(

  2. +++ b/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/NormalizerBaseTest.php
    @@ -0,0 +1,76 @@
    +    $this->assertFalse($normalizer_base->supportsNormalization(new \stdClass()));
    ...
    +  public function testSupportsNormalization() {
    

    What about using a dataProvider here?

  3. +++ b/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/NormalizerBaseTest.php
    @@ -0,0 +1,76 @@
    +abstract class TestNormalizerBase extends NormalizerBase {
    

    Can't we just use a non abstract test class and use a proper new in the test?

damiankloip’s picture

StatusFileSize
new4.18 KB
new3.44 KB

Thanks once again! Converted to data provider.

As discussed, I don't think it's better to not have an abstract class, as we then have to stub the normalize() method ourselves too. Let's use some of these cool PHPUnit features :)

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you here as well!

xjm’s picture

2: 2159737-2.patch queued for re-testing.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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