mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #275 from halkyon/e_strict_support
First round of fixes for E_STRICT compliance
This commit is contained in:
commit
f0ee711f52
@ -322,7 +322,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
|||||||
SSViewer::set_theme(null);
|
SSViewer::set_theme(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRequest($request, DataModel $model) {
|
function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
|
||||||
$title = $this->Title();
|
$title = $this->Title();
|
||||||
|
|
||||||
$response = parent::handleRequest($request, $model);
|
$response = parent::handleRequest($request, $model);
|
||||||
|
@ -113,7 +113,7 @@ abstract class ModelAdmin extends LeftAndMain {
|
|||||||
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/ModelAdmin.js');
|
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/ModelAdmin.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEditForm($id = null) {
|
function getEditForm($id = null, $fields = null) {
|
||||||
$list = $this->getList();
|
$list = $this->getList();
|
||||||
$exportButton = new GridFieldExportButton();
|
$exportButton = new GridFieldExportButton();
|
||||||
$exportButton->setExportColumns($this->getExportFields());
|
$exportButton->setExportColumns($this->getExportFields());
|
||||||
|
@ -319,7 +319,7 @@ class File extends DataObject {
|
|||||||
* Returns the fields to power the edit screen of files in the CMS
|
* Returns the fields to power the edit screen of files in the CMS
|
||||||
* @return FieldList
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
// Preview
|
// Preview
|
||||||
if($this instanceof Image) {
|
if($this instanceof Image) {
|
||||||
$formattedImage = $this->getFormattedImage('SetWidth', Image::$asset_preview_width);
|
$formattedImage = $this->getFormattedImage('SetWidth', Image::$asset_preview_width);
|
||||||
@ -816,8 +816,8 @@ class File extends DataObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function flushCache() {
|
public function flushCache($persistant = true) {
|
||||||
parent::flushCache();
|
parent::flushCache($persistant);
|
||||||
|
|
||||||
self::$cache_file_fields = null;
|
self::$cache_file_fields = null;
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ class Folder extends File {
|
|||||||
* You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension}
|
* You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension}
|
||||||
* and implemeting updateCMSFields(FieldList $fields) on that extension.
|
* and implemeting updateCMSFields(FieldList $fields) on that extension.
|
||||||
*/
|
*/
|
||||||
function getCMSFields() {
|
function getCMSFields($param = null) {
|
||||||
// Hide field on root level, which can't be renamed
|
// Hide field on root level, which can't be renamed
|
||||||
if(!$this->ID || $this->ID === "root") {
|
if(!$this->ID || $this->ID === "root") {
|
||||||
$titleField = new HiddenField("Name");
|
$titleField = new HiddenField("Name");
|
||||||
|
@ -343,7 +343,7 @@ class TreeDropdownField extends FormField {
|
|||||||
class TreeDropdownField_Readonly extends TreeDropdownField {
|
class TreeDropdownField_Readonly extends TreeDropdownField {
|
||||||
protected $readonly = true;
|
protected $readonly = true;
|
||||||
|
|
||||||
function Field() {
|
function Field($properties = array()) {
|
||||||
$fieldName = $this->labelField;
|
$fieldName = $this->labelField;
|
||||||
if($this->value) {
|
if($this->value) {
|
||||||
$keyObj = $this->objectForKey($this->value);
|
$keyObj = $this->objectForKey($this->value);
|
||||||
|
@ -90,7 +90,7 @@ class Aggregate extends ViewableData {
|
|||||||
* This gets the aggregate function
|
* This gets the aggregate function
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function XML_val($name, $args) {
|
public function XML_val($name, $args = null, $cache = false) {
|
||||||
$func = strtoupper( strpos($name, 'get') === 0 ? substr($name, 3) : $name );
|
$func = strtoupper( strpos($name, 'get') === 0 ? substr($name, 3) : $name );
|
||||||
$attribute = $args ? $args[0] : 'ID';
|
$attribute = $args ? $args[0] : 'ID';
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ abstract class DataExtension extends Extension {
|
|||||||
* @return array Returns a map where the keys are db, has_one, etc, and
|
* @return array Returns a map where the keys are db, has_one, etc, and
|
||||||
* the values are additional fields/relations to be defined.
|
* the values are additional fields/relations to be defined.
|
||||||
*/
|
*/
|
||||||
function extraStatics($class=null, $extension=null) {
|
function extraStatics($class = null, $extension = null) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2654,7 +2654,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* When false will just clear session-local cached data
|
* When false will just clear session-local cached data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function flushCache($persistant=true) {
|
public function flushCache($persistant = true) {
|
||||||
if($persistant) Aggregate::flushCache($this->class);
|
if($persistant) Aggregate::flushCache($this->class);
|
||||||
|
|
||||||
if($this->class == 'DataObject') {
|
if($this->class == 'DataObject') {
|
||||||
|
@ -675,11 +675,11 @@ class Hierarchy extends DataExtension {
|
|||||||
self::$treeOpened = array();
|
self::$treeOpened = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
public static function reset() {
|
||||||
self::$marked = array();
|
self::$marked = array();
|
||||||
self::$expanded = array();
|
self::$expanded = array();
|
||||||
self::$treeOpened = array();
|
self::$treeOpened = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ class Image extends File {
|
|||||||
parent::defineMethods();
|
parent::defineMethods();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
|
|
||||||
$urlLink = "<div class='field readonly'>";
|
$urlLink = "<div class='field readonly'>";
|
||||||
$urlLink .= "<label class='left'>"._t('AssetTableField.URL','URL')."</label>";
|
$urlLink .= "<label class='left'>"._t('AssetTableField.URL','URL')."</label>";
|
||||||
|
@ -554,7 +554,7 @@ class SQLQuery {
|
|||||||
* Return the number of rows in this query if the limit were removed. Useful in paged data sets.
|
* Return the number of rows in this query if the limit were removed. Useful in paged data sets.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function unlimitedRowCount( $column = null) {
|
function unlimitedRowCount($column = null) {
|
||||||
// we can't clear the select if we're relying on its output by a HAVING clause
|
// we can't clear the select if we're relying on its output by a HAVING clause
|
||||||
if(count($this->having)) {
|
if(count($this->having)) {
|
||||||
$records = $this->execute();
|
$records = $this->execute();
|
||||||
|
@ -132,7 +132,7 @@ class Versioned extends DataExtension {
|
|||||||
* Augment the the SQLQuery that is created by the DataQuery
|
* Augment the the SQLQuery that is created by the DataQuery
|
||||||
* @todo Should this all go into VersionedDataQuery?
|
* @todo Should this all go into VersionedDataQuery?
|
||||||
*/
|
*/
|
||||||
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery) {
|
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) {
|
||||||
$baseTable = ClassInfo::baseDataClass($dataQuery->dataClass());
|
$baseTable = ClassInfo::baseDataClass($dataQuery->dataClass());
|
||||||
|
|
||||||
switch($dataQuery->getQueryParam('Versioned.mode')) {
|
switch($dataQuery->getQueryParam('Versioned.mode')) {
|
||||||
|
@ -41,7 +41,7 @@ class Currency extends Decimal {
|
|||||||
else return $val;
|
else return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setValue($value) {
|
function setValue($value, $record = null) {
|
||||||
$matches = null;
|
$matches = null;
|
||||||
if(is_numeric($value)) {
|
if(is_numeric($value)) {
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
class Date extends DBField {
|
class Date extends DBField {
|
||||||
|
|
||||||
function setValue($value) {
|
function setValue($value, $record = null) {
|
||||||
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
||||||
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
|
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
|
||||||
$this->value = null;
|
$this->value = null;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
class SS_Datetime extends Date {
|
class SS_Datetime extends Date {
|
||||||
|
|
||||||
function setValue($value) {
|
function setValue($value, $record = null) {
|
||||||
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
||||||
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
|
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
|
||||||
$this->value = null;
|
$this->value = null;
|
||||||
|
@ -136,7 +136,7 @@ class HTMLText extends Text {
|
|||||||
return new HtmlEditorField($this->name, $title);
|
return new HtmlEditorField($this->name, $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scaffoldSearchField($title = null) {
|
public function scaffoldSearchField($title = null, $params = null) {
|
||||||
return new TextField($this->name, $title);
|
return new TextField($this->name, $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,8 @@ abstract class Authenticator extends Object {
|
|||||||
* @return bool|Member Returns FALSE if authentication fails, otherwise
|
* @return bool|Member Returns FALSE if authentication fails, otherwise
|
||||||
* the member object
|
* the member object
|
||||||
*/
|
*/
|
||||||
public abstract static function authenticate($RAW_data,
|
public static function authenticate($RAW_data, Form $form = null) {
|
||||||
Form $form = null);
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that creates the login form for this authentication method
|
* Method that creates the login form for this authentication method
|
||||||
@ -49,7 +48,8 @@ abstract class Authenticator extends Object {
|
|||||||
* @return Form Returns the login form to use with this authentication
|
* @return Form Returns the login form to use with this authentication
|
||||||
* method
|
* method
|
||||||
*/
|
*/
|
||||||
public abstract static function get_login_form(Controller $controller);
|
public static function get_login_form(Controller $controller) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +57,8 @@ abstract class Authenticator extends Object {
|
|||||||
*
|
*
|
||||||
* @return string Returns the name of the authentication method.
|
* @return string Returns the name of the authentication method.
|
||||||
*/
|
*/
|
||||||
public abstract static function get_name();
|
public static function get_name() {
|
||||||
|
}
|
||||||
|
|
||||||
public static function register($authenticator) {
|
public static function register($authenticator) {
|
||||||
self::register_authenticator($authenticator);
|
self::register_authenticator($authenticator);
|
||||||
|
@ -59,7 +59,7 @@ class Group extends DataObject {
|
|||||||
*
|
*
|
||||||
* @return FieldList
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function getCMSFields() {
|
public function getCMSFields($params = null) {
|
||||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
|
@ -1084,7 +1084,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
* @return FieldList Return a FieldList of fields that would appropriate for
|
* @return FieldList Return a FieldList of fields that would appropriate for
|
||||||
* editing this member.
|
* editing this member.
|
||||||
*/
|
*/
|
||||||
public function getCMSFields() {
|
public function getCMSFields($params = null) {
|
||||||
require_once('Zend/Date.php');
|
require_once('Zend/Date.php');
|
||||||
|
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
@ -33,8 +33,8 @@ class PermissionRole extends DataObject {
|
|||||||
|
|
||||||
static $plural_name = 'Roles';
|
static $plural_name = 'Roles';
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
|
|
||||||
$fields->removeFieldFromTab('Root', 'Codes');
|
$fields->removeFieldFromTab('Root', 'Codes');
|
||||||
$fields->removeFieldFromTab('Root', 'Groups');
|
$fields->removeFieldFromTab('Root', 'Groups');
|
||||||
|
@ -329,7 +329,7 @@ class RequestHandlingTest_Controller extends Controller implements TestOnly {
|
|||||||
$this->httpError(404, 'This page does not exist.');
|
$this->httpError(404, 'This page does not exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getViewer(){
|
public function getViewer($action) {
|
||||||
return new SSViewer('BlankPage');
|
return new SSViewer('BlankPage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,7 +384,7 @@ class RequestHandlingTest_FormActionController extends Controller {
|
|||||||
return 'formactionInAllowedActions';
|
return 'formactionInAllowedActions';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getViewer(){
|
public function getViewer($action = null) {
|
||||||
return new SSViewer('BlankPage');
|
return new SSViewer('BlankPage');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,11 +128,13 @@ class FormScaffolderTest_ArticleExtension extends DataExtension implements TestO
|
|||||||
static $db = array(
|
static $db = array(
|
||||||
'ExtendedField' => 'Varchar'
|
'ExtendedField' => 'Varchar'
|
||||||
);
|
);
|
||||||
function updateCMSFields(&$fields) {
|
|
||||||
|
function updateCMSFields(FieldList $fields) {
|
||||||
$fields->addFieldToTab('Root.Main',
|
$fields->addFieldToTab('Root.Main',
|
||||||
new TextField('AddedExtensionField')
|
new TextField('AddedExtensionField')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataObject::add_extension('FormScaffolderTest_Article', 'FormScaffolderTest_ArticleExtension');
|
DataObject::add_extension('FormScaffolderTest_Article', 'FormScaffolderTest_ArticleExtension');
|
||||||
|
@ -468,7 +468,7 @@ class FormTest_Controller extends Controller implements TestOnly {
|
|||||||
return $this->redirectBack();
|
return $this->redirectBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getViewer(){
|
function getViewer($action = null) {
|
||||||
return new SSViewer('BlankPage');
|
return new SSViewer('BlankPage');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +505,7 @@ class FormTest_ControllerWithSecurityToken extends Controller implements TestOnl
|
|||||||
return $this->redirectBack();
|
return $this->redirectBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getViewer(){
|
function getViewer($action = null) {
|
||||||
return new SSViewer('BlankPage');
|
return new SSViewer('BlankPage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,8 @@ class GridFieldDetailFormTest_Person extends DataObject implements TestOnly {
|
|||||||
'Categories' => 'GridFieldDetailFormTest_Category'
|
'Categories' => 'GridFieldDetailFormTest_Category'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
// TODO No longer necessary once FormScaffolder uses GridField
|
// TODO No longer necessary once FormScaffolder uses GridField
|
||||||
$fields->replaceField('Categories',
|
$fields->replaceField('Categories',
|
||||||
Object::create('GridField', 'Categories', 'Categories',
|
Object::create('GridField', 'Categories', 'Categories',
|
||||||
@ -162,8 +162,8 @@ class GridFieldDetailFormTest_PeopleGroup extends DataObject implements TestOnly
|
|||||||
'People' => 'GridFieldDetailFormTest_Person'
|
'People' => 'GridFieldDetailFormTest_Person'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
// TODO No longer necessary once FormScaffolder uses GridField
|
// TODO No longer necessary once FormScaffolder uses GridField
|
||||||
$fields->replaceField('People',
|
$fields->replaceField('People',
|
||||||
Object::create('GridField', 'People', 'People',
|
Object::create('GridField', 'People', 'People',
|
||||||
@ -184,8 +184,8 @@ class GridFieldDetailFormTest_Category extends DataObject implements TestOnly {
|
|||||||
'People' => 'GridFieldDetailFormTest_Person'
|
'People' => 'GridFieldDetailFormTest_Person'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
// TODO No longer necessary once FormScaffolder uses GridField
|
// TODO No longer necessary once FormScaffolder uses GridField
|
||||||
$fields->replaceField('People',
|
$fields->replaceField('People',
|
||||||
Object::create('GridField', 'People', 'People',
|
Object::create('GridField', 'People', 'People',
|
||||||
|
@ -567,21 +567,21 @@ static $many_many = array(
|
|||||||
|
|
||||||
class UploadFieldTest_FileExtension extends DataExtension implements TestOnly {
|
class UploadFieldTest_FileExtension extends DataExtension implements TestOnly {
|
||||||
|
|
||||||
function extraStatics() {
|
function extraStatics($class = null, $extension = null) {
|
||||||
return array(
|
return array(
|
||||||
'has_one' => array('Record' => 'UploadFieldTest_Record')
|
'has_one' => array('Record' => 'UploadFieldTest_Record')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function canDelete() {
|
function canDelete($member = null) {
|
||||||
if($this->owner->Name == 'nodelete.txt') return false;
|
if($this->owner->Name == 'nodelete.txt') return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function canEdit() {
|
function canEdit($member = null) {
|
||||||
if($this->owner->Name == 'noedit.txt') return false;
|
if($this->owner->Name == 'noedit.txt') return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function canView() {
|
function canView($member = null) {
|
||||||
if($this->owner->Name == 'noview.txt') return false;
|
if($this->owner->Name == 'noview.txt') return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,13 +73,15 @@ class AggregateTest extends SapphireTest {
|
|||||||
* Test basic aggregation on a passed type
|
* Test basic aggregation on a passed type
|
||||||
*/
|
*/
|
||||||
function testTypeSpecifiedAggregate() {
|
function testTypeSpecifiedAggregate() {
|
||||||
|
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
||||||
|
|
||||||
// Template style access
|
// Template style access
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9);
|
$this->assertEquals($foo->Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9);
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3);
|
$this->assertEquals($foo->Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3);
|
||||||
|
|
||||||
// PHP style access
|
// PHP style access
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
$this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Fab'), 3);
|
$this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Fab'), 3);
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
@ -106,13 +108,15 @@ class AggregateTest extends SapphireTest {
|
|||||||
* @return unknown_type
|
* @return unknown_type
|
||||||
*/
|
*/
|
||||||
function testBaseFieldAggregate() {
|
function testBaseFieldAggregate() {
|
||||||
|
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('LastEdited')),
|
$this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('LastEdited')),
|
||||||
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"LastEdited" DESC')->LastEdited)
|
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"LastEdited" DESC')->LastEdited)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('Created')),
|
$this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('Created')),
|
||||||
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"Created" DESC')->Created)
|
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"Created" DESC')->Created)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -122,13 +126,14 @@ class AggregateTest extends SapphireTest {
|
|||||||
* Test aggregation takes place on the passed type & it's children only
|
* Test aggregation takes place on the passed type & it's children only
|
||||||
*/
|
*/
|
||||||
function testChildAggregate() {
|
function testChildAggregate() {
|
||||||
|
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
||||||
|
|
||||||
// For base classes, aggregate is calculcated on it and all children classes
|
// For base classes, aggregate is calculcated on it and all children classes
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
$this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
||||||
|
|
||||||
// For subclasses, aggregate is calculated for that subclass and it's children only
|
// For subclasses, aggregate is calculated for that subclass and it's children only
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
$this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
$this->assertEquals($foo->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||||
|
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
@ -145,35 +150,35 @@ class AggregateTest extends SapphireTest {
|
|||||||
* Test cache is correctly flushed on write
|
* Test cache is correctly flushed on write
|
||||||
*/
|
*/
|
||||||
function testCacheFlushing() {
|
function testCacheFlushing() {
|
||||||
|
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
||||||
|
$fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
|
||||||
|
|
||||||
// For base classes, aggregate is calculcated on it and all children classes
|
// For base classes, aggregate is calculcated on it and all children classes
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
$this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
||||||
|
|
||||||
// For subclasses, aggregate is calculated for that subclass and it's children only
|
// For subclasses, aggregate is calculated for that subclass and it's children only
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
$this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
$this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||||
|
|
||||||
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
|
||||||
$foo->Foo = 12;
|
$foo->Foo = 12;
|
||||||
$foo->write();
|
$foo->write();
|
||||||
|
|
||||||
// For base classes, aggregate is calculcated on it and all children classes
|
// For base classes, aggregate is calculcated on it and all children classes
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 12);
|
$this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 12);
|
||||||
|
|
||||||
// For subclasses, aggregate is calculated for that subclass and it's children only
|
// For subclasses, aggregate is calculated for that subclass and it's children only
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
$this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
$this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||||
|
|
||||||
$fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
|
|
||||||
$fab->Foo = 15;
|
$fab->Foo = 15;
|
||||||
$fab->write();
|
$fab->write();
|
||||||
|
|
||||||
// For base classes, aggregate is calculcated on it and all children classes
|
// For base classes, aggregate is calculcated on it and all children classes
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 15);
|
$this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 15);
|
||||||
|
|
||||||
// For subclasses, aggregate is calculated for that subclass and it's children only
|
// For subclasses, aggregate is calculated for that subclass and it's children only
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 15);
|
$this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 15);
|
||||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
$this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ class DataDifferencerTest_Object extends DataObject implements TestOnly {
|
|||||||
'HasOneRelation' => 'DataDifferencerTest_HasOneRelationObject'
|
'HasOneRelation' => 'DataDifferencerTest_HasOneRelationObject'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
$choices = array(
|
$choices = array(
|
||||||
'a' => 'a',
|
'a' => 'a',
|
||||||
'b' => 'b',
|
'b' => 'b',
|
||||||
|
@ -132,7 +132,7 @@ class GroupTest extends FunctionalTest {
|
|||||||
|
|
||||||
class GroupTest_Member extends Member implements TestOnly {
|
class GroupTest_Member extends Member implements TestOnly {
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$groups = DataObject::get('Group');
|
$groups = DataObject::get('Group');
|
||||||
$groupsMap = ($groups) ? $groups->map() : false;
|
$groupsMap = ($groups) ? $groups->map() : false;
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
|
@ -591,29 +591,29 @@ class MemberTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
class MemberTest_ViewingAllowedExtension extends DataExtension implements TestOnly {
|
class MemberTest_ViewingAllowedExtension extends DataExtension implements TestOnly {
|
||||||
|
|
||||||
public function canView() {
|
public function canView($member = null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
class MemberTest_ViewingDeniedExtension extends DataExtension implements TestOnly {
|
class MemberTest_ViewingDeniedExtension extends DataExtension implements TestOnly {
|
||||||
|
|
||||||
public function canView() {
|
public function canView($member = null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
class MemberTest_EditingAllowedDeletingDeniedExtension extends DataExtension implements TestOnly {
|
class MemberTest_EditingAllowedDeletingDeniedExtension extends DataExtension implements TestOnly {
|
||||||
|
|
||||||
public function canView() {
|
public function canView($member = null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canEdit() {
|
public function canEdit($member = null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canDelete() {
|
public function canDelete($member = null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,7 +930,7 @@ class SSViewerTestFixture extends ViewableData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function XML_val($fieldName, $arguments = null) {
|
function XML_val($fieldName, $arguments = null, $cache = false) {
|
||||||
if(preg_match('/NotSet/i', $fieldName)) {
|
if(preg_match('/NotSet/i', $fieldName)) {
|
||||||
return '';
|
return '';
|
||||||
} else if(preg_match('/Raw/i', $fieldName)) {
|
} else if(preg_match('/Raw/i', $fieldName)) {
|
||||||
@ -940,7 +940,7 @@ class SSViewerTestFixture extends ViewableData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasValue($fieldName, $arguments = null) {
|
function hasValue($fieldName, $arguments = null, $cache = true) {
|
||||||
return (bool)$this->XML_val($fieldName, $arguments);
|
return (bool)$this->XML_val($fieldName, $arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user