From f28412ccd907bd22a62bbd294fa958db7c13212e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 20 Feb 2024 20:10:20 +1300 Subject: [PATCH] Add compound UID unit test --- .../Database/Validator/CompoundUIDTest.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/unit/Utopia/Database/Validator/CompoundUIDTest.php diff --git a/tests/unit/Utopia/Database/Validator/CompoundUIDTest.php b/tests/unit/Utopia/Database/Validator/CompoundUIDTest.php new file mode 100644 index 0000000000..b443cf590b --- /dev/null +++ b/tests/unit/Utopia/Database/Validator/CompoundUIDTest.php @@ -0,0 +1,37 @@ +object = new CompoundUID(); + } + + public function tearDown(): void + { + } + + public function testValues(): void + { + $this->assertEquals($this->object->isValid('123:456'), true); + $this->assertEquals($this->object->isValid('123'), false); + $this->assertEquals($this->object->isValid('123:_456'), false); + $this->assertEquals($this->object->isValid('dasda asdasd'), false); + $this->assertEquals($this->object->isValid('dasda:asdasd'), true); + $this->assertEquals($this->object->isValid('_asdas:dasdas'), false); + $this->assertEquals($this->object->isValid('as$$5da:sdasdas'), false); + $this->assertEquals($this->object->isValid(false), false); + $this->assertEquals($this->object->isValid(null), false); + $this->assertEquals($this->object->isValid('socialAccountForYoutubeAndRestSubscribers:12345'), false); + $this->assertEquals($this->object->isValid('socialAccountForYoutubeAndRSubscriber:12345'), false); + $this->assertEquals($this->object->isValid('socialAccount:ForYoutubeSubscribe'), true); + $this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscribe:socialAccountForYoutubeSubscribe'), true); + } +}