0

Is it possible? I am trying to contribute to a drupal module (first time) and I have uploaded a patch.

But the test keeps failing because of an unmet dependency on the libraries API. I have added the dependency to the $modules static in the simpletest but now I get an error:

fail: [Other] Line 33 of modules/swiftmailer/src/Tests/SwiftMailerSettingsTest.php: Unable to install modules libraries, swiftmailer, block due to missing modules libraries.

I'm getting really frustrated because I can't figure out how to fix it. D8 documentation is just not sufficient...

I would greatly appreciate it if somebody could help me out because I'm about ready to give up.

The issue page I created is here https://www.drupal.org/node/2620822 And this is the test code:

<?php
/**
 * @file
 * Contains \Drupal\swiftmailer\Tests\SwiftMailerSettingsTest.
 */

 namespace Drupal\swiftmailer\Tests;

 use Drupal\simpletest\WebTestBase;

/**
 * Tests the Transport and Message Settings UI.
 *
 * @group swiftmailer
 */
class SwiftMailerSettingsTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'libraries',
    'swiftmailer',
    'block',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
  parent::setUp();
  $this->drupalPlaceBlock('local_tasks_block');
    $this->drupalPlaceBlock('local_actions_block');
  }

  /**
   * Tests the Transport Settings.
   */
  public function testTransportSettings() {
// Unauthorized user should not have access.
$this->drupalGet('admin/config/swiftmailer/transport');
$this->assertResponse(403);

// Login..
$user = $this->createUser(['administer swiftmailer']);
$this->drupalLogin($user);
$this->drupalGet(t('admin/config/swiftmailer/transport'));
$this->assertText(t('Transport types'));

//Select Smtp tranport option.
$this->drupalPostAjaxForm(NULL, [ 'transport[type]' => 'smtp' ], ['transport[type]' => 'smtp']);
$this->drupalPostForm(NULL, [
  'transport[type]' => 'smtp',
  'transport[configuration][smtp][username]' => 'example',
  'transport[configuration][smtp][password]' => 'pass'
], t('Save configuration'));
$this->assertText('using the SMTP transport type.');

//Loading configuration to check if is set up correctly.
$config = $this->config('swiftmailer.transport');
$transport = $config->get('transport');
$user= $config->get('smtp_username');
$password= $config->get('smtp_password');
$this->assertEqual($transport, 'smtp');
$this->assertEqual($user, 'example');
$this->assertEqual($password, 'pass');

//Select Sppol tranport option.
$this->drupalPostAjaxForm(NULL, [ 'transport[type]' => 'spool' ], ['transport[type]' => 'spool']);
$this->drupalPostForm(NULL, [
  'transport[type]' => 'spool',
  'transport[configuration][spool][directory]' => 'aaaaa'
], t('Save configuration'));
$this->assertText('using the Spool transport type.');

//Loading configuration to check if is set up correctly.
$config = $this->config('swiftmailer.transport');
$transport = $config->get('transport');
$directory = $config->get('spool_directory');
$this->assertEqual($transport, 'spool');
$this->assertEqual($directory, 'aaaaa');

//Select Sendmail tranport option.
$this->drupalPostAjaxForm(NULL, [ 'transport[type]' => 'sendmail' ], ['transport[type]' => 'sendmail']);
$this->drupalPostForm(NULL, [
  'transport[type]' => 'sendmail',
  'transport[configuration][sendmail][path]' => 'bbbbb'
    ], t('Save configuration'));
    $this->assertText('using the Sendmail transport type.');

    //Loading configuration to check if is set up correctly.
    $config = $this->config('swiftmailer.transport');
    $transport = $config->get('transport');
    $path = $config->get('sendmail_path');
    $this->assertEqual($transport, 'sendmail');
    $this->assertEqual($path, 'bbbbb');
  }

  public function testMessageSettings() {
    $this->drupalGet('admin/config/swiftmailer/transport');
    $this->assertResponse(403);

    // Login..
    $user = $this->createUser(['administer swiftmailer']);
    $this->drupalLogin($user);
    $this->drupalGet(t('admin/config/swiftmailer/transport'));
    $this->assertText(t('Transport types'));

    $this->clickLink('Messages');
    $this->assertText(t('Message format'));

    $this->drupalPostForm(NULL, [
      'format[type]' => 'text/html',
      'convert[mode]' => 'TRUE',
      'character_set[type]' => 'EUC-CN'
    ], t('Save configuration'));
    $this->assertText('The configuration options have been saved.');

    $config = $this->config('swiftmailer.message');
    $format = $config->get('format');
    $mode = $config->get('convert_mode');
    $character = $config->get('character_set');
    $this->assertEqual($format, 'text/html');
    $this->assertEqual($mode, 'TRUE');
    $this->assertEqual($character, 'EUC-CN');
  }
}`

So things seem to be going wrong during the setup process: i want to enable the contrib module libraries becaues the module depends on that. But that doesn't work.

2
  • Welcome to Drupal Answers! Does the test fail because there aren't library files? Seeing the code would help.
    – avpaderno
    Commented Nov 23, 2015 at 19:59
  • Also, knowing the module or the issue in question sure would help.
    – mona lisa
    Commented Nov 23, 2015 at 21:16

1 Answer 1

1

I don't understand why you need libraries module for swiftmailer?

Swiftmailer dependencies in 8.x-1.x are installed using composer (manager). Which is something that the testbot currently simply does not support.

That said, the generic answer:

Adding the dependency to the test is not enough, it also needs to be specified in the info.yml file as test_dependencies entry. That however only works when already committed. So if you try to do that, you need two patches/issues. First add the dependencies, wait a while until dependencies are rebuilt and then provide the rest of the patch.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.