mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
commit
0c859b8587
@ -3,3 +3,5 @@ tools:
|
||||
-
|
||||
scope: file
|
||||
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
|
||||
*/
|
||||
class BehatFixtureFactory extends \FixtureFactory {
|
||||
public function createObject($name, $identifier, $data = null) {
|
||||
if(!$data) $data = array();
|
||||
public function createObject($name, $identifier, $data = null) {
|
||||
if(!$data) $data = array();
|
||||
|
||||
// Copy identifier to some visible property unless its already defined.
|
||||
// Exclude files, since they generate their own named based on the file path.
|
||||
if(!$name != 'File' && !is_subclass_of($name, 'File')) {
|
||||
foreach(array('Name', 'Title') as $fieldName) {
|
||||
if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
|
||||
$data[$fieldName] = $identifier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Copy identifier to some visible property unless its already defined.
|
||||
// Exclude files, since they generate their own named based on the file path.
|
||||
if(!$name != 'File' && !is_subclass_of($name, 'File')) {
|
||||
foreach(array('Name', 'Title') as $fieldName) {
|
||||
if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
|
||||
$data[$fieldName] = $identifier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent::createObject($name, $identifier, $data);
|
||||
}
|
||||
}
|
||||
return parent::createObject($name, $identifier, $data);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,9 @@ class CheckboxField_Readonly extends ReadonlyField {
|
||||
}
|
||||
|
||||
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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1136,7 +1136,7 @@ abstract class SS_Query implements Iterator {
|
||||
$result .= "<tr>";
|
||||
foreach($record as $k => $v) {
|
||||
$result .= "<th>" . Convert::raw2xml($k) . "</th> ";
|
||||
}
|
||||
}
|
||||
$result .= "</tr> \n";
|
||||
}
|
||||
|
||||
@ -1213,7 +1213,7 @@ abstract class SS_Query implements Iterator {
|
||||
*/
|
||||
public function valid() {
|
||||
if(!$this->queryHasBegun) $this->next();
|
||||
return $this->currentRecord !== false;
|
||||
return $this->currentRecord !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,8 +77,8 @@ class Hierarchy extends DataExtension {
|
||||
* @param int $nodeCountThreshold The lower bounds for the amount of nodes to mark. If set, the logic will expand
|
||||
* nodes until it eaches at least this number, and then stops. Root nodes will always
|
||||
* show regardless of this settting. Further nodes can be lazy-loaded via ajax.
|
||||
* This isn't a hard limit. Example: On a value of 10, with 20 root nodes, each having
|
||||
* 30 children, the actual node count will be 50 (all root nodes plus first expanded child).
|
||||
* This isn't a hard limit. Example: On a value of 10, with 20 root nodes, each having 30
|
||||
* children, the actual node count will be 50 (all root nodes plus first expanded child).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -31,7 +31,7 @@ class FeatureContext extends SilverStripeContext
|
||||
* Initializes context.
|
||||
* 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)
|
||||
{
|
||||
@ -47,22 +47,22 @@ class FeatureContext extends SilverStripeContext
|
||||
$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);
|
||||
$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);
|
||||
}
|
||||
|
||||
public function setMinkParameters(array $parameters)
|
||||
{
|
||||
parent::setMinkParameters($parameters);
|
||||
|
||||
if(isset($parameters['files_path'])) {
|
||||
$this->getSubcontext('FixtureContext')->setFilesPath($parameters['files_path']);
|
||||
}
|
||||
}
|
||||
{
|
||||
parent::setMinkParameters($parameters);
|
||||
|
||||
if(isset($parameters['files_path'])) {
|
||||
$this->getSubcontext('FixtureContext')->setFilesPath($parameters['files_path']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FixtureFactory
|
||||
|
@ -130,7 +130,8 @@ class HTTPTest extends SapphireTest {
|
||||
// background-image
|
||||
// Note that using /./ in urls is absolutely acceptable
|
||||
$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>')
|
||||
);
|
||||
|
||||
@ -169,7 +170,8 @@ class HTTPTest extends SapphireTest {
|
||||
// background
|
||||
// Note that using /./ in urls is absolutely acceptable
|
||||
$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>')
|
||||
);
|
||||
|
||||
|
@ -22,11 +22,13 @@ class CoreTest extends SapphireTest {
|
||||
$user = getTempFolderUsername();
|
||||
|
||||
// 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'));
|
||||
|
||||
// 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'));
|
||||
|
||||
// A typical Linux location for where sites are stored
|
||||
|
@ -12,14 +12,18 @@ if(!empty($_SERVER['argv'][1])) {
|
||||
|
||||
$result = array('comments' => array());
|
||||
|
||||
// Run each sniff
|
||||
$extension = pathinfo($path, PATHINFO_EXTENSION);
|
||||
|
||||
// phpcs --encoding=utf-8 --standard=framework/tests/phpcs/tabs.xml
|
||||
run_sniff('tabs.xml', $path, $result);
|
||||
// Whitelist of extensions to check (default phpcs list)
|
||||
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
|
||||
run_sniff('ruleset.xml', $path, $result, '--tab-width=4');
|
||||
// phpcs --encoding=utf-8 --standard=framework/tests/phpcs/tabs.xml
|
||||
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);
|
||||
|
||||
function run_sniff($standard, $path, array &$result, $extraFlags = '') {
|
||||
|
Loading…
Reference in New Issue
Block a user