Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WCMS
uw_base_profile
Commits
e7e0abef
Commit
e7e0abef
authored
Jul 19, 2021
by
Lily Yan
Browse files
ISTWCMS-4953 Add test function to test node revision delete config page
parent
53c325d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/src/Functional/UwWcmsBasicTest.php
View file @
e7e0abef
...
...
@@ -7,6 +7,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use
Drupal\Core\Url
;
use
Drupal\Tests\BrowserTestBase
;
use
Drupal\uw_cfg_common
\
Service\UWService
;
use
Behat\Mink\Element\NodeElement
;
/**
* Basic WCMS test.
...
...
@@ -100,6 +101,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this
->
ckeditorButtonsTest
();
$this
->
bannerBlockTest
();
$this
->
ofisTest
();
$this
->
nodeRevisionDeleteTest
();
}
/**
...
...
@@ -2564,4 +2566,89 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this
->
assertSession
()
->
pageTextNotContains
(
'Clear OFIS caches'
);
}
/**
* Test for node revision delete config.
*/
public
function
nodeRevisionDeleteTest
()
{
// Login as administrator and check node revision delete config form.
$this
->
drupalLogin
(
$this
->
drupalUsers
[
'administrator'
]);
$this
->
drupalGet
(
'admin/config/content/node_revision_delete'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
$page
=
$this
->
getSession
()
->
getPage
();
// Ensures that the current configuration table is found.
$table
=
$page
->
find
(
'css'
,
'table#edit-current-configuration'
);
$this
->
assertNotNull
(
$table
);
// Ensures that the expected table headers are found.
$headers
=
$table
->
findAll
(
'css'
,
'thead th'
);
$this
->
assertEquals
(
8
,
count
(
$headers
));
$expected_headers
=
[
'Content type'
,
'Machine name'
,
'Minimum to keep'
,
'Minimum age'
,
'When to delete'
,
'Candidate nodes'
,
'Candidate revisions'
,
'Operations'
,
];
$actual_headers
=
array_map
(
function
(
NodeElement
$element
)
{
return
$element
->
getText
();
},
$headers
);
$this
->
assertSame
(
$expected_headers
,
$actual_headers
);
// Ensures that all the layouts are listed in the table.
$content_types
=
[
'uw_ct_blog'
=>
'Blog post'
,
'uw_ct_catalog_item'
=>
'Catalog item'
,
'uw_ct_contact'
=>
'Contact'
,
'uw_ct_event'
=>
'Event'
,
'uw_ct_news_item'
=>
'News item'
,
'uw_ct_profile'
=>
'Profile'
,
'uw_ct_sidebar'
=>
'Sidebar'
,
'uw_ct_site_footer'
=>
'Site footer'
,
'uw_ct_web_page'
=>
'Web page'
,
];
$table_rows
=
$table
->
findAll
(
'css'
,
'tbody tr'
);
$this
->
assertEquals
(
9
,
count
(
$table_rows
));
$index
=
0
;
foreach
(
$content_types
as
$machine_name
=>
$content_type
)
{
$cells
=
$table_rows
[
$index
]
->
findAll
(
'css'
,
'td'
);
$this
->
assertEquals
(
8
,
count
(
$cells
));
$cell_content_type
=
$cells
[
0
];
$this
->
assertEquals
(
$cell_content_type
->
getText
(),
$content_type
);
$cell_machine_name
=
$cells
[
1
];
$this
->
assertEquals
(
$cell_machine_name
->
getText
(),
$machine_name
);
$cell_minimum_to_key
=
$cells
[
2
];
$this
->
assertEquals
(
$cell_minimum_to_key
->
getText
(),
'50'
);
$cell_minimum_age
=
$cells
[
3
];
$this
->
assertEquals
(
$cell_minimum_age
->
getText
(),
'None'
);
$cell_when_to_delete
=
$cells
[
4
];
$this
->
assertEquals
(
$cell_when_to_delete
->
getText
(),
'Always delete'
);
$cell_candidate_nodes
=
$cells
[
5
];
$this
->
assertEquals
(
$cell_candidate_nodes
->
getText
(),
'0'
);
$cell_candidate_revisions
=
$cells
[
6
];
$this
->
assertEquals
(
$cell_candidate_revisions
->
getText
(),
'0'
);
$index
++
;
}
// Make sure the default settings.
$this
->
getSession
()
->
getPage
()
->
findField
(
'edit-node-revision-delete-cron'
)
->
getValue
(
'50'
);
$this
->
getSession
()
->
getPage
()
->
findField
(
'edit-node-revision-delete-time'
)
->
getValue
(
'86400'
);
$this
->
getSession
()
->
getPage
()
->
findField
(
'edit-node-revision-delete-minimum-age-to-delete-time-max-number'
)
->
getValue
(
'12'
);
$this
->
getSession
()
->
getPage
()
->
findField
(
'edit-node-revision-delete-minimum-age-to-delete-time-time'
)
->
getValue
(
'months'
);
$this
->
getSession
()
->
getPage
()
->
findField
(
'edit-node-revision-delete-when-to-delete-time-max-number'
)
->
getValue
(
'12'
);
$this
->
getSession
()
->
getPage
()
->
findField
(
'edit-node-revision-delete-when-to-delete-time-time'
)
->
getValue
(
'months'
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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