-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from mateusz/fix-link-rewrite
BUG Fixes to link rewriting when previewing subsites.
- Loading branch information
Showing
5 changed files
with
163 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
tests/behat/features/bootstrap/Context/FeatureContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
namespace Subsites\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\Cms\Test\Behaviour; | ||
|
||
// 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 { | ||
|
||
/** | ||
* @var FixtureFactory | ||
*/ | ||
protected $fixtureFactory; | ||
|
||
/** | ||
* 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) { | ||
parent::__construct($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)); | ||
|
||
$fixtureContext = new FixtureContext($parameters); | ||
$fixtureContext->setFixtureFactory($this->getFixtureFactory()); | ||
$this->useContext('FixtureContext', $fixtureContext); | ||
|
||
// Use blueprints to set user name from identifier | ||
$factory = $fixtureContext->getFixtureFactory(); | ||
$blueprint = \Injector::inst()->create('FixtureBlueprint', 'Member'); | ||
$blueprint->addCallback('beforeCreate', function($identifier, &$data, &$fixtures) { | ||
if(!isset($data['FirstName'])) $data['FirstName'] = $identifier; | ||
}); | ||
$factory->define('Member', $blueprint); | ||
|
||
// Auto-publish pages | ||
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); | ||
} | ||
} | ||
|
||
public function setMinkParameters(array $parameters) { | ||
parent::setMinkParameters($parameters); | ||
|
||
if(isset($parameters['files_path'])) { | ||
$this->getSubcontext('FixtureContext')->setFilesPath($parameters['files_path']); | ||
} | ||
} | ||
|
||
/** | ||
* @return FixtureFactory | ||
*/ | ||
public function getFixtureFactory() { | ||
if(!$this->fixtureFactory) { | ||
$this->fixtureFactory = \Injector::inst()->create('BehatFixtureFactory'); | ||
} | ||
|
||
return $this->fixtureFactory; | ||
} | ||
|
||
public function setFixtureFactory(FixtureFactory $factory) { | ||
$this->fixtureFactory = $factory; | ||
} | ||
|
||
// | ||
// Place your definition and hook methods here: | ||
// | ||
// /** | ||
// * @Given /^I have done something with "([^"]*)"$/ | ||
// */ | ||
// public function iHaveDoneSomethingWith($argument) { | ||
// $container = $this->kernel->getContainer(); | ||
// $container->get('some_service')->doSomethingWith($argument); | ||
// } | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Feature: Preview navigation | ||
As a CMS user | ||
I can navigate a subsite in the preview pane | ||
In order to preview my content | ||
|
||
Background: | ||
Given a "subsite" "My subsite" | ||
And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content <a name='aname'>aname</a><a href='other-page'>ahref</a>" and "Subsite"="=>Subsite.My subsite" | ||
And a "page" "Other page" with "URLSegment"="other-page", "Content"="Other page content <form action='my-page'><input type='submit' value='Submit my form'></form>" and "Subsite"="=>Subsite.My subsite" | ||
Given a "member" "Joe" belonging to "Admin Group" with "Email"="[email protected]" and "Password"="Password1" | ||
And the "group" "Admin Group" has permissions "Full administrative rights" | ||
And I log in with "[email protected]" and "Password1" | ||
|
||
Scenario: I can navigate the subsite preview | ||
When I go to "admin" | ||
And I select "My subsite" from "SubsitesSelect" | ||
And I go to "admin/pages" | ||
And I click on "My page" in the tree | ||
And I wait for 3 seconds | ||
And I set the CMS mode to "Preview mode" | ||
And I follow "ahref" in preview | ||
Then the preview contains "Other page content" | ||
# We are already on the second page, submit the form to return to first one. | ||
When I wait for 3 seconds | ||
And I press "Submit my form" in preview | ||
Then the preview contains "My page content" |