mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
FIX Update behat tests and add configuration
This commit is contained in:
parent
1a9797c185
commit
d934fbe08c
10
.travis.yml
10
.travis.yml
@ -3,6 +3,9 @@ language: php
|
||||
addons:
|
||||
firefox: "31.0"
|
||||
|
||||
# Required for Behat, currently
|
||||
dist: precise
|
||||
|
||||
env:
|
||||
global:
|
||||
- COMPOSER_ROOT_VERSION="4.0.x-dev"
|
||||
@ -17,9 +20,8 @@ matrix:
|
||||
env: DB=PGSQL PHPUNIT_TEST=1
|
||||
- php: 7.1
|
||||
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
||||
# @todo Fix behat
|
||||
# - php: 7.0
|
||||
# env: DB=MYSQL BEHAT_TEST=1
|
||||
- php: 7.0
|
||||
env: DB=MYSQL BEHAT_TEST=1
|
||||
|
||||
before_script:
|
||||
- phpenv rehash
|
||||
@ -43,7 +45,7 @@ before_script:
|
||||
|
||||
|
||||
script:
|
||||
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/php/ flush=1; fi
|
||||
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
|
||||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
|
||||
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=framework/phpcs.xml.dist code/ tests/ ; fi
|
||||
- if [[ $BEHAT_TEST ]]; then vendor/bin/behat @subsites; fi
|
||||
|
27
behat.yml
Normal file
27
behat.yml
Normal file
@ -0,0 +1,27 @@
|
||||
default:
|
||||
suites:
|
||||
subsites:
|
||||
paths:
|
||||
- %paths.modules.subsites%/tests/behat/features
|
||||
contexts:
|
||||
- SilverStripe\Framework\Tests\Behaviour\FeatureContext
|
||||
- SilverStripe\Framework\Tests\Behaviour\CmsFormsContext
|
||||
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext
|
||||
- SilverStripe\BehatExtension\Context\BasicContext
|
||||
- SilverStripe\BehatExtension\Context\EmailContext
|
||||
- SilverStripe\CMS\Tests\Behaviour\LoginContext
|
||||
- SilverStripe\CMS\Tests\Behaviour\ThemeContext
|
||||
- SilverStripe\CMS\Tests\Behaviour\FixtureContext:
|
||||
# Note: double indent for args is intentional
|
||||
- %paths.modules.subsites%/tests/behat/features/files/
|
||||
|
||||
extensions:
|
||||
SilverStripe\BehatExtension\MinkExtension:
|
||||
default_session: selenium2
|
||||
javascript_session: selenium2
|
||||
selenium2:
|
||||
browser: firefox
|
||||
|
||||
SilverStripe\BehatExtension\Extension:
|
||||
screenshot_path: %paths.base%/artifacts/screenshots
|
||||
bootstrap_file: "cms/tests/behat/serve-bootstrap.php"
|
@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Subsites\Tests\Behaviour;
|
||||
|
||||
if (!class_exists('SilverStripe\BehatExtension\Context\SilverStripeContext')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use SilverStripe\BehatExtension\Context\BasicContext;
|
||||
use SilverStripe\BehatExtension\Context\FixtureContext;
|
||||
use SilverStripe\BehatExtension\Context\LoginContext;
|
||||
use SilverStripe\BehatExtension\Context\SilverStripeContext;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\BehatFixtureFactory;
|
||||
use SilverStripe\Dev\FixtureBlueprint;
|
||||
use SilverStripe\Dev\FixtureFactory;
|
||||
use SilverStripe\Framework\Test\Behaviour\CmsFormsContext;
|
||||
use SilverStripe\Framework\Test\Behaviour\CmsUiContext;
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
// 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::class, Member::class);
|
||||
$blueprint->addCallback('beforeCreate', function ($identifier, &$data, &$fixtures) {
|
||||
if (!isset($data['FirstName'])) {
|
||||
$data['FirstName'] = $identifier;
|
||||
}
|
||||
});
|
||||
$factory->define(Member::class, $blueprint);
|
||||
|
||||
// Auto-publish pages
|
||||
foreach (ClassInfo::subclassesFor(SiteTree::class) as $id => $class) {
|
||||
$blueprint = Injector::inst()->create(FixtureBlueprint::class, $class);
|
||||
$blueprint->addCallback('afterCreate', function ($obj, $identifier, &$data, &$fixtures) {
|
||||
$obj->copyVersionToStage('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::class);
|
||||
}
|
||||
|
||||
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);
|
||||
// }
|
||||
//
|
||||
}
|
@ -5,22 +5,21 @@ Feature: Preview navigation
|
||||
|
||||
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"
|
||||
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"="=>SilverStripe\Subsites\Model\Subsite.My subsite"
|
||||
And a "page" "Other page" with "URLSegment"="other-page", "Content"="Other page content <a href='my-page'>Goto my page></a>" and "Subsite"="=>SilverStripe\Subsites\Model\Subsite.My subsite"
|
||||
Given a "member" "Joe" belonging to "Admin Group" with "Email"="joe@test.com" and "Password"="Password1"
|
||||
And the "group" "Admin Group" has permissions "Full administrative rights"
|
||||
And I log in with "joe@test.com" and "Password1"
|
||||
|
||||
@javascript
|
||||
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
|
||||
# We are already on the second page, submit the form to return to first one.
|
||||
And I follow "Goto my page" in preview
|
||||
Then the preview contains "My page content"
|
||||
|
Loading…
Reference in New Issue
Block a user