diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2025-02-15 21:45:59 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2025-06-29 13:28:23 +0200 |
commit | 9884bb7f1d0a2e65b32f517b55550a3123f3e2c3 (patch) | |
tree | 85217f25a14f82bf95bb5786b5e4d5b900368727 | |
parent | a17601643b1e9f5f6505487ca5e761f1e6073656 (diff) | |
download | volse-hubzilla-add-registration-entity-class.tar.gz volse-hubzilla-add-registration-entity-class.tar.bz2 volse-hubzilla-add-registration-entity-class.zip |
Add Registration::get methodadd-registration-entity-class
-rw-r--r-- | Zotlabs/Entity/Registration.php | 9 | ||||
-rw-r--r-- | tests/unit/Entity/RegistrationTest.php | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/Zotlabs/Entity/Registration.php b/Zotlabs/Entity/Registration.php index 8f3c87350..e79d0ab5f 100644 --- a/Zotlabs/Entity/Registration.php +++ b/Zotlabs/Entity/Registration.php @@ -119,6 +119,15 @@ class Registration return null; } + public static function get(int $id): ?self + { + return static::by_query([ + 'where' => [ + 'reg_id' => $id, + ] + ]); + } + /** * Find a registration by it's hash. * diff --git a/tests/unit/Entity/RegistrationTest.php b/tests/unit/Entity/RegistrationTest.php index 31e421914..3e4412545 100644 --- a/tests/unit/Entity/RegistrationTest.php +++ b/tests/unit/Entity/RegistrationTest.php @@ -39,6 +39,18 @@ class RegistrationTest extends UnitTestCase { $this->assertEquals($target['reg_lang'], $reg->lang); } + public function test_get_registration_by_id(): void { + $target = $this->fixtures['register'][0]; + + $reg = Registration::get(intval($target['reg_id'])); + + $this->assertInstanceOf(Registration::class, $reg); + + $this->assertEquals($target['reg_uid'], $reg->uid); + $this->assertEquals($target['reg_hash'], $reg->hash); + $this->assertEquals($target['reg_lang'], $reg->lang); + } + #[DataProvider('findByHashProvider')] public function test_find_by_hash(string $hash, bool $expect_success): void { $reg = Registration::find_by_hash($hash); |