mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge remote-tracking branch 'origin/3.0' into 3.1.0
Conflicts: model/Hierarchy.php
This commit is contained in:
commit
40c239076b
@ -3,3 +3,5 @@ tools:
|
|||||||
-
|
-
|
||||||
scope: file
|
scope: file
|
||||||
command: php tests/phpcs_runner.php %pathname%
|
command: php tests/phpcs_runner.php %pathname%
|
||||||
|
filter:
|
||||||
|
excluded_paths: ["*/css/*", "css/*", "thirdparty/*", "*/jquery-changetracker/*", "parsers/HTML/BBCodeParser/*", "*/SSTemplateParser.php$", "docs/*", "*/images/*"]
|
||||||
|
@ -4,20 +4,20 @@
|
|||||||
* @subpackage testing
|
* @subpackage testing
|
||||||
*/
|
*/
|
||||||
class BehatFixtureFactory extends \FixtureFactory {
|
class BehatFixtureFactory extends \FixtureFactory {
|
||||||
public function createObject($name, $identifier, $data = null) {
|
public function createObject($name, $identifier, $data = null) {
|
||||||
if(!$data) $data = array();
|
if(!$data) $data = array();
|
||||||
|
|
||||||
// Copy identifier to some visible property unless its already defined.
|
// Copy identifier to some visible property unless its already defined.
|
||||||
// Exclude files, since they generate their own named based on the file path.
|
// Exclude files, since they generate their own named based on the file path.
|
||||||
if(!$name != 'File' && !is_subclass_of($name, 'File')) {
|
if(!$name != 'File' && !is_subclass_of($name, 'File')) {
|
||||||
foreach(array('Name', 'Title') as $fieldName) {
|
foreach(array('Name', 'Title') as $fieldName) {
|
||||||
if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
|
if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
|
||||||
$data[$fieldName] = $identifier;
|
$data[$fieldName] = $identifier;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::createObject($name, $identifier, $data);
|
return parent::createObject($name, $identifier, $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,9 @@ class CheckboxField_Readonly extends ReadonlyField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function Value() {
|
public function Value() {
|
||||||
return Convert::raw2xml($this->value ? _t('CheckboxField.YESANSWER', 'Yes') : _t('CheckboxField.NOANSWER', 'No'));
|
return Convert::raw2xml($this->value ?
|
||||||
|
_t('CheckboxField.YESANSWER', 'Yes') :
|
||||||
|
_t('CheckboxField.NOANSWER', 'No'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1157,7 +1157,7 @@ abstract class SS_Query implements Iterator {
|
|||||||
$result .= "<tr>";
|
$result .= "<tr>";
|
||||||
foreach($record as $k => $v) {
|
foreach($record as $k => $v) {
|
||||||
$result .= "<th>" . Convert::raw2xml($k) . "</th> ";
|
$result .= "<th>" . Convert::raw2xml($k) . "</th> ";
|
||||||
}
|
}
|
||||||
$result .= "</tr> \n";
|
$result .= "</tr> \n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1234,7 +1234,7 @@ abstract class SS_Query implements Iterator {
|
|||||||
*/
|
*/
|
||||||
public function valid() {
|
public function valid() {
|
||||||
if(!$this->queryHasBegun) $this->next();
|
if(!$this->queryHasBegun) $this->next();
|
||||||
return $this->currentRecord !== false;
|
return $this->currentRecord !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +15,7 @@ class Hierarchy extends DataExtension {
|
|||||||
* @var Int
|
* @var Int
|
||||||
*/
|
*/
|
||||||
protected $_cache_numChildren;
|
protected $_cache_numChildren;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @config
|
* @config
|
||||||
* @var integer The lower bounds for the amount of nodes to mark. If set, the logic will expand
|
* @var integer The lower bounds for the amount of nodes to mark. If set, the logic will expand
|
||||||
@ -113,7 +113,7 @@ class Hierarchy extends DataExtension {
|
|||||||
if($limitToMarked && $rootCall) {
|
if($limitToMarked && $rootCall) {
|
||||||
$this->markingFinished($numChildrenMethod);
|
$this->markingFinished($numChildrenMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($nodeCountCallback) {
|
if($nodeCountCallback) {
|
||||||
$nodeCountWarning = $nodeCountCallback($this->owner, $this->owner->$numChildrenMethod());
|
$nodeCountWarning = $nodeCountCallback($this->owner, $this->owner->$numChildrenMethod());
|
||||||
if($nodeCountWarning) return $nodeCountWarning;
|
if($nodeCountWarning) return $nodeCountWarning;
|
||||||
@ -154,9 +154,9 @@ class Hierarchy extends DataExtension {
|
|||||||
$output .= $nodeCountWarning;
|
$output .= $nodeCountWarning;
|
||||||
$child->markClosed();
|
$child->markClosed();
|
||||||
} else {
|
} else {
|
||||||
$output .= $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked, $childrenMethod,
|
$output .= $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked, $childrenMethod,
|
||||||
$numChildrenMethod, false, $nodeCountThreshold);
|
$numChildrenMethod, false, $nodeCountThreshold);
|
||||||
}
|
}
|
||||||
} elseif($child->isTreeOpened()) {
|
} elseif($child->isTreeOpened()) {
|
||||||
// Since we're not loading children, don't mark it as open either
|
// Since we're not loading children, don't mark it as open either
|
||||||
$child->markClosed();
|
$child->markClosed();
|
||||||
@ -455,7 +455,7 @@ class Hierarchy extends DataExtension {
|
|||||||
$id = $this->owner->ID;
|
$id = $this->owner->ID;
|
||||||
return isset(self::$treeOpened[$baseClass][$id]) ? self::$treeOpened[$baseClass][$id] : false;
|
return isset(self::$treeOpened[$baseClass][$id]) ? self::$treeOpened[$baseClass][$id] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of this DataObject's and all it's descendants IDs.
|
* Get a list of this DataObject's and all it's descendants IDs.
|
||||||
* @return int
|
* @return int
|
||||||
@ -495,7 +495,7 @@ class Hierarchy extends DataExtension {
|
|||||||
$this->_cache_children = $result->filterByCallback(function($item) {
|
$this->_cache_children = $result->filterByCallback(function($item) {
|
||||||
return $item->canView();
|
return $item->canView();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return $this->_cache_children;
|
return $this->_cache_children;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,7 +614,7 @@ class Hierarchy extends DataExtension {
|
|||||||
->exclude('ID', (int)$this->owner->ID);
|
->exclude('ID', (int)$this->owner->ID);
|
||||||
if (!$showAll && $this->owner->db('ShowInMenus')) {
|
if (!$showAll && $this->owner->db('ShowInMenus')) {
|
||||||
$staged = $staged->filter('ShowInMenus', 1);
|
$staged = $staged->filter('ShowInMenus', 1);
|
||||||
}
|
}
|
||||||
$this->owner->extend("augmentStageChildren", $staged, $showAll);
|
$this->owner->extend("augmentStageChildren", $staged, $showAll);
|
||||||
return $staged;
|
return $staged;
|
||||||
}
|
}
|
||||||
@ -640,7 +640,7 @@ class Hierarchy extends DataExtension {
|
|||||||
'Versioned.mode' => $onlyDeletedFromStage ? 'stage_unique' : 'stage',
|
'Versioned.mode' => $onlyDeletedFromStage ? 'stage_unique' : 'stage',
|
||||||
'Versioned.stage' => 'Live'
|
'Versioned.stage' => 'Live'
|
||||||
));
|
));
|
||||||
|
|
||||||
if(!$showAll) $children = $children->filter('ShowInMenus', 1);
|
if(!$showAll) $children = $children->filter('ShowInMenus', 1);
|
||||||
|
|
||||||
return $children;
|
return $children;
|
||||||
|
@ -31,7 +31,7 @@ class FeatureContext extends SilverStripeContext
|
|||||||
* Initializes context.
|
* Initializes context.
|
||||||
* Every scenario gets it's own context object.
|
* Every scenario gets it's own context object.
|
||||||
*
|
*
|
||||||
* @param array $parameters context parameters (set them up through behat.yml)
|
* @param array $parameters context parameters (set them up through behat.yml)
|
||||||
*/
|
*/
|
||||||
public function __construct(array $parameters)
|
public function __construct(array $parameters)
|
||||||
{
|
{
|
||||||
@ -47,22 +47,22 @@ class FeatureContext extends SilverStripeContext
|
|||||||
$this->useContext('FixtureContext', $fixtureContext);
|
$this->useContext('FixtureContext', $fixtureContext);
|
||||||
|
|
||||||
// Use blueprints to set user name from identifier
|
// Use blueprints to set user name from identifier
|
||||||
$factory = $fixtureContext->getFixtureFactory();
|
$factory = $fixtureContext->getFixtureFactory();
|
||||||
$blueprint = \Injector::inst()->create('FixtureBlueprint', 'Member');
|
$blueprint = \Injector::inst()->create('FixtureBlueprint', 'Member');
|
||||||
$blueprint->addCallback('beforeCreate', function($identifier, &$data, &$fixtures) {
|
$blueprint->addCallback('beforeCreate', function($identifier, &$data, &$fixtures) {
|
||||||
if(!isset($data['FirstName'])) $data['FirstName'] = $identifier;
|
if(!isset($data['FirstName'])) $data['FirstName'] = $identifier;
|
||||||
});
|
});
|
||||||
$factory->define('Member', $blueprint);
|
$factory->define('Member', $blueprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMinkParameters(array $parameters)
|
public function setMinkParameters(array $parameters)
|
||||||
{
|
{
|
||||||
parent::setMinkParameters($parameters);
|
parent::setMinkParameters($parameters);
|
||||||
|
|
||||||
if(isset($parameters['files_path'])) {
|
if(isset($parameters['files_path'])) {
|
||||||
$this->getSubcontext('FixtureContext')->setFilesPath($parameters['files_path']);
|
$this->getSubcontext('FixtureContext')->setFilesPath($parameters['files_path']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return FixtureFactory
|
* @return FixtureFactory
|
||||||
|
@ -246,10 +246,13 @@ class CmsUiContext extends BehatContext
|
|||||||
public function thePreviewContains($content)
|
public function thePreviewContains($content)
|
||||||
{
|
{
|
||||||
$driver = $this->getSession()->getDriver();
|
$driver = $this->getSession()->getDriver();
|
||||||
$driver->switchToIFrame('cms-preview-iframe');
|
// TODO Remove once we have native support in Mink and php-webdriver,
|
||||||
|
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
||||||
|
$origWindowName = $driver->getWebDriverSession()->window_handle();
|
||||||
|
|
||||||
|
$driver->switchToIFrame('cms-preview-iframe');
|
||||||
$this->getMainContext()->assertPageContainsText($content);
|
$this->getMainContext()->assertPageContainsText($content);
|
||||||
$driver->switchToWindow();
|
$driver->switchToWindow($origWindowName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -304,10 +307,13 @@ class CmsUiContext extends BehatContext
|
|||||||
public function thePreviewDoesNotContain($content)
|
public function thePreviewDoesNotContain($content)
|
||||||
{
|
{
|
||||||
$driver = $this->getSession()->getDriver();
|
$driver = $this->getSession()->getDriver();
|
||||||
|
// TODO Remove once we have native support in Mink and php-webdriver,
|
||||||
|
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
||||||
|
$origWindowName = $driver->getWebDriverSession()->window_handle();
|
||||||
|
|
||||||
$driver->switchToIFrame('cms-preview-iframe');
|
$driver->switchToIFrame('cms-preview-iframe');
|
||||||
|
|
||||||
$this->getMainContext()->assertPageNotContainsText($content);
|
$this->getMainContext()->assertPageNotContainsText($content);
|
||||||
$driver->switchToWindow();
|
$driver->switchToWindow($origWindowName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +130,8 @@ class HTTPTest extends SapphireTest {
|
|||||||
// background-image
|
// background-image
|
||||||
// Note that using /./ in urls is absolutely acceptable
|
// Note that using /./ in urls is absolutely acceptable
|
||||||
$test->assertEquals(
|
$test->assertEquals(
|
||||||
'<div style="background-image: url(\'http://www.silverstripe.org/./images/mybackground.gif\');">Content</div>',
|
'<div style="background-image: url(\'http://www.silverstripe.org/./images/mybackground.gif\');">'.
|
||||||
|
'Content</div>',
|
||||||
HTTP::absoluteURLs('<div style="background-image: url(\'./images/mybackground.gif\');">Content</div>')
|
HTTP::absoluteURLs('<div style="background-image: url(\'./images/mybackground.gif\');">Content</div>')
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -169,7 +170,8 @@ class HTTPTest extends SapphireTest {
|
|||||||
// background
|
// background
|
||||||
// Note that using /./ in urls is absolutely acceptable
|
// Note that using /./ in urls is absolutely acceptable
|
||||||
$test->assertEquals(
|
$test->assertEquals(
|
||||||
'<div background="http://www.silverstripe.org/./themes/silverstripe/images/nav-bg-repeat-2.png">SS Blog</div>',
|
'<div background="http://www.silverstripe.org/./themes/silverstripe/images/nav-bg-repeat-2.png">'.
|
||||||
|
'SS Blog</div>',
|
||||||
HTTP::absoluteURLs('<div background="./themes/silverstripe/images/nav-bg-repeat-2.png">SS Blog</div>')
|
HTTP::absoluteURLs('<div background="./themes/silverstripe/images/nav-bg-repeat-2.png">SS Blog</div>')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,11 +24,13 @@ class CoreTest extends SapphireTest {
|
|||||||
$user = getTempFolderUsername();
|
$user = getTempFolderUsername();
|
||||||
|
|
||||||
// A typical Windows location for where sites are stored on IIS
|
// A typical Windows location for where sites are stored on IIS
|
||||||
$this->assertEquals(sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project/' . $user,
|
$this->assertEquals(sys_get_temp_dir() .
|
||||||
|
'/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project/' . $user,
|
||||||
getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'));
|
getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'));
|
||||||
|
|
||||||
// A typical Mac OS X location for where sites are stored
|
// A typical Mac OS X location for where sites are stored
|
||||||
$this->assertEquals(sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project/' . $user,
|
$this->assertEquals(sys_get_temp_dir() .
|
||||||
|
'/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project/' . $user,
|
||||||
getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'));
|
getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'));
|
||||||
|
|
||||||
// A typical Linux location for where sites are stored
|
// A typical Linux location for where sites are stored
|
||||||
|
@ -12,14 +12,18 @@ if(!empty($_SERVER['argv'][1])) {
|
|||||||
|
|
||||||
$result = array('comments' => array());
|
$result = array('comments' => array());
|
||||||
|
|
||||||
// Run each sniff
|
$extension = pathinfo($path, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
// phpcs --encoding=utf-8 --standard=framework/tests/phpcs/tabs.xml
|
// Whitelist of extensions to check (default phpcs list)
|
||||||
run_sniff('tabs.xml', $path, $result);
|
if(in_array($extension, array('php', 'js', 'inc', 'css'))) {
|
||||||
|
// Run each sniff
|
||||||
|
|
||||||
// phpcs --encoding=utf-8 --tab-width=4 --standard=framework/tests/phpcs/ruleset.xml
|
// phpcs --encoding=utf-8 --standard=framework/tests/phpcs/tabs.xml
|
||||||
run_sniff('ruleset.xml', $path, $result, '--tab-width=4');
|
run_sniff('tabs.xml', $path, $result);
|
||||||
|
|
||||||
|
// phpcs --encoding=utf-8 --tab-width=4 --standard=framework/tests/phpcs/ruleset.xml
|
||||||
|
run_sniff('ruleset.xml', $path, $result, '--tab-width=4');
|
||||||
|
}
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
|
|
||||||
function run_sniff($standard, $path, array &$result, $extraFlags = '') {
|
function run_sniff($standard, $path, array &$result, $extraFlags = '') {
|
||||||
|
Loading…
Reference in New Issue
Block a user