mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts: tests/behat/features/edit-a-page.feature tests/behat/features/preview-a-page.feature
This commit is contained in:
commit
df1836add2
@ -5,8 +5,10 @@ namespace SilverStripe\Cms\Test\Behaviour;
|
||||
use SilverStripe\BehatExtension\Context\SilverStripeContext,
|
||||
SilverStripe\BehatExtension\Context\BasicContext,
|
||||
SilverStripe\BehatExtension\Context\LoginContext,
|
||||
SilverStripe\BehatExtension\Context\FixtureContext,
|
||||
SilverStripe\Framework\Test\Behaviour\CmsFormsContext,
|
||||
SilverStripe\Framework\Test\Behaviour\CmsUiContext;
|
||||
SilverStripe\Framework\Test\Behaviour\CmsUiContext,
|
||||
SilverStripe\Cms\Test\Behaviour;
|
||||
|
||||
// PHPUnit
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
@ -18,7 +20,7 @@ require_once 'PHPUnit/Framework/Assert/Functions.php';
|
||||
* Context automatically loaded by Behat.
|
||||
* Uses subcontexts to extend functionality.
|
||||
*/
|
||||
class FeatureContext extends SilverStripeContext
|
||||
class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureContext
|
||||
{
|
||||
/**
|
||||
* Initializes context.
|
||||
@ -28,11 +30,23 @@ class FeatureContext extends SilverStripeContext
|
||||
*/
|
||||
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);
|
||||
|
||||
// Override existing fixture context with more specific one
|
||||
$fixtureContext = new \SilverStripe\Cms\Test\Behaviour\FixtureContext($parameters);
|
||||
$fixtureContext->setFixtureFactory($this->getFixtureFactory());
|
||||
$this->useContext('FixtureContext', $fixtureContext);
|
||||
|
||||
// Use blueprints which auto-publish all subclasses of SiteTree
|
||||
$factory = $fixtureContext->getFixtureFactory();
|
||||
foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) {
|
||||
$blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
|
||||
$blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) {
|
||||
$obj->publish('Stage', 'Live');
|
||||
});
|
||||
$factory->define($class, $blueprint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Cms\Test\Behaviour;
|
||||
|
||||
use Behat\Behat\Context\ClosuredContextInterface,
|
||||
Behat\Behat\Context\TranslatedContextInterface,
|
||||
Behat\Behat\Context\BehatContext,
|
||||
Behat\Behat\Context\Step,
|
||||
Behat\Behat\Event\StepEvent,
|
||||
Behat\Behat\Exception\PendingException,
|
||||
Behat\Mink\Driver\Selenium2Driver,
|
||||
Behat\Gherkin\Node\PyStringNode,
|
||||
Behat\Gherkin\Node\TableNode;
|
||||
|
||||
// PHPUnit
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
require_once 'PHPUnit/Framework/Assert/Functions.php';
|
||||
|
||||
/**
|
||||
* Context used to create fixtures in the SilverStripe ORM.
|
||||
*/
|
||||
class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext
|
||||
{
|
||||
|
||||
/**
|
||||
* Find or create a redirector page and link to another existing page.
|
||||
* Example: Given a "page" "My Redirect" which redirects to a "page" "Page 1"
|
||||
*
|
||||
* @Given /^(?:(an|a|the) )"(?<type>[^"]+)" "(?<id>[^"]+)" (:?which )?redirects to (?:(an|a|the) )"(?<targetType>[^"]+)" "(?<targetId>[^"]+)"$/
|
||||
*/
|
||||
public function stepCreateRedirectorPage($type, $id, $targetType, $targetId)
|
||||
{
|
||||
$class = 'RedirectorPage';
|
||||
$targetClass = $this->convertTypeToClass($targetType);
|
||||
|
||||
$targetObj = $this->fixtureFactory->get($targetClass, $targetId);
|
||||
if(!$targetObj) $targetObj = $this->fixtureFactory->get($targetClass, $targetId);
|
||||
|
||||
$fields = array('LinkToID' => $targetObj->ID);
|
||||
$obj = $this->fixtureFactory->get($class, $id);
|
||||
if($obj) {
|
||||
$obj->update($fields);
|
||||
} else {
|
||||
$obj = $this->fixtureFactory->createObject($class, $id, $fields);
|
||||
}
|
||||
$obj->write();
|
||||
$obj->publish('Stage', 'Live');
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
@database-defaults
|
||||
Feature: Create a page
|
||||
As an author
|
||||
I want to create a page in the CMS
|
||||
|
@ -1,10 +1,10 @@
|
||||
@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 a "page" "About Us"
|
||||
Given I am logged in with "ADMIN" permissions
|
||||
And I go to "/admin/pages"
|
||||
Then I should see "About Us" in CMS Tree
|
||||
@ -21,8 +21,8 @@ Feature: Edit a page
|
||||
|
||||
When I fill in "Title" with "About Us!"
|
||||
And I fill in the "Content" HTML field with "my new content"
|
||||
And I press the "Save Draft" button
|
||||
Then I should see a "Saved" button
|
||||
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!"
|
||||
|
@ -1,9 +1,11 @@
|
||||
@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
|
||||
|
||||
Background:
|
||||
Given a "page" "About Us"
|
||||
|
||||
@javascript
|
||||
Scenario: I can show a preview of the current page from the pages section
|
||||
Given I am logged in with "ADMIN" permissions
|
||||
@ -27,7 +29,7 @@ Feature: Preview a page
|
||||
|
||||
When I follow "About Us"
|
||||
And I fill in the "Content" HTML field with "my new content"
|
||||
And I press the "Save Draft" button
|
||||
And I press the "Save draft" button
|
||||
And I set the CMS mode to "Preview mode"
|
||||
|
||||
When I switch the preview to "Published"
|
||||
|
@ -1,9 +1,12 @@
|
||||
@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
|
||||
|
||||
Background:
|
||||
Given a "page" "About Us"
|
||||
And a "page" "Contact Us"
|
||||
|
||||
@javascript
|
||||
Scenario: I can search for a page by its title
|
||||
Given I am logged in with "ADMIN" permissions
|
||||
|
Loading…
Reference in New Issue
Block a user