diff --git a/app/Models/Validation/Validators/UserValidatorByMatrixUserName.php b/app/Models/Validation/Validators/UserValidatorByMatrixUserName.php new file mode 100644 index 0000000..e6ea91e --- /dev/null +++ b/app/Models/Validation/Validators/UserValidatorByMatrixUserName.php @@ -0,0 +1,17 @@ +getName())->count(); + + return $count != 0; + } +} + diff --git a/tests/Feature/Validation/Validators/UserValidatorByMatrixUserNameTest.php b/tests/Feature/Validation/Validators/UserValidatorByMatrixUserNameTest.php new file mode 100644 index 0000000..1fb0011 --- /dev/null +++ b/tests/Feature/Validation/Validators/UserValidatorByMatrixUserNameTest.php @@ -0,0 +1,44 @@ + [ + 'name' => '@test:test.com', + 'isValid' => true, + ], + 'Not Found Case' => [ + 'name' => '@kostia:test.com', + 'isValid' => false, + ], + 'Invalid Case' => [ + 'name' => '', + 'isValid' => false, + ], + ]; + } + + public function setUpValidator(string $name): UserValidatorByMatrixUserName + { + return new UserValidatorByMatrixUserName($name, new OkValidator()); + } + + /** + * @dataProvider dataProvider + */ + public function testGetMessage(string $name, bool $isValid): void + { + $validator = $this->setUpValidator($name); + + $this->assertEquals($validator->isValid(), $isValid); + } +} +