Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
219
Merge Requests
219
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
57432ad4
Commit
57432ad4
authored
Jul 19, 2016
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2737805
by klausi, larowlan: Convert web tests to browser tests for forum module
parent
91987586
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
30 deletions
+30
-30
core/modules/forum/tests/src/Functional/ForumBlockTest.php
core/modules/forum/tests/src/Functional/ForumBlockTest.php
+3
-3
core/modules/forum/tests/src/Functional/ForumIndexTest.php
core/modules/forum/tests/src/Functional/ForumIndexTest.php
+3
-3
core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php
...odules/forum/tests/src/Functional/ForumNodeAccessTest.php
+3
-3
core/modules/forum/tests/src/Functional/ForumTest.php
core/modules/forum/tests/src/Functional/ForumTest.php
+16
-16
core/modules/forum/tests/src/Functional/ForumUninstallTest.php
...modules/forum/tests/src/Functional/ForumUninstallTest.php
+5
-5
No files found.
core/modules/forum/
src/Tests
/ForumBlockTest.php
→
core/modules/forum/
tests/src/Functional
/ForumBlockTest.php
View file @
57432ad4
<?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
Web
TestBase
{
class
ForumBlockTest
extends
Browser
TestBase
{
/**
* Modules to enable.
...
...
core/modules/forum/
src/Tests
/ForumIndexTest.php
→
core/modules/forum/
tests/src/Functional
/ForumIndexTest.php
View file @
57432ad4
<?php
namespace
Drupal\
forum\Tests
;
namespace
Drupal\
Tests\forum\Functional
;
use
Drupal\
simpletest\Web
TestBase
;
use
Drupal\
Tests\Browser
TestBase
;
/**
* Tests the forum index listing.
*
* @group forum
*/
class
ForumIndexTest
extends
Web
TestBase
{
class
ForumIndexTest
extends
Browser
TestBase
{
/**
* Modules to enable.
...
...
core/modules/forum/
src/Tests
/ForumNodeAccessTest.php
→
core/modules/forum/
tests/src/Functional
/ForumNodeAccessTest.php
View file @
57432ad4
<?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
Web
TestBase
{
class
ForumNodeAccessTest
extends
Browser
TestBase
{
/**
* Modules to enable.
...
...
core/modules/forum/
src/Tests
/ForumTest.php
→
core/modules/forum/
tests/src/Functional
/ForumTest.php
View file @
57432ad4
<?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 @@
*
* @group forum
*/
class
ForumTest
extends
Web
TestBase
{
class
ForumTest
extends
Browser
TestBase
{
/**
* Modules to enable.
...
...
@@ -193,21 +193,21 @@ function testForum() {
// 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
->
assert
FieldByXpath
(
$xpath
,
$this
->
forum
[
'name'
]
,
'Forum name found in unread topics text.'
);
$
elements
=
$this
->
xpath
(
'//tr[@id=:forum]//em[@class="placeholder"]'
,
$forum_arg
);
$this
->
assert
Contains
(
$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
->
assert
FieldByXPath
(
$xpath
,
'6'
,
'Number of posts found.'
);
$
elements
=
$this
->
xpath
(
'//tr[@id=:forum]//td[@class="forum__posts"]'
,
$forum_arg
);
$this
->
assert
Equals
(
'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 @@ private function doAdminTests($user) {
// Test vocabulary form alterations.
$this
->
drupalGet
(
'admin/structure/taxonomy/manage/forums'
);
$this
->
assert
FieldByName
(
'op'
,
t
(
'Save'
),
'Save button found.
'
);
$this
->
assert
NoFieldByName
(
'op'
,
t
(
'Delete'
),
'Delete button not found.
'
);
$this
->
assert
Session
()
->
buttonExists
(
'Save
'
);
$this
->
assert
Session
()
->
buttonNotExists
(
'Delete
'
);
// Test term edit form alterations.
$this
->
drupalGet
(
'taxonomy/term/'
.
$this
->
forumContainer
[
'tid'
]
.
'/edit'
);
...
...
@@ -343,7 +343,7 @@ private function doAdminTests($user) {
$vocabulary
->
save
();
// Test tags vocabulary form is not affected.
$this
->
drupalGet
(
'admin/structure/taxonomy/manage/tags'
);
$this
->
assert
FieldByName
(
'op'
,
t
(
'Save'
),
'Save button found.
'
);
$this
->
assert
Session
()
->
buttonExists
(
'Save
'
);
$this
->
assertLink
(
t
(
'Delete'
));
// Test tags vocabulary term form is not affected.
$this
->
drupalGet
(
'admin/structure/taxonomy/manage/tags/add'
);
...
...
core/modules/forum/
src/Tests
/ForumUninstallTest.php
→
core/modules/forum/
tests/src/Functional
/ForumUninstallTest.php
View file @
57432ad4
<?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
Web
TestBase
{
class
ForumUninstallTest
extends
Browser
TestBase
{
/**
* Modules to enable.
...
...
@@ -66,7 +66,7 @@ public function testForumUninstallWithField() {
// Attempt to uninstall forum.
$this
->
drupalGet
(
'admin/modules/uninstall'
);
// Assert forum is required.
$this
->
assert
NoFieldByName
(
'uninstall[forum]'
);
$this
->
assert
Session
()
->
fieldDisabled
(
'uninstall[forum]'
);
$this
->
assertText
(
'To uninstall Forum, first delete all Forum content'
);
// Delete the node.
...
...
@@ -75,7 +75,7 @@ public function testForumUninstallWithField() {
// Attempt to uninstall forum.
$this
->
drupalGet
(
'admin/modules/uninstall'
);
// Assert forum is still required.
$this
->
assert
NoFieldByName
(
'uninstall[forum]'
);
$this
->
assert
Session
()
->
fieldDisabled
(
'uninstall[forum]'
);
$this
->
assertText
(
'To uninstall Forum, first delete all Forums terms'
);
// Delete any forum terms.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment