Problem/Motivation

The simplenews demo module is not being tested (and simply adding it as a module seems broken).

Proposed resolution

Add test for the demo module.

Remaining tasks

Doing it.

User interface changes

None

API changes

None

Comments

LKS90’s picture

Status: Active » Needs review
StatusFileSize
new6.74 KB

Here is a patch which adds a separate test class to enable the demo module (and test it). The testing part isn't really finished yet. Things that are done in simplenews_demo.install can't really be verified (I don't know where else to look). Setting the from-name and address is the only thing the test asserts.

Status: Needs review » Needs work

The last submitted patch, 1: demoModule_2495125_1.patch, failed testing.

LKS90’s picture

Status: Needs work » Needs review
StatusFileSize
new6.75 KB

Copy&pasteed the test but missed one instance of tmgmt_demo.
New patch.

Status: Needs review » Needs work

The last submitted patch, 3: demoModule_2495125_2.patch, failed testing.

Status: Needs work » Needs review

LKS90 queued 3: demoModule_2495125_2.patch for re-testing.

LKS90’s picture

StatusFileSize
new7.44 KB
new2.6 KB

Latest patch, now also testing the settings set by the demo module, the newsletters added and sent by it and the subscribers the demo module adds.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/config/schema/simplenews.schema.yml
    @@ -232,6 +232,16 @@ field.value.simplenews_subscription:
       mapping:
    +    cache:
    +      type: mapping
    +      label: Cache
    +      mapping:
    +        max-age:
    +          type: integer
    +          label: Maximum Age
    +        contexts:
    +          type: sequence
    +          label: Contexts
         newsletters:
    

    At least the contexts setting no longer exists and should be removed.

  2. +++ b/modules/simplenews_demo/config/install/block.block.simplenewssubscription.yml
    @@ -3,8 +3,8 @@ status: true
     dependencies:
       module:
         - simplenews
    -  theme:
    -    - bartik
    +#  theme:
    +#    - bartik
     id: simplenewssubscription
    

    This is obviously not a proper fix. But it shows the problem, we can't realy on this being available in the test. Except if we make it so.

    I think we should move this into _install() and set the theme dynamically to the current default theme which you can get from system.theme:default config.

    It also means that we need to check that those blocks exists, because this change means that they don't I think.

  3. +++ b/modules/simplenews_demo/src/Tests/SimplenewsDemoTest.php
    @@ -0,0 +1,63 @@
    +  protected function testInstalled() {
    +    $this->drupalGet('/admin/config/services/simplenews');
    

    no leading / in drupalGet(). More below.

  4. +++ b/modules/simplenews_demo/src/Tests/SimplenewsDemoTest.php
    @@ -0,0 +1,63 @@
    +    $this->drupalGet('/admin/content/simplenews');
    +    $this->assertRaw(t('Newsletter issue sent to 2 subscribers.'));
    +    $this->assertRaw(t('Newsletter issue is pending, mails sent out of 3.'));
    +    $this->assertRaw(t('Newsletter issue is pending, mails sent out of 1.'));
    

    We should also assert on the node titles I think.

    This text actually looks brong, there should be a number there (X sent out of 3)

  5. +++ b/src/Tests/SimplenewsTestSubscriptionOutput.php
    @@ -15,6 +15,13 @@ namespace Drupal\simplenews\Tests;
    +   * Modules to enable.
    +   *
    +   * @var string[]
    +   */
    +  public static $modules = array('simplenews', 'simplenews_scheduler', 'simplenews_demo');
    +
    

    Should be reverted.

LKS90’s picture

Status: Needs work » Needs review
StatusFileSize
new10.1 KB
new8.76 KB

All the feedback should be implemented in this patch. I also fixed the sent_count issue you noticed in 4. and ammended the adminTest so it still passes. All tests should pass.

miro_dietiker’s picture

Status: Needs review » Needs work

There are parts in this patch that are not related to this issue.

As a followup: The demo module still lacks a general intro node (sticky) with some links / references to relevant parts in the application. Example: collect_demo

LKS90’s picture

Status: Needs work » Needs review
StatusFileSize
new6.88 KB
new4.71 KB

Removed the unrelated changes (and directed them to Sebastian who was working on the issue but couldn't reproduce).

This should be a clean patch.

miro_dietiker’s picture

Status: Needs review » Fixed

Yeah. Committed.

Please create a followup about this bartik dependency problem.

sasanikolic’s picture

@LKS90 - Please, it would be great if you could paste the link to the followup issues next time.

berdir’s picture

Title: Add simplenews_demo test to module. » Tests broken: Add simplenews_demo test to module.
Priority: Normal » Critical
Status: Fixed » Needs work
  1. +++ b/modules/simplenews_demo/src/Tests/SimplenewsDemoTest.php
    @@ -0,0 +1,73 @@
    +namespace Drupal\simplenews_demo\Tests;
    +
    +use Drupal\search_api\Tests\WebTestBase;
    +
    +/**
    + * Tests the demo module for Simplenews.
    + *
    + * @group simplenews
    + */
    +class SimplenewsDemoTest extends WebTestBase {
    

    Why on earth is this extending from WebTestBase in search_api and how were the tests here green?

    Testbot is completely broken right now..

  2. +++ b/modules/simplenews_demo/src/Tests/SimplenewsDemoTest.php
    @@ -0,0 +1,73 @@
    +    // Install bartik theme.
    +    \Drupal::service('theme_handler')->install(array('bartik'));
    +    $theme_settings = $this->config('system.theme');
    +    $theme_settings->set('default', 'bartik')->save();
    +    // Log in with all relevant permissions.
    +    $this->drupalLogin($this->drupalCreateUser(['administer simplenews subscriptions', 'send newsletter', 'administer newsletters', 'administer simplenews settings']));
    

    If you enable bartik and then manually install simplenews_demo then the dependency stuff should be working fine...

Re-opening this, we should either fix this asap or revert.

LKS90’s picture

Status: Needs work » Needs review
StatusFileSize
new7.22 KB

New patch, the WebTestBase is the simpletest one now, I added tests for the two blocks.

I now manually install the theme and then the module, but that doesn't change anything for the test ()

Edit: Re-add the dependency on bartik in the block config?

berdir’s picture

Status: Needs review » Needs work

The previous patch has not been reverted, you need to do a diff against that, this won't apply.

LKS90’s picture

Status: Needs work » Needs review
StatusFileSize
new1.88 KB

Rebased version!

Status: Needs review » Needs work

The last submitted patch, 17: tests_broken_add-2495125-17.patch, failed testing.

berdir’s picture

Title: Tests broken: Add simplenews_demo test to module. » Add simplenews_demo test to module.
Priority: Critical » Normal
Status: Needs work » Fixed

Committed.

  • Berdir committed 5ed0db8 on 8.x-1.x authored by LKS90
    Issue #2495125 by LKS90: Tests broken: Add simplenews_demo test to...

The last submitted patch, 15: tests_broken_add-2495125-15.patch, failed testing.

Status: Fixed » Closed (fixed)

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