mirror of
https://github.com/bitinflow/accounts.git
synced 2026-03-13 13:35:52 +00:00
Add method to check if a email exists
This commit is contained in:
@@ -32,4 +32,18 @@ trait UsersTrait
|
|||||||
{
|
{
|
||||||
return $this->post('v2/users', $parameters);
|
return $this->post('v2/users', $parameters);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Checks if the given email exists.
|
||||||
|
*
|
||||||
|
* @param string $email
|
||||||
|
*
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
public function isEmailExisting(string $email): Result
|
||||||
|
{
|
||||||
|
return $this->post('v2/users/check-email', [
|
||||||
|
'email' => $email,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,6 +22,20 @@ class ApiUsersTest extends ApiTestCase
|
|||||||
$this->assertEquals('rene@preuss.io', $result->data()->email);
|
$this->assertEquals('rene@preuss.io', $result->data()->email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmailAvailabilityNonExisting(): void
|
||||||
|
{
|
||||||
|
$this->getClient()->withToken($this->getToken());
|
||||||
|
$this->registerResult($result = $this->getClient()->isEmailExisting('rene+non-existing@preuss.io'));
|
||||||
|
$this->assertTrue(!$result->success());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testEmailAvailabilityExisting(): void
|
||||||
|
{
|
||||||
|
$this->getClient()->withToken($this->getToken());
|
||||||
|
$this->registerResult($result = $this->getClient()->isEmailExisting('rene@preuss.io'));
|
||||||
|
$this->assertTrue($result->success());
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreateUser(): void
|
public function testCreateUser(): void
|
||||||
{
|
{
|
||||||
$testEmailAddress = $this->createRandomEmail();
|
$testEmailAddress = $this->createRandomEmail();
|
||||||
@@ -47,4 +61,4 @@ class ApiUsersTest extends ApiTestCase
|
|||||||
{
|
{
|
||||||
return sprintf('rene+unittest.%s@bitinflow.com', Str::random());
|
return sprintf('rene+unittest.%s@bitinflow.com', Str::random());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user