Merge remote-tracking branch 'origin/3.1'
Conflicts: .travis.yml forms/Form.php
This commit is contained in:
commit
d485faf0c9
21
.travis.yml
21
.travis.yml
|
@ -16,15 +16,26 @@ matrix:
|
|||
env: DB=MYSQL CORE_RELEASE=master
|
||||
- php: 5.5
|
||||
env: DB=MYSQL CORE_RELEASE=master
|
||||
- php: 5.3
|
||||
env: DB=MYSQL CORE_RELEASE=master BEHAT_TEST=1
|
||||
|
||||
before_script:
|
||||
- composer self-update
|
||||
- phpenv rehash
|
||||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
||||
- "if [ \"$BEHAT_TEST\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension; fi"
|
||||
- cd ~/builds/ss
|
||||
- php ~/travis-support/travis_setup_selenium.php --base-url http://localhost --if-env BEHAT_TEST
|
||||
- php ~/travis-support/travis_setup_apache.php --if-env BEHAT_TEST
|
||||
|
||||
script:
|
||||
- phpunit framework/tests
|
||||
- "if [ \"$BEHAT_TEST\" = \"\" ]; then phpunit framework/tests; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then vendor/bin/behat --tags '~@todo&&~@assets' @framework; fi"
|
||||
|
||||
after_failure:
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then sudo cat /var/log/apache2/error.log; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then sudo cat /var/log/apache2/access.log; fi"
|
||||
|
||||
branches:
|
||||
except:
|
||||
|
@ -37,3 +48,9 @@ notifications:
|
|||
irc:
|
||||
channels:
|
||||
- "irc.freenode.org#silverstripe"
|
||||
|
||||
# global:
|
||||
# - secure: "AZmjVPtUD8JBA7ag4ULlEwEKXSEZbIUjDHeRBFugaOtdsn5yigGLmwYbzsg2tq7k7UkdbbAlGct0SUbiRJb9F2wPA5+eUd/p49fgDIU6CTSWIlT87H2BwgOrxKwS9sDwxLptPFM6vWQ8JKYSNGmVIepie9kQZbu4L2k5k6B69jQ="
|
||||
# - secure: "f3kKpUn9cS5K+p/E52cMqN18cDApol/43LanDmHO6mo3iRAztk3jZLyfNOUq6JASKMqdh8+9kencRpEoaAYbcQnDPoZsT9POResiJ9/ADKB6RwWy+lcFHUp9E2Zf/x2VRh9FmXEguDhpWzkJqzWYJGCSig1IBp/+TjzKnsjQHIY="
|
||||
#
|
||||
# - php ~/travis-support/travis_setup_sauceconnect.php --if-env BEHAT_TEST --username ${SAUCE_USERNAME} --access-key ${SAUCE_ACCESS_KEY} --tunnel-identifier ${TRAVIS_JOB_NUMBER} --base-url http://localhost
|
||||
|
|
|
@ -3,6 +3,23 @@
|
|||
* Deals with special form handling in CMS, mainly around {@link PjaxResponseNegotiator}
|
||||
*/
|
||||
class CMSForm extends Form {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $validationExemptActions = array();
|
||||
|
||||
/**
|
||||
* Always return true if the current form action is exempt from validation
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function validate() {
|
||||
return (
|
||||
in_array($this->buttonClicked()->actionName(), $this->getValidationExemptActions())
|
||||
|| parent::validate()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Route validation error responses through response negotiator,
|
||||
|
@ -19,6 +36,25 @@ class CMSForm extends Form {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set actions that are exempt from validation
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
public function setValidationExemptActions($actions) {
|
||||
$this->validationExemptActions = $actions;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of actions that are exempt from validation
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValidationExemptActions() {
|
||||
return $this->validationExemptActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the response negotiator
|
||||
* @param ResponseNegotiator $negotiator The response negotiator to use
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package framework
|
||||
* @subpackage tests
|
||||
*/
|
||||
class CMSFormTest extends FunctionalTest {
|
||||
|
||||
public function testValidationExemptActions() {
|
||||
$response = $this->get('CMSFormTest_Controller');
|
||||
|
||||
$response = $this->submitForm(
|
||||
'Form_Form',
|
||||
'action_doSubmit',
|
||||
array(
|
||||
'Email' => 'test@test.com'
|
||||
)
|
||||
);
|
||||
|
||||
// Firstly, assert that required fields still work when not using an exempt action
|
||||
$this->assertPartialMatchBySelector(
|
||||
'#SomeRequiredField span.required',
|
||||
array(
|
||||
'"Some Required Field" is required'
|
||||
),
|
||||
'Required fields show a notification on field when left blank'
|
||||
);
|
||||
|
||||
// Re-submit the form using validation-exempt button
|
||||
$response = $this->submitForm(
|
||||
'Form_Form',
|
||||
'action_doSubmitValidationExempt',
|
||||
array(
|
||||
'Email' => 'test@test.com'
|
||||
)
|
||||
);
|
||||
|
||||
// The required message should be empty if validation was skipped
|
||||
$items = $this->cssParser()->getBySelector('#SomeRequiredField span.required');
|
||||
$this->assertEmpty($items);
|
||||
|
||||
// And the session message should show up is submitted successfully
|
||||
$this->assertPartialMatchBySelector(
|
||||
'#Form_Form_error',
|
||||
array(
|
||||
'Validation skipped'
|
||||
),
|
||||
'Form->sessionMessage() shows up after reloading the form'
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetValidationExemptActions() {
|
||||
$form = $this->getStubForm();
|
||||
|
||||
$form->setValidationExemptActions(array('exemptaction'));
|
||||
$exemptActions = $form->getValidationExemptActions();
|
||||
$this->assertEquals('exemptaction', $exemptActions[0]);
|
||||
}
|
||||
|
||||
protected function getStubForm() {
|
||||
$form = new CMSForm(
|
||||
new CMSFormTest_Controller(),
|
||||
'CMSForm',
|
||||
new FieldList(),
|
||||
new FieldList()
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CMSFormTest_Controller extends Controller implements TestOnly {
|
||||
|
||||
private static $allowed_actions = array('Form');
|
||||
|
||||
private static $url_handlers = array(
|
||||
'$Action//$ID/$OtherID' => "handleAction",
|
||||
);
|
||||
|
||||
protected $template = 'BlankPage';
|
||||
|
||||
public function Link($action = null) {
|
||||
return Controller::join_links('CMSFormTest_Controller', $this->request->latestParam('Action'),
|
||||
$this->request->latestParam('ID'), $action);
|
||||
}
|
||||
|
||||
public function Form() {
|
||||
$form = new CMSForm(
|
||||
$this,
|
||||
'Form',
|
||||
new FieldList(
|
||||
new EmailField('Email'),
|
||||
new TextField('SomeRequiredField'),
|
||||
new CheckboxSetField('Boxes', null, array('1'=>'one','2'=>'two'))
|
||||
),
|
||||
new FieldList(
|
||||
new FormAction('doSubmit'),
|
||||
new FormAction('doSubmitValidationExempt')
|
||||
),
|
||||
new RequiredFields(
|
||||
'Email',
|
||||
'SomeRequiredField'
|
||||
)
|
||||
);
|
||||
$form->setValidationExemptActions(array('doSubmitValidationExempt'));
|
||||
$form->setResponseNegotiator('foo'); // We aren't testing AJAX responses, so just set anything
|
||||
$form->disableSecurityToken(); // Disable CSRF protection for easier form submission handling
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function doSubmit($data, $form, $request) {
|
||||
$form->sessionMessage('Test save was successful', 'good');
|
||||
return $this->redirectBack();
|
||||
}
|
||||
|
||||
public function doSubmitValidationExempt($data, $form, $request) {
|
||||
$form->sessionMessage('Validation skipped', 'good');
|
||||
return $this->redirectBack();
|
||||
}
|
||||
|
||||
public function getViewer($action = null) {
|
||||
return new SSViewer('BlankPage');
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
## Overview
|
||||
|
||||
* Fixed regression with "Reports" section links
|
||||
* Complete translations into Chinese, Japanese and partially complete Te Reo Māori
|
||||
* Complete translations into Chinese, Arabic, Japanese and partially complete Te Reo Māori
|
||||
|
||||
## Changelog
|
||||
|
||||
|
|
|
@ -1504,12 +1504,12 @@ class Form extends RequestHandler {
|
|||
* @return FormAction
|
||||
*/
|
||||
public function buttonClicked() {
|
||||
foreach($this->actions as $action) {
|
||||
if($this->buttonClickedFunc == $action->actionName()) {
|
||||
foreach($this->actions->dataFields() as $action) {
|
||||
if($action->hasMethod('actionname') && $this->buttonClickedFunc == $action->actionName()) {
|
||||
return $action;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default button that should be clicked when another one isn't
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
Feature: Apply rich formatting to content
|
||||
As a cms author
|
||||
I want to work with content in the way I'm used to from word processing software
|
||||
So that I make it more appealing by creating structure and highlights
|
||||
|
||||
Background:
|
||||
Given a "page" "About Us" has the "Content" "<h1>My awesome headline</h1><p>Some amazing content</p>"
|
||||
And I am logged in with "ADMIN" permissions
|
||||
And I go to "/admin/pages"
|
||||
Then I click on "About Us" in the tree
|
||||
|
||||
Scenario: I can control alignment of selected content
|
||||
Given I select "My awesome headline" in the "Content" HTML field
|
||||
When I press the "Align Right" button
|
||||
Then "My awesome headline" in the "Content" HTML field should be right aligned
|
||||
But "Some amazing content" in the "Content" HTML field should be left aligned
|
||||
Then I press the "Save draft" button
|
||||
Then "My awesome headline" in the "Content" HTML field should be right aligned
|
||||
|
||||
Scenario: I can bold selected content
|
||||
Given I select "awesome" in the "Content" HTML field
|
||||
When I press the "Bold (Ctrl+B)" button
|
||||
Then "awesome" in the "Content" HTML field should be bold
|
||||
But "My" in the "Content" HTML field should not be bold
|
||||
When I press the "Save draft" button
|
||||
Then "awesome" in the "Content" HTML field should be bold
|
||||
But "My" in the "Content" HTML field should not be bold
|
||||
|
|
@ -299,7 +299,7 @@ class CmsUiContext extends BehatContext
|
|||
$driver->switchToIFrame('cms-preview-iframe');
|
||||
$this->getSession()->wait(
|
||||
5000,
|
||||
"!jQuery('iframe[name=cms-preview-iframe]').hasClass('loading')"
|
||||
"window.jQuery && !window.jQuery('iframe[name=cms-preview-iframe]').hasClass('loading')"
|
||||
);
|
||||
$driver->switchToWindow($origWindowName);
|
||||
}
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
@assets
|
||||
Feature: Insert links into a page
|
||||
As a cms author
|
||||
I want to insert a link into my content
|
||||
So that I can link to a external website or a page on my site
|
||||
|
||||
Background:
|
||||
Given a "page" "Home"
|
||||
And a "page" "About Us" has the "Content" "My awesome content"
|
||||
#And a "file" "assets/folder1/file1.jpg"
|
||||
And I am logged in with "ADMIN" permissions
|
||||
And I go to "/admin/pages"
|
||||
And I click on "About Us" in the tree
|
||||
|
||||
Scenario: I can link to an internal page
|
||||
Given I select "awesome" in the "Content" HTML field
|
||||
And I press the "Insert Link" button
|
||||
When I check "Page on the site"
|
||||
And I fill in the "Page" dropdown with "Home"
|
||||
And I fill in "my desc" for "Link description"
|
||||
And I press the "Insert" button
|
||||
# TODO Dynamic DB identifiers
|
||||
Then the "Content" HTML field should contain "<a title="my desc" href="[sitetree_link,id=1]">awesome</a>"
|
||||
# Required to avoid "unsaved changed" browser dialog
|
||||
Then I press the "Save draft" button
|
||||
|
||||
Scenario: I can link to an external URL
|
||||
Given I select "awesome" in the "Content" HTML field
|
||||
And I press the "Insert Link" button
|
||||
|
||||
When I check "Another website"
|
||||
And I fill in "http://silverstripe.org" for "URL"
|
||||
And I check "Open link in a new window"
|
||||
And I press the "Insert" button
|
||||
Then the "Content" HTML field should contain "<a href="http://silverstripe.org" target="_blank">awesome</a>"
|
||||
# Required to avoid "unsaved changed" browser dialog
|
||||
Then I press the "Save draft" button
|
||||
|
||||
@todo
|
||||
Scenario: I can link to a file
|
||||
Given I select "awesome" in the "Content" HTML field
|
||||
When I press the "Insert Link" button
|
||||
When I check "Download a file"
|
||||
And I fill in the "File" dropdown with "file1.jpg"
|
||||
And I press the "Insert link" button
|
||||
Then the "Content" HTML field should contain "<a href="assets/folder1/file1.jpg">awesome</a>"
|
||||
# Required to avoid "unsaved changed" browser dialog
|
||||
Then I press the "Save draft" button
|
||||
|
||||
|
||||
@todo
|
||||
Scenario: I can link to an anchor
|
||||
Given I fill in the "Content" HTML field with "My awesome content <a name=myanchor>"
|
||||
And I select "awesome" in the "Content" HTML field
|
||||
When I press the "Insert Link" button
|
||||
When I check "Anchor on this page"
|
||||
And I fill in the "Select an anchor" dropdown with "myanchor"
|
||||
And I press the "Insert link" button
|
||||
Then the "Content" HTML field should contain "<a href="#myanchor">awesome</a>"
|
||||
# Required to avoid "unsaved changed" browser dialog
|
||||
Then I press the "Save draft" button
|
||||
|
||||
@todo
|
||||
Scenario: I can edit a link
|
||||
Given I fill in the "Content" HTML field with "My <a href="http://silverstripe.org">awesome</a> content"
|
||||
And I select "awesome"
|
||||
When I press the "Insert Link" button
|
||||
And the "URL" field should contain "http://silverstripe.org"
|
||||
When I fill in "http://wordpress.org" for "URL"
|
||||
And I press the "Insert link" button
|
||||
Then the "Content" HTML field should contain "<a href="http://wordpress.org">awesome</a>"
|
||||
# Required to avoid "unsaved changed" browser dialog
|
||||
Then I press the "Save draft" button
|
||||
|
||||
@todo
|
||||
Scenario: I can delete a link
|
||||
Given I fill in the "Content" HTML field with "My <a href="http://silverstripe.org">awesome</a> content"
|
||||
And I select "awesome"
|
||||
When I press the "Insert Link" button
|
||||
And I press the "Remove link" button
|
||||
Then the "Content" HTML field should not contain "<a href="http://silverstripe.org">awesome</a>"
|
||||
# Required to avoid "unsaved changed" browser dialog
|
||||
Then I press the "Save draft" button
|
|
@ -1,95 +0,0 @@
|
|||
@assets
|
||||
Feature: Insert an image into a page
|
||||
As a cms author
|
||||
I want to insert an image into a page
|
||||
So that I can insert them into my content efficiently
|
||||
|
||||
Background:
|
||||
Given a "page" "About Us"
|
||||
#And a "file" "assets/folder1/file1.jpg"
|
||||
#And a "file" "assets/folder1/file3.jpg"
|
||||
#And a "file" "assets/folder1/folder1.1/file2.jpg"
|
||||
#And a "folder" "assets/folder2"
|
||||
And I am logged in with "ADMIN" permissions
|
||||
And I go to "/admin/pages"
|
||||
And I click on "About Us" in the tree
|
||||
|
||||
Scenario: I can insert an image from a URL
|
||||
Given I press the "Insert Media" button
|
||||
Then I should see "Choose files to upload..."
|
||||
|
||||
When I press the "From the web" button
|
||||
And I fill in "RemoteURL" with "http://www.silverstripe.com/themes/sscom/images/silverstripe_logo_web.png"
|
||||
And I press the "Add url" button
|
||||
Then I should see "silverstripe_logo_web.png (www.silverstripe.com)" in the ".ss-assetuploadfield span.name" element
|
||||
|
||||
When I press the "Insert" button
|
||||
Then the "Content" HTML field should contain "silverstripe_logo_web.png"
|
||||
# Required to avoid "unsaved changed" browser dialog
|
||||
Then I press the "Save draft" button
|
||||
|
||||
@todo
|
||||
Scenario: I can insert an image uploaded from my own computer
|
||||
Given I press the "Insert Media" button
|
||||
And I press the "From your computer" button
|
||||
# TODO Figure out how to provide the file
|
||||
And I attach the file "testfile.jpg" to "AssetUploadField" with HTML5
|
||||
Then the upload field should have successfully uploaded "testfile.jpg"
|
||||
When I press the "Insert" button
|
||||
Then the "Content" HTML field should contain "testfile.jpg"
|
||||
|
||||
@todo
|
||||
Scenario: I can insert an image from the CMS file store
|
||||
Given I press the "Insert Media" button
|
||||
And I press the "From the CMS" button
|
||||
And I select "folder1" in the "Find in Folder" dropdown
|
||||
And I select "file1.jpg"
|
||||
When I press the "Insert" button
|
||||
Then the "Content" HTML field should contain "file1.jpg"
|
||||
|
||||
@todo
|
||||
Scenario: I can insert multiple images at once
|
||||
Given I press the "Insert Media" button
|
||||
And I press the "From the CMS" button
|
||||
And I select "folder1" in the "Find in Folder" dropdown
|
||||
And I select "file1.jpg"
|
||||
And I select "file3.jpg"
|
||||
When I press the "Insert" button
|
||||
Then the "Content" HTML field should contain "file1.jpg"
|
||||
And the "Content" HTML field should contain "file1.jpg"
|
||||
|
||||
@todo
|
||||
Scenario: I can edit properties of an image before inserting it
|
||||
Given I press the "Insert Media" button
|
||||
And I press the "From the CMS" button
|
||||
And I select "folder1" in the "Find in Folder" dropdown
|
||||
And I select "file1.jpg"
|
||||
And I follow "Edit"
|
||||
When I fill in "Alternative text (alt)" with "My alt"
|
||||
And I press the "Insert" button
|
||||
Then the "Content" HTML field should contain "file1.jpg"
|
||||
And the "Content" HTML field should contain "My alt"
|
||||
|
||||
@todo
|
||||
Scenario: I can edit dimensions of an image before inserting it
|
||||
Given I press the "Insert Media" button
|
||||
And I press the "From the CMS" button
|
||||
And I select "folder1" in the "Find in Folder" dropdown
|
||||
And I select "file1.jpg"
|
||||
And I follow "Edit"
|
||||
When I fill in "Width" with "10"
|
||||
When I fill in "Height" with "20"
|
||||
And I press the "Insert" button
|
||||
Then the "Content" HTML field should contain "<img src=assets/folder1/file1.jpg width=10 height=20>"
|
||||
|
||||
@todo
|
||||
Scenario: I can edit dimensions of an existing image
|
||||
Given the "page" "About us" contains "<img src=assets/folder1/file1.jpg>"
|
||||
And I reload the current page
|
||||
When I highlight "<img src=assets/folder1/file1.jpg>" in the "Content" HTML field
|
||||
And I press the "Insert Media" button
|
||||
Then I should see "file1.jpg"
|
||||
When I fill in "Width" with "10"
|
||||
When I fill in "Height" with "20"
|
||||
And I press the "Insert" button
|
||||
Then the "Content" HTML field should contain "<img src=assets/folder1/file1.jpg width=10 height=20>"
|
Loading…
Reference in New Issue