Comments

AdamPS created an issue. See original summary.

adamps’s picture

Status: Active » Needs review
StatusFileSize
new4.78 KB

Status: Needs review » Needs work

The last submitted patch, 2: simplenews.tests_.3062352-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

adamps’s picture

Status: Needs work » Needs review
StatusFileSize
new5.93 KB
new4.44 KB
adamps’s picture

Issue tags: +Plan to commit
jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community

Looks good Adam, the coverage seems fine.

It took me a little work to figure out how exactly the logic flowed, the following are just some unimportant notes on what might have helped me get it quicker.

  1. +++ b/src/Tests/SimplenewsRecipientHandlerTest.php
    @@ -0,0 +1,146 @@
    +    // Mark users 4&5 as logged in.
    ...
    +    $this->assertText(t('Send newsletter issue to 3 subscribers.'));
    

    The number of users found is not the number the comment leads us to expect.

  2. +++ b/src/Tests/SimplenewsRecipientHandlerTest.php
    @@ -0,0 +1,146 @@
    +    foreach (array_slice($users, -2) as $user) {
    ...
    +    $this->checkRecipients(array_keys(array_slice($users, 0, 3)));
    

    It took me a while to figure out what was going on in these 2 different slices; it seems fine, albeit could be more explicit.

  3. +++ b/src/Tests/SimplenewsRecipientHandlerTest.php
    @@ -0,0 +1,146 @@
    +    $this->checkRecipients(array_keys(array_slice($users, 2, 2)));
    

    There's a lot going on in this line.

    It would be easier to understand if you moved the slicing to higher up in the function where you first worked on the users.

    The significance of array_keys here is not obvious.

    Something like:

    $recipients  = array_slice($users, 2, 2);
    ...
    //Fill in the forms etc.
    ...
    $recipientEmails = array_keys($recipients);
    $this->checkRecipients($recipientEmails);
    
adamps’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new5.97 KB
new2.27 KB
jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community

makes sense

adamps’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Plan to commit

  • AdamPS committed d1ccbbd on 8.x-2.x
    Issue #3062352 by AdamPS, jonathanshaw: Add tests for RecipientHandler
    

Status: Fixed » Closed (fixed)

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