Skip to content

Commit 7b7852f

Browse files
authored
Merge pull request #15 from ucl-isd/CTP-2242
added Behat test to assert news are shown
2 parents 42dba87 + 5de2820 commit 7b7852f

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

block_news.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function specialization() {
4848
*
4949
* @return stdClass - the block content.
5050
*/
51-
public function get_content() : stdClass {
51+
public function get_content(): stdClass {
5252
global $OUTPUT;
5353

5454
if ($this->content !== null) {
@@ -82,7 +82,7 @@ public function get_content() : stdClass {
8282
*
8383
* @return array news items.
8484
*/
85-
public function fetch_news() : array {
85+
public function fetch_news(): array {
8686
// Template data for mustache.
8787
$template = new stdClass();
8888

@@ -144,7 +144,7 @@ public function fetch_news() : array {
144144
*
145145
* @return array of the pages where the block can be added.
146146
*/
147-
public function applicable_formats() : array {
147+
public function applicable_formats(): array {
148148
return [
149149
'admin' => false,
150150
'site-index' => true,
@@ -159,7 +159,7 @@ public function applicable_formats() : array {
159159
*
160160
* @return bool.
161161
*/
162-
public function instance_allow_multiple() : bool {
162+
public function instance_allow_multiple(): bool {
163163
return false;
164164
}
165165

@@ -168,7 +168,7 @@ public function instance_allow_multiple() : bool {
168168
*
169169
* @return bool.
170170
*/
171-
public function has_config() : bool {
171+
public function has_config(): bool {
172172
return true;
173173
}
174174
}

classes/admin_setting_date.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct($name, $visiblename, $description, $defaultsetting)
4545
* @param string $query
4646
* @return string HMTL field
4747
*/
48-
public function output_html($data, $query='') : string {
48+
public function output_html($data, $query=''): string {
4949
$default = $this->get_defaultsetting();
5050

5151
return format_admin_setting($this, $this->visiblename,

classes/privacy/provider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class provider implements \core_privacy\local\metadata\null_provider {
3838
*
3939
* @return string
4040
*/
41-
public static function get_reason() : string {
41+
public static function get_reason(): string {
4242
return 'privacy:metadata';
4343
}
4444
}

tests/behat/show_news.feature

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@block @block_news
2+
Feature: Show news
3+
In order to be informed about news
4+
As a user
5+
I need to be able to see that the news block shows the intended news.
6+
7+
Background:
8+
Given the following "blocks" exist:
9+
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
10+
| news | System | 1 | site-index | side-pre |
11+
And the following config values are set as admin:
12+
| config | value | plugin |
13+
| title1 | News Title One | block_news |
14+
| description1 | News Description One | block_news |
15+
| link1 | https://apple.com | block_news |
16+
| title2 | News Title Two | block_news |
17+
| description2 | News Description Two | block_news |
18+
| link2 | https://google.com | block_news |
19+
| title3 | News Title Three | block_news |
20+
| description3 | News Description Three | block_news |
21+
| link3 | https://ucl.ac.uk | block_news |
22+
23+
Scenario: See news as intended.
24+
When I am on site homepage
25+
Then I should see "News"
26+
And I should see "News Title One"
27+
And I should see "News Title Two"
28+
And I should see "News Title Three"

0 commit comments

Comments
 (0)