mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 09:05:53 +00:00
More verbose fixture step definitions
Too many clashes with other steps otherwise, e.g. with 'And the preview contains "You can fill"'. Also removed some duplicated code no longer necessary because we use inheritance rather than composition
This commit is contained in:
parent
8bd1e4373d
commit
d2105ef7a6
@ -21,45 +21,12 @@ require_once 'PHPUnit/Framework/Assert/Functions.php';
|
||||
*/
|
||||
class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext
|
||||
{
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* @var FixtureFactory
|
||||
*/
|
||||
protected $fixtureFactory;
|
||||
|
||||
public function __construct(array $parameters)
|
||||
{
|
||||
$this->context = $parameters;
|
||||
}
|
||||
|
||||
public function getSession($name = null)
|
||||
{
|
||||
return $this->getMainContext()->getSession($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \FixtureFactory
|
||||
*/
|
||||
public function getFixtureFactory() {
|
||||
if(!$this->fixtureFactory) {
|
||||
$this->fixtureFactory = \Injector::inst()->get('FixtureFactory', 'FixtureContextFactory');
|
||||
}
|
||||
return $this->fixtureFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \FixtureFactory $factory
|
||||
*/
|
||||
public function setFixtureFactory(\FixtureFactory $factory) {
|
||||
$this->fixtureFactory = $factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"
|
||||
* 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>[^"]+)"$/
|
||||
* @Given /^(?:(an|a|the) )"(?<type>[^"]+)" "(?<id>[^"]+)" (:?which )?redirects to (?:(an|a|the) )"(?<targetType>[^"]+)" "(?<targetId>[^"]+)"$/
|
||||
*/
|
||||
public function stepCreateRedirectorPage($type, $id, $targetType, $targetId)
|
||||
{
|
||||
@ -80,31 +47,4 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext
|
||||
$obj->publish('Stage', 'Live');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a natural language class description to an actual class name.
|
||||
* Respects {@link DataObject::$singular_name} variations.
|
||||
* Example: "redirector page" -> "RedirectorPage"
|
||||
*
|
||||
* @param String
|
||||
* @return String Class name
|
||||
*/
|
||||
protected function convertTypeToClass($type) {
|
||||
// Try direct mapping
|
||||
$class = str_replace(' ', '', ucfirst($type));
|
||||
if(class_exists($class) || !is_subclass_of($class, 'DataObject')) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
// Fall back to singular names
|
||||
foreach(array_values(\ClassInfo::subclassesFor('DataObject')) as $candidate) {
|
||||
if(singleton($candidate)->singular_name() == $type) return $candidate;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Class "%s" does not exist, or is not a subclass of DataObjet',
|
||||
$class
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ Feature: Edit a page
|
||||
So that I correct errors and provide new information
|
||||
|
||||
Background:
|
||||
Given a page "About Us"
|
||||
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
|
||||
|
@ -4,7 +4,7 @@ Feature: Preview a page
|
||||
So that I can see how it would look like to my visitors
|
||||
|
||||
Background:
|
||||
Given a page "About Us"
|
||||
Given a "page" "About Us"
|
||||
|
||||
@javascript
|
||||
Scenario: I can show a preview of the current page from the pages section
|
||||
@ -28,7 +28,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 press the "Preview »" button
|
||||
|
||||
When I follow "Published Site"
|
||||
|
@ -4,8 +4,8 @@ Feature: Search for a page
|
||||
So that I can efficiently navigate nested content structures
|
||||
|
||||
Background:
|
||||
Given a page "About Us"
|
||||
And a page "Contact Us"
|
||||
Given a "page" "About Us"
|
||||
And a "page" "Contact Us"
|
||||
|
||||
@javascript
|
||||
Scenario: I can search for a page by its title
|
||||
|
Loading…
x
Reference in New Issue
Block a user