Compare commits

..

3 Commits

Author SHA1 Message Date
Steve Boyd
6af66030fb
Merge 00fd636f71 into 666b4094b4 2024-10-17 04:41:43 +00:00
Steve Boyd
00fd636f71 NEW Validate DBFields 2024-10-17 17:41:36 +13:00
Guy Sartorelli
666b4094b4
API Improve type safety for Controller::join_links() (#11426) 2024-10-17 17:15:24 +13:00
3 changed files with 13 additions and 5 deletions

View File

@ -627,9 +627,8 @@ class Controller extends RequestHandler implements TemplateGlobalProvider
* Caution: All parameters are expected to be URI-encoded already.
*
* @param string|array $arg One or more link segments, or list of link segments as an array
* @return string
*/
public static function join_links($arg = null)
public static function join_links($arg = null): string
{
if (func_num_args() === 1 && is_array($arg)) {
$args = $arg;

View File

@ -179,10 +179,18 @@ class DBEnumTest extends SapphireTest
public function testSaveDefaultValue()
{
$obj = new FieldType\DBEnumTestObject();
$obj->Colour = null;
$id = $obj->write();
// Fetch the object from the database
$colour = FieldType\DBEnumTestObject::get()->byID($id)->Colour;
$this->assertEquals('Red', $colour);
$obj = FieldType\DBEnumTestObject::get()->byID($id);
$this->assertEquals('Red', $obj->Colour);
$this->assertEquals('Blue', $obj->ColourWithDefault);
// Set value to null and save
$obj->Colour = null;
$obj->ColourWithDefault = null;
$obj->write();
// Fetch the object from the database
$obj = FieldType\DBEnumTestObject::get()->byID($id);
$this->assertEquals(null, $obj->Colour);
$this->assertEquals(null, $obj->ColourWithDefault);
}
}

View File

@ -11,5 +11,6 @@ class DBEnumTestObject extends DataObject
private static $db = [
'Colour' => 'Enum("Red,Blue,Green")',
'ColourWithDefault' => 'Enum("Red,Blue,Green","Blue")',
];
}