The unit tests of Ban's Migrate source plugins should be changed to the base class introduced in #2791119: Write meaningful Migrate source tests.

Comments

quietone created an issue. See original summary.

quietone’s picture

quietone’s picture

Status: Active » Needs review
StatusFileSize
new2.25 KB
phenaproxima’s picture

Status: Needs review » Needs work

Looks great! Only two nitpicks...

  1. +++ b/core/modules/ban/tests/src/Kernel/Plugin/migrate/source/d7/BlockedIpsTest.php
    @@ -0,0 +1,42 @@
    +  protected $expectedResults = [
    +    [
    +      'ip' => '127.0.0.1',
    +    ],
    +  ];
    

    I would rather this was moved directly into providerSource().

  2. +++ b/core/modules/ban/tests/src/Kernel/Plugin/migrate/source/d7/BlockedIpsTest.php
    @@ -0,0 +1,42 @@
    +  public function providerSource() {
    +
    +    $databaseContents['blocked_ips'] = [
    

    Nit: Extra blank line here.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.24 KB
new928 bytes

I would rather this was moved directly into providerSource().

Why?

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Consistency. Part of the purpose of having the new base class is to get rid of warts like $expectedResults, which being a protected property implies that there's only one test pass. (In this case there is, but everything should be in the data provider.)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: 2807845-5.patch, failed testing.

phenaproxima’s picture

Status: Needs work » Reviewed & tested by the community

What? No, it didn't.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

See #2807879-14: Convert Contact's Migrate source tests to new base class - let's use better array keys to make it easier to understand what is going on.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB
new855 bytes

OK

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Nice. Back to RTBC.

chipway’s picture

Status: Reviewed & tested by the community » Needs work

May be I am wrong, but I don't see the comparison between $tests[0]['source_data']['blocked_ips'] and $tests[0]['expected_data'] in 2807845-10.patch.
Could you check please?

svendecabooter’s picture

Status: Needs work » Reviewed & tested by the community

I don't see an issue here.
The source & expected data get evaluated by the testSource() method in \Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase.
Which provides the given source data to the \Drupal\ban\Plugin\migrate\source\d7\BlockedIps Plugin, which prepares it into the expected data.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 9baedb6 to 8.3.x and 2f7b4e3 to 8.2.x. Thanks!

  • alexpott committed 9baedb6 on 8.3.x
    Issue #2807845 by quietone: Convert Ban's Migrate source tests to new...
chipway’s picture

Status: Fixed » Needs work

Thanks @svendecabooter for the hint.

chipway’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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