silverstripe-framework/tests/php/ORM/DBFieldTest/TestDbField.php
Guy Sartorelli e2e32317d6
API Move various classes to more appropriate namespaces (#11370)
Also rename ViewableData to ModelData ahead of the template layer
lift-and-shift
2024-09-23 14:31:50 +12:00

44 lines
1.2 KiB
PHP

<?php
namespace SilverStripe\ORM\Tests\DBFieldTest;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\Model\ModelData;
class TestDbField extends DBField implements TestOnly
{
public function requireField(): void
{
// Basically the same as DBVarchar but we don't want to test with DBVarchar in case something
// changes in that class eventually.
$charset = Config::inst()->get(MySQLDatabase::class, 'charset');
$collation = Config::inst()->get(MySQLDatabase::class, 'collation');
$parts = [
'datatype' => 'varchar',
'precision' => 255,
'character set' => $charset,
'collate' => $collation,
'arrayValue' => $this->arrayValue
];
$values = [
'type' => 'varchar',
'parts' => $parts
];
DB::require_field($this->tableName, $this->name, $values);
}
public $saveIntoCalledCount = 0;
public function saveInto(ModelData $model): void
{
$this->saveIntoCalledCount++;
parent::saveInto($model);
}
}