Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Behat test to assert news are shown #15

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions block_news.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function specialization() {
*
* @return stdClass - the block content.
*/
public function get_content() : stdClass {
public function get_content(): stdClass {
global $OUTPUT;

if ($this->content !== null) {
Expand Down Expand Up @@ -82,7 +82,7 @@ public function get_content() : stdClass {
*
* @return array news items.
*/
public function fetch_news() : array {
public function fetch_news(): array {
// Template data for mustache.
$template = new stdClass();

Expand Down Expand Up @@ -144,7 +144,7 @@ public function fetch_news() : array {
*
* @return array of the pages where the block can be added.
*/
public function applicable_formats() : array {
public function applicable_formats(): array {
return [
'admin' => false,
'site-index' => true,
Expand All @@ -159,7 +159,7 @@ public function applicable_formats() : array {
*
* @return bool.
*/
public function instance_allow_multiple() : bool {
public function instance_allow_multiple(): bool {
return false;
}

Expand All @@ -168,7 +168,7 @@ public function instance_allow_multiple() : bool {
*
* @return bool.
*/
public function has_config() : bool {
public function has_config(): bool {
return true;
}
}
2 changes: 1 addition & 1 deletion classes/admin_setting_date.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct($name, $visiblename, $description, $defaultsetting)
* @param string $query
* @return string HMTL field
*/
public function output_html($data, $query='') : string {
public function output_html($data, $query=''): string {
$default = $this->get_defaultsetting();

return format_admin_setting($this, $this->visiblename,
Expand Down
2 changes: 1 addition & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class provider implements \core_privacy\local\metadata\null_provider {
*
* @return string
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
Expand Down
28 changes: 28 additions & 0 deletions tests/behat/show_news.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@block @block_news
Feature: Show news
In order to be informed about news
As a user
I need to be able to see that the news block shows the intended news.

Background:
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| news | System | 1 | site-index | side-pre |
And the following config values are set as admin:
| config | value | plugin |
| title1 | News Title One | block_news |
| description1 | News Description One | block_news |
| link1 | https://apple.com | block_news |
| title2 | News Title Two | block_news |
| description2 | News Description Two | block_news |
| link2 | https://google.com | block_news |
| title3 | News Title Three | block_news |
| description3 | News Description Three | block_news |
| link3 | https://ucl.ac.uk | block_news |

Scenario: See news as intended.
When I am on site homepage
Then I should see "News"
And I should see "News Title One"
And I should see "News Title Two"
And I should see "News Title Three"