diff --git a/inmail.links.action.yml b/inmail.links.action.yml index 255b82b..d696b4e 100644 --- a/inmail.links.action.yml +++ b/inmail.links.action.yml @@ -1,5 +1,5 @@ inmail.deliverer_add: route_name: inmail.deliverer_add - title: 'Configure new deliverer' + title: 'Add deliverer' appears_on: - 'inmail.deliverer_list' diff --git a/inmail.module b/inmail.module index b2d76a8..c5dda41 100644 --- a/inmail.module +++ b/inmail.module @@ -279,6 +279,7 @@ function inmail_cron() { $processor = \Drupal::service('inmail.processor'); // Fetch and process new mail. + // @todo Test cron deliverer invocation. foreach ($deliverers as $deliverer) { /** @var \Drupal\inmail\Plugin\inmail\Deliverer\DelivererInterface $plugin */ $plugin = $deliverer_manager->createInstance($deliverer->id(), $deliverer->getConfiguration()); diff --git a/inmail.routing.yml b/inmail.routing.yml index aa9de00..72f34e3 100644 --- a/inmail.routing.yml +++ b/inmail.routing.yml @@ -78,7 +78,7 @@ inmail.deliverer_add: path: admin/config/system/inmail/deliverers/add defaults: _entity_form: 'inmail_deliverer.add' - _title: 'Configure new deliverer' + _title: 'Add deliverer' requirements: _permission: 'administer inmail' diff --git a/src/DelivererListBuilder.php b/src/DelivererListBuilder.php index c01b317..68cb399 100644 --- a/src/DelivererListBuilder.php +++ b/src/DelivererListBuilder.php @@ -77,6 +77,7 @@ class DelivererListBuilder extends ConfigEntityListBuilder { * {@inheritdoc} */ public function getDefaultOperations(EntityInterface $entity) { + // @todo Enable deleting deliverers. $operations = parent::getDefaultOperations($entity); $operations['edit']['title'] = $this->t('Configure'); return $operations; diff --git a/src/Tests/InmailWebTest.php b/src/Tests/InmailWebTest.php index 931f675..00b9996 100644 --- a/src/Tests/InmailWebTest.php +++ b/src/Tests/InmailWebTest.php @@ -27,7 +27,7 @@ class InmailWebTest extends WebTestBase { /** * Tests the admin UI. */ - public function testAdminUI() { + public function testAdminUi() { // Create a test user and log in. $user = $this->drupalCreateUser(array( 'access administration pages', @@ -53,11 +53,30 @@ class InmailWebTest extends WebTestBase { $this->drupalPostForm(NULL, ['return_path' => ''], 'Save configuration'); $this->assertText('The configuration options have been saved.'); + // Check other parts of UI. Saving some time by not implementing them as + // proper test methods. + $this->doTestDelivererUi(); + $this->doTestAnalyzerUi(); + $this->doTestHandlerUi(); + } + + /** + * Tests the listing and configuration form of deliverers. + * + * @see \Drupal\inmail\DelivererListBuilder + * @see \Drupal\inmail\Form\DelivererConfigurationForm + * @see \Drupal\inmail\Plugin\inmail\Fetcher\ImapFetcher + */ + protected function doTestDelivererUi() { // Check Deliverer list. $this->clickLink('Mail deliverers'); + $this->assertUrl('admin/config/system/inmail/deliverers'); $this->assertText('There is no Mail deliverer yet.'); - $this->clickLink('Configure new deliverer'); + // Add an IMAP deliverer. + $this->clickLink('Add deliverer'); + $this->assertUrl('admin/config/system/inmail/deliverers/add'); + // Select the IMAP plugin. $edit = array( 'label' => 'Test IMAP Deliverer', 'id' => 'test_imap', @@ -70,14 +89,31 @@ class InmailWebTest extends WebTestBase { 'password' => 'pass', ); $this->drupalPostForm(NULL, $edit, 'Save'); + $this->assertUrl('admin/config/system/inmail/deliverers'); $this->assertText('Test IMAP Deliverer'); - $this->assertLink('Configure'); + // Status operations and configuration link should be present. $this->clickLink('Disable'); $this->clickLink('Enable'); + $this->clickLink('Configure'); + $this->assertUrl('admin/config/system/inmail/deliverers/test_imap'); + $this->drupalPostForm(NULL, array(), 'Save'); + $this->assertUrl('admin/config/system/inmail/deliverers'); + } + /** + * Tests the listing and configuration form of analyzers. + * + * @see \Drupal\inmail\AnalyzerListBuilder + * @see \Drupal\inmail\Form\AnalyzerConfigurationForm + * @see \Drupal\inmail\Plugin\inmail\Analyzer\StandardDSNAnalyzer + * @see \Drupal\inmail\Plugin\inmail\Analyzer\StandardDSNReasonAnalyzer + * @see \Drupal\inmail\Plugin\inmail\Analyzer\VERPAnalyzer + */ + protected function doTestAnalyzerUi() { // Check Analyzer list. $this->clickLink('Message analyzers'); + $this->assertUrl('admin/config/system/inmail/analyzers'); $this->assertText('Standard DSN Analyzer'); $this->assertText('Standard bounce analyzer'); $this->assertText('Standard DSN Reason Analyzer'); @@ -85,14 +121,18 @@ class InmailWebTest extends WebTestBase { $this->assertText('VERP Analyzer'); $this->assertText('VERP address verification'); + // Status operations should be present. $this->assertNoLink('Enable'); $this->clickLink('Disable'); $this->clickLink('Enable'); + // The analyzers should be ordered according to default config. $this->assertFieldByXPath('//table[@id="edit-entities"]/tbody/tr[1]/td/text()', 'VERP Analyzer'); $this->assertFieldByXPath('//table[@id="edit-entities"]/tbody/tr[2]/td/text()', 'Standard DSN Analyzer'); $this->assertFieldByXPath('//table[@id="edit-entities"]/tbody/tr[3]/td/text()', 'Standard DSN Reason Analyzer'); + // Configs referring to missing plugins should not cause errors, but show a + // message. AnalyzerConfig::create(array( 'id' => 'unicorn', 'plugin_id' => 'unicorn', @@ -100,17 +140,31 @@ class InmailWebTest extends WebTestBase { ))->save(); $this->drupalGet('admin/config/system/inmail/analyzers'); $this->assertText('Unicorn'); + // @todo Improve style for "broken" plugin https://www.drupal.org/node/2379777 $this->assertText('Plugin missing'); + } + /** + * Tests the listing and configuration form of handlers. + * + * @see \Drupal\inmail\HandlerListBuilder + * @see \Drupal\inmail\Form\HandlerConfigurationForm + * @see \Drupal\inmail\Plugin\inmail\Handler\ModeratorForwardHandler + */ + protected function doTestHandlerUi() { // Check Handler list and fallback plugin. $this->clickLink('Message handlers'); + $this->assertUrl('admin/config/system/inmail/handlers'); $this->assertText('Forward unclassified bounces'); + // Status operations should be present. $this->assertNoLink('Enable'); $this->clickLink('Disable'); $this->assertNoLink('Disable'); $this->assertLink('Enable'); + // Configs referring to missing plugins should not cause errors, but show a + // message. HandlerConfig::create(array( 'id' => 'unicorn', 'plugin_id' => 'unicorn', @@ -118,11 +172,14 @@ class InmailWebTest extends WebTestBase { ))->save(); $this->drupalGet('admin/config/system/inmail/handlers'); $this->assertText('Unicorn'); + // @todo Improve style for "broken" plugin https://www.drupal.org/node/2379777 $this->assertText('Plugin missing'); // Configure a handler. $this->clickLink('Configure'); + $this->assertUrl('admin/config/system/inmail/handlers/moderator_forward'); $this->drupalPostForm(NULL, ['moderator' => 'moderator@example.com'], 'Save'); + $this->assertUrl('admin/config/system/inmail/handlers'); $this->clickLink('Configure'); $this->assertFieldByName('moderator', 'moderator@example.com'); }