2019-02-21 23:08:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\ORM\Tests\DataObjectTest;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\ORM\DataObject;
|
|
|
|
use SilverStripe\ORM\ManyManyList;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a fake DB field specifically design to test dynamic value assignment
|
|
|
|
* @property boolean $StaticScalarOnlyField
|
|
|
|
* @property boolean $DynamicScalarOnlyField
|
|
|
|
* @property boolean $DynamicField
|
|
|
|
* @method ManyManyList MockManyMany
|
|
|
|
*/
|
|
|
|
class MockDynamicAssignmentDataObject extends DataObject implements TestOnly
|
|
|
|
{
|
|
|
|
|
|
|
|
private static $table_name = 'MockDynamicAssignmentDataObject';
|
|
|
|
|
|
|
|
private static $db = [
|
|
|
|
// This field only emits scalar value and will save
|
|
|
|
'StaticScalarOnlyField' => MockDynamicAssignmentDBField::class . '(1,0)',
|
|
|
|
|
|
|
|
// This field tries to emit dynamic assignment but will fail because of scalar only
|
|
|
|
'DynamicScalarOnlyField' => MockDynamicAssignmentDBField::class . '(1,1)',
|
|
|
|
|
2021-12-13 09:05:33 +01:00
|
|
|
// This field does dynamic assignment and will pass
|
2019-02-21 23:08:43 +01:00
|
|
|
'DynamicField' => MockDynamicAssignmentDBField::class . '(0,1)',
|
|
|
|
];
|
|
|
|
|
|
|
|
private static $many_many = [
|
2019-02-26 23:14:47 +01:00
|
|
|
'MockManyMany' => self::class,
|
2019-02-21 23:08:43 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
private static $belongs_many_many = [
|
2019-02-26 23:14:47 +01:00
|
|
|
'MockBelongsManyMany' => self::class,
|
2019-02-21 23:08:43 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
private static $many_many_extraFields = [
|
|
|
|
'MockManyMany' => [
|
|
|
|
// This field only emits scalar value and will save
|
|
|
|
'ManyManyStaticScalarOnlyField' => MockDynamicAssignmentDBField::class . '(1,0)',
|
|
|
|
|
|
|
|
// This field tries to emit dynamic assignment but will fail because of scalar only
|
|
|
|
'ManyManyDynamicScalarOnlyField' => MockDynamicAssignmentDBField::class . '(1,1)',
|
|
|
|
|
2021-12-13 09:05:33 +01:00
|
|
|
// This field does dynamic assignment and will pass
|
2019-02-21 23:08:43 +01:00
|
|
|
'ManyManyDynamicField' => MockDynamicAssignmentDBField::class . '(0,1)',
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|