Commit f30b37a8 authored by l26yan's avatar l26yan
Browse files

ISTWCMS-4918-4919-4920 Test sort by event date (asc) for events or date fields...

ISTWCMS-4918-4919-4920 Test sort by event date (asc) for events or date fields (asc) for blog and news
parent c30311ce
......@@ -361,8 +361,72 @@ class UwWcmsBasicTest extends BrowserTestBase {
* Test content creation.
*/
private function createContent() {
$this->drupalLogin($this->drupalUsers['uw_role_content_author']);
$this->drupalLogin($this->drupalUsers['administrator']);
// Create three events node including the below dates.
$dates = [
'2021-07-01',
'2021-06-01',
'2021-08-01',
];
foreach ($dates as $date) {
$edits['event'][] = [
'edit-title-0-value' => $date,
'edit-field-uw-event-summary-0-value' => 'string',
'edit-field-uw-event-date-0-value-date' => $date,
'edit-field-uw-event-date-0-value-time' => '13:00:00',
'edit-field-uw-event-date-0-end-value-date' => $date,
'edit-field-uw-event-date-0-end-value-time' => '14:00:00',
'edit-field-uw-meta-description-0-value' => 'string',
'edit-moderation-state-0-state' => 'published',
];
$edits['blog'][] = [
'edit-title-0-value' => $date,
'edit-field-uw-blog-date-0-value-date' => $date,
'edit-field-uw-blog-summary-0-value' => 'string',
'edit-field-uw-meta-description-0-value' => 'string',
'edit-moderation-state-0-state' => 'published',
];
$edits['news_item'][] = [
'edit-title-0-value' => $date,
'edit-field-uw-news-date-0-value-date' => $date,
'edit-field-uw-news-summary-0-value' => 'string',
'edit-field-uw-meta-description-0-value' => 'string',
'edit-moderation-state-0-state' => 'published',
];
}
foreach ($edits as $content_type => $items) {
foreach ($items as $item) {
$this->drupalPostForm('node/add/uw_ct_' . $content_type, $item, 'Save');
}
}
// Get expected sort dates for late use.
sort($dates);
$page_views = [
'events',
'blog',
'news',
];
foreach ($page_views as $view) {
$this->drupalGet($view);
$this->assertSession()->statusCodeEquals(200);
$rows = $this->xpath('//div[@class="views-row"]');
// Events: getText() shows "Thursday, July 1, 2021
// 1:00 PM - 2:00 PM AEST 2021-07-01 string".
// Blog: getText() shows "Tuesday, July 1, 2021 2021-06-01
// by administrator string"
// News: getTest() shows "Thursday, July 1, 2021
// 2021-07-01 string".
// Get the actual date from the text above.
foreach ($rows as $key => $row) {
preg_match("/\d{4}\-\d{2}-\d{2}/", $row->getText(), $matches);
$this->assertEqual($matches[0], $dates[$key]);
}
}
$this->drupalLogin($this->drupalUsers['uw_role_content_author']);
// Make sure audience taxonomy to blog, catalog,
// event and news item content types.
$types = [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment