Skip to content
Snippets Groups Projects

ISTWCMS-4863-4918-4919-4920 Test sort by sticky, then date field or event date field for events, news or blogs

Compare and
1 file
+ 74
1
Compare changes
  • Side-by-side
  • Inline
@@ -361,8 +361,81 @@ 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.
// The first two nodes are non-sticky, the third is sticky.
$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',
'edit-sticky-value' => ($date === '2021-08-01') ? 1 : 0,
];
$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',
'edit-sticky-value' => ($date === '2021-08-01') ? 1 : 0,
];
$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',
'edit-sticky-value' => ($date === '2021-08-01') ? 1 : 0,
];
}
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.
// The stick one is the first, then sort by date field asc.
$expected_dates = [
'2021-08-01',
'2021-06-01',
'2021-07-01',
];
$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], $expected_dates[$key]);
}
}
$this->drupalLogin($this->drupalUsers['uw_role_content_author']);
// Make sure audience taxonomy to blog, catalog,
// event and news item content types.
$types = [
Loading