Merge pull request #236 from chillu/pulls/behat

Behat Tests
This commit is contained in:
Sam Minnée 2012-11-15 18:35:41 -08:00
commit 2227e7d152
10 changed files with 184 additions and 1 deletions

View File

@ -19,5 +19,8 @@
"php": ">=5.3.2",
"composer/installers": "*",
"silverstripe/framework": "self.version"
}
},
"autoload": {
"classmap": ["tests/behat/"]
}
}

1
tests/behat/README.md Normal file
View File

@ -0,0 +1 @@
See https://github.com/silverstripe-labs/silverstripe-behat-extension

View File

34
tests/behat/behat.yml Normal file
View File

@ -0,0 +1,34 @@
default:
context:
class: SilverStripe\Cms\Test\Behaviour\FeatureContext
extensions:
SilverStripe\BehatExtension\Extension: ~
Behat\MinkExtension\Extension:
# Adjust this to your local environment
base_url: http://localhost/
files_path: %behat.paths.features%/files/
default_session: selenium2
javascript_session: selenium2
goutte: ~
selenium2:
browser: firefox
# Alternative profile, use with "vendor/bin/behat --profile chrome"
chrome:
extensions:
Behat\MinkExtension\Extension:
selenium2:
browser: chrome
# Saucelabs.com sample setup, use with "vendor/bin/behat --profile saucelabs"
saucelabs:
extensions:
Behat\MinkExtension\Extension:
selenium2:
browser: firefox
# Add your own username and API token here
wd_host: <user>:<api-token>@ondemand.saucelabs.com/wd/hub
capabilities:
platform: "Windows 2008"
browser: "firefox"
version: "15"

View File

@ -0,0 +1,38 @@
<?php
namespace SilverStripe\Cms\Test\Behaviour;
use SilverStripe\BehatExtension\Context\SilverStripeContext,
SilverStripe\BehatExtension\Context\BasicContext,
SilverStripe\BehatExtension\Context\LoginContext,
SilverStripe\Test\Behaviour\CmsFormsContext,
SilverStripe\Test\Behaviour\CmsUiContext;
// PHPUnit
require_once 'PHPUnit/Autoload.php';
require_once 'PHPUnit/Framework/Assert/Functions.php';
/**
* Features context
*
* Context automatically loaded by Behat.
* Uses subcontexts to extend functionality.
*/
class FeatureContext extends SilverStripeContext
{
/**
* Initializes context.
* Every scenario gets it's own context object.
*
* @param array $parameters context parameters (set them up through behat.yml)
*/
public function __construct(array $parameters)
{
$this->useContext('BasicContext', new BasicContext($parameters));
$this->useContext('LoginContext', new LoginContext($parameters));
$this->useContext('CmsFormsContext', new CmsFormsContext($parameters));
$this->useContext('CmsUiContext', new CmsUiContext($parameters));
parent::__construct($parameters);
}
}

View File

@ -0,0 +1,15 @@
@database-defaults
Feature: Create a page
As an author
I want to create a page in the CMS
So that I can grow my website
@javascript
Scenario: I can create a page from the pages section
Given I am logged in with "ADMIN" permissions
And I go to "/admin/pages"
And I should see a "Add new" button in CMS Content Toolbar
When I press the "Add new" button
And I check "Page"
And I press the "Create" button
Then I should see an edit page form

View File

@ -0,0 +1,29 @@
@database-defaults
Feature: Edit a page
As an author
I want to edit a page in the CMS
So that I correct errors and provide new information
Background:
Given I am logged in with "ADMIN" permissions
And I go to "/admin/pages"
Then I should see "About Us" in CMS Tree
@javascript
Scenario: I can open a page for editing from the pages tree
When I follow "About Us"
Then I should see an edit page form
@javascript
Scenario: I can edit title and content and see the changes on draft
When I follow "About Us"
Then I should see an edit page form
When I fill in "Title" with "About Us!"
And I fill in the content form with "my new content"
And I press the "Save Draft" button
Then I should see a "Saved." notice
When I follow "About Us"
Then the "Title" field should contain "About Us!"
And the content form should contain "my new content"

View File

@ -0,0 +1,41 @@
@database-defaults
Feature: Preview a page
As an author
I want to preview the page I'm editing in the CMS
So that I can see how it would look like to my visitors
@javascript
Scenario: I can show a preview of the current page from the pages section
Given I am logged in with "ADMIN" permissions
And I go to "/admin/pages"
Then I should see "About Us" in CMS Tree
When I follow "About Us"
And I press the "Preview »" button
Then I can see the preview panel
And the preview contains "About Us"
# TODO:
# - Only tests correctly on fresh database
# - We should continue testing against it after we have fixtures ready
@javascript
Scenario: I can see an updated preview when editing content
Given I am logged in with "ADMIN" permissions
And I go to "/admin/pages"
Then I should see "About Us" in CMS Tree
When I follow "About Us"
And I fill in the content form with "my new content"
And I press the "Save Draft" button
And I press the "Preview »" button
When I follow "Published Site"
Then the preview does not contain "my new content"
And the preview contains "You can fill"
When I follow "Draft Site"
Then the preview does not contain "You can fill"
And the preview contains "my new content"
When I press the "« Edit" button
Then I should see an edit page form

View File

@ -0,0 +1,4 @@
Feature: Create a page
As a site owner
I want content to go to a draft site before being published
So that only high quality changes are seen by our visitors

View File

@ -0,0 +1,18 @@
@database-defaults
Feature: Search for a page
As an author
I want to search for a page in the CMS
So that I can efficiently navigate nested content structures
@javascript
Scenario: I can search for a page by its title
Given I am logged in with "ADMIN" permissions
And I go to "/admin/pages"
Then I should see "About Us" in CMS Tree
And I should see "Contact Us" in CMS Tree
When I expand the "Filter" CMS Panel
And I fill in "Content" with "About Us"
And I press the "Apply Filter" button
Then I should see "About Us" in CMS Tree
But I should not see "Contact Us" in CMS Tree