Merge pull request #48008 from nextcloud/fix/entity/strict-types

pull/47998/head
Kate 2024-09-16 11:08:35 +07:00 committed by GitHub
commit 8a32881633
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

@ -54,9 +54,8 @@ abstract class Entity {
$instance = new static();
foreach ($row as $key => $value) {
$prop = ucfirst($instance->columnToProperty($key));
$setter = 'set' . $prop;
$instance->$setter($value);
$prop = $instance->columnToProperty($key);
$instance->setter($prop, [$value]);
}
$instance->resetUpdatedFields();

@ -27,7 +27,6 @@ use PHPUnit\Framework\Constraint\IsType;
* @method void setTrueOrFalse(bool $trueOrFalse)
* @method bool getAnotherBool()
* @method bool isAnotherBool()
* @method void setAnotherBool(bool $anotherBool)
* @method string getLongText()
* @method void setLongText(string $longText)
*/
@ -47,6 +46,10 @@ class TestEntity extends Entity {
$this->addType('longText', 'blob');
$this->name = $name;
}
public function setAnotherBool(bool $anotherBool): void {
parent::setAnotherBool($anotherBool);
}
}
@ -71,12 +74,14 @@ class EntityTest extends \Test\TestCase {
public function testFromRow(): void {
$row = [
'pre_name' => 'john',
'email' => 'john@something.com'
'email' => 'john@something.com',
'another_bool' => 1,
];
$this->entity = TestEntity::fromRow($row);
$this->assertEquals($row['pre_name'], $this->entity->getPreName());
$this->assertEquals($row['email'], $this->entity->getEmail());
$this->assertEquals($row['another_bool'], $this->entity->getAnotherBool());
}