Skip to content

Commit

Permalink
Merge pull request #51 from creative-commoners/pulls/2.3/behat
Browse files Browse the repository at this point in the history
MNT Add behat tests
  • Loading branch information
Maxime Rainville authored Nov 10, 2021
2 parents 84201eb + 3e5546c commit 2c485c6
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: ~> 1.0

import:
- silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-range.yml
- silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-range-behat.yml

env:
global:
Expand Down
29 changes: 29 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
default:
suites:
securityreport:
paths:
- "%paths.modules.securityreport%/tests/behat/features"
contexts:
- SilverStripe\Admin\Tests\Behat\Context\AdminContext
- SilverStripe\BehatExtension\Context\BasicContext
- SilverStripe\BehatExtension\Context\EmailContext
- SilverStripe\BehatExtension\Context\LoginContext
- SilverStripe\Framework\Tests\Behaviour\CmsFormsContext
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext
- SilverStripe\SecurityReport\Tests\Behat\Context\FeatureContext
- SilverStripe\SecurityReport\Tests\Behat\Context\FixtureContext
-
SilverStripe\SecurityReport\Tests\Behat\Context\FixtureContext:
- "%paths.modules.securityreport%/tests/behat/files/"

extensions:
SilverStripe\BehatExtension\MinkExtension:
default_session: facebook_web_driver
javascript_session: facebook_web_driver
facebook_web_driver:
browser: chrome
wd_host: "http://127.0.0.1:9515"

SilverStripe\BehatExtension\Extension:
screenshot_path: "%paths.base%/artifacts/screenshots"
bootstrap_file: vendor/silverstripe/framework/tests/behat/serve-bootstrap.php
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
"autoload": {
"psr-4": {
"SilverStripe\\SecurityReport\\": "src/",
"SilverStripe\\SecurityReport\\Tests\\": "tests/"
"SilverStripe\\SecurityReport\\Tests\\": "tests/",
"SilverStripe\\SecurityReport\\Tests\\Behat\\Context\\": "tests/behat/src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
Empty file added tests/behat/_manifest_exclude
Empty file.
41 changes: 41 additions & 0 deletions tests/behat/features/securityreport.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Feature: Security report
As a website user
I want to use the security report

Background:
Given the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" and "FILE_EDIT_ALL"

# Login as EDITOR to create member
And I am logged in with "EDITOR" permissions

# Logout and login again as ADMIN
And I go to "/Security/login"
And I press the "Log in as someone else" button
And I am logged in with "ADMIN" permissions

# Create a subsite
And I go to "/admin/subsites"
And I press the "Add Subsite" button
And I fill in "Subsite Name" with "My subsite"
And I press the "Create" button

Scenario: Operate the security report

# Show members
When I go to "/admin/reports"
And I follow "Users, Groups and Permissions"

# Assert firstname, surname and email
Then I should see "EDITOR"
And I should see "User"
And I should see "[email protected]"

# Groups column
And I should see "EDITOR group (global group)"

# Permissions column
Then I should see "Edit any file"
And I should see "Full administrative rights"

# Subsites column
And I should see "Main site, My subsite"
Empty file added tests/behat/files/blank.txt
Empty file.
9 changes: 9 additions & 0 deletions tests/behat/src/FeatureContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace SilverStripe\SecurityReport\Tests\Behat\Context;

use SilverStripe\BehatExtension\Context\SilverStripeContext;

class FeatureContext extends SilverStripeContext
{
}
9 changes: 9 additions & 0 deletions tests/behat/src/FixtureContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace SilverStripe\SecurityReport\Tests\Behat\Context;

use SilverStripe\BehatExtension\Context\FixtureContext as BaseFixtureContext;

class FixtureContext extends BaseFixtureContext
{
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2c485c6

Please sign in to comment.