Issue #2737805 by klausi, larowlan: Convert web tests to browser tests for forum module
parent
91987586b8
commit
57432ad421
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\forum\Tests;
|
||||
namespace Drupal\Tests\forum\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the forum blocks.
|
||||
*
|
||||
* @group forum
|
||||
*/
|
||||
class ForumBlockTest extends WebTestBase {
|
||||
class ForumBlockTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\forum\Tests;
|
||||
namespace Drupal\Tests\forum\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the forum index listing.
|
||||
*
|
||||
* @group forum
|
||||
*/
|
||||
class ForumIndexTest extends WebTestBase {
|
||||
class ForumIndexTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\forum\Tests;
|
||||
namespace Drupal\Tests\forum\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests forum block view for private node access.
|
||||
*
|
||||
* @group forum
|
||||
*/
|
||||
class ForumNodeAccessTest extends WebTestBase {
|
||||
class ForumNodeAccessTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\forum\Tests;
|
||||
namespace Drupal\Tests\forum\Functional;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests for forum.module.
|
||||
|
@ -18,7 +18,7 @@ use Drupal\taxonomy\Entity\Vocabulary;
|
|||
*
|
||||
* @group forum
|
||||
*/
|
||||
class ForumTest extends WebTestBase {
|
||||
class ForumTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -193,21 +193,21 @@ class ForumTest extends WebTestBase {
|
|||
// Topics cell contains number of topics and number of unread topics.
|
||||
$xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="forum__topics"]', $forum_arg);
|
||||
$topics = $this->xpath($xpath);
|
||||
$topics = trim($topics[0]);
|
||||
$this->assertEqual($topics, '6', 'Number of topics found.');
|
||||
$topics = trim($topics[0]->getText());
|
||||
// The extracted text contains the number of topics (6) and new posts
|
||||
// (also 6) in this table cell.
|
||||
$this->assertEquals('6 6 new posts in forum ' . $this->forum['name'], $topics, 'Number of topics found.');
|
||||
|
||||
// Verify the number of unread topics.
|
||||
$unread_topics = $this->container->get('forum_manager')->unreadTopics($this->forum['tid'], $this->editAnyTopicsUser->id());
|
||||
$unread_topics = \Drupal::translation()->formatPlural($unread_topics, '1 new post', '@count new posts');
|
||||
$xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="forum__topics"]//a', $forum_arg);
|
||||
$this->assertFieldByXPath($xpath, $unread_topics, 'Number of unread topics found.');
|
||||
$elements = $this->xpath('//tr[@id=:forum]//td[@class="forum__topics"]//a', $forum_arg);
|
||||
$this->assertStringStartsWith('6 new posts', $elements[0]->getText(), 'Number of unread topics found.');
|
||||
// Verify that the forum name is in the unread topics text.
|
||||
$xpath = $this->buildXPathQuery('//tr[@id=:forum]//em[@class="placeholder"]', $forum_arg);
|
||||
$this->assertFieldByXpath($xpath, $this->forum['name'], 'Forum name found in unread topics text.');
|
||||
$elements = $this->xpath('//tr[@id=:forum]//em[@class="placeholder"]', $forum_arg);
|
||||
$this->assertContains($this->forum['name'], $elements[0]->getText(), 'Forum name found in unread topics text.');
|
||||
|
||||
// Verify total number of posts in forum.
|
||||
$xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="forum__posts"]', $forum_arg);
|
||||
$this->assertFieldByXPath($xpath, '6', 'Number of posts found.');
|
||||
$elements = $this->xpath('//tr[@id=:forum]//td[@class="forum__posts"]', $forum_arg);
|
||||
$this->assertEquals('6', $elements[0]->getText(), 'Number of posts found.');
|
||||
|
||||
// Test loading multiple forum nodes on the front page.
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer content types', 'create forum content', 'post comments')));
|
||||
|
@ -322,8 +322,8 @@ class ForumTest extends WebTestBase {
|
|||
|
||||
// Test vocabulary form alterations.
|
||||
$this->drupalGet('admin/structure/taxonomy/manage/forums');
|
||||
$this->assertFieldByName('op', t('Save'), 'Save button found.');
|
||||
$this->assertNoFieldByName('op', t('Delete'), 'Delete button not found.');
|
||||
$this->assertSession()->buttonExists('Save');
|
||||
$this->assertSession()->buttonNotExists('Delete');
|
||||
|
||||
// Test term edit form alterations.
|
||||
$this->drupalGet('taxonomy/term/' . $this->forumContainer['tid'] . '/edit');
|
||||
|
@ -343,7 +343,7 @@ class ForumTest extends WebTestBase {
|
|||
$vocabulary->save();
|
||||
// Test tags vocabulary form is not affected.
|
||||
$this->drupalGet('admin/structure/taxonomy/manage/tags');
|
||||
$this->assertFieldByName('op', t('Save'), 'Save button found.');
|
||||
$this->assertSession()->buttonExists('Save');
|
||||
$this->assertLink(t('Delete'));
|
||||
// Test tags vocabulary term form is not affected.
|
||||
$this->drupalGet('admin/structure/taxonomy/manage/tags/add');
|
|
@ -1,20 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\forum\Tests;
|
||||
namespace Drupal\Tests\forum\Functional;
|
||||
|
||||
use Drupal\comment\CommentInterface;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests forum module uninstallation.
|
||||
*
|
||||
* @group forum
|
||||
*/
|
||||
class ForumUninstallTest extends WebTestBase {
|
||||
class ForumUninstallTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -66,7 +66,7 @@ class ForumUninstallTest extends WebTestBase {
|
|||
// Attempt to uninstall forum.
|
||||
$this->drupalGet('admin/modules/uninstall');
|
||||
// Assert forum is required.
|
||||
$this->assertNoFieldByName('uninstall[forum]');
|
||||
$this->assertSession()->fieldDisabled('uninstall[forum]');
|
||||
$this->assertText('To uninstall Forum, first delete all Forum content');
|
||||
|
||||
// Delete the node.
|
||||
|
@ -75,7 +75,7 @@ class ForumUninstallTest extends WebTestBase {
|
|||
// Attempt to uninstall forum.
|
||||
$this->drupalGet('admin/modules/uninstall');
|
||||
// Assert forum is still required.
|
||||
$this->assertNoFieldByName('uninstall[forum]');
|
||||
$this->assertSession()->fieldDisabled('uninstall[forum]');
|
||||
$this->assertText('To uninstall Forum, first delete all Forums terms');
|
||||
|
||||
// Delete any forum terms.
|
Loading…
Reference in New Issue