Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/UsersTest.php
Show First 20 Lines • Show All 964 Lines • ▼ Show 20 Lines | public function dataValidateEmail(): array | ||||
// forbidden local part on public domains | // forbidden local part on public domains | ||||
["admin@$domain", $john, true, 'The specified alias is not available.'], | ["admin@$domain", $john, true, 'The specified alias is not available.'], | ||||
["administrator@$domain", $john, true, 'The specified alias is not available.'], | ["administrator@$domain", $john, true, 'The specified alias is not available.'], | ||||
// forbidden (other user's domain) | // forbidden (other user's domain) | ||||
["testtest@kolab.org", $user, true, 'The specified domain is not available.'], | ["testtest@kolab.org", $user, true, 'The specified domain is not available.'], | ||||
// existing alias of other user | // existing alias of other user, to be a user email | ||||
["jack.daniels@kolab.org", $john, true, 'The specified alias is not available.'], | ["jack.daniels@kolab.org", $john, false, 'The specified email is not available.'], | ||||
// existing alias of other user, to be an alias, user in the same group account | |||||
["jack.daniels@kolab.org", $john, true, null], | |||||
// existing user | // existing user | ||||
["jack@kolab.org", $john, true, 'The specified alias is not available.'], | ["jack@kolab.org", $john, true, 'The specified alias is not available.'], | ||||
// valid (user domain) | // valid (user domain) | ||||
["admin@kolab.org", $john, true, null], | ["admin@kolab.org", $john, true, null], | ||||
// valid (public domain) | // valid (public domain) | ||||
["test.test@$domain", $john, true, null], | ["test.test@$domain", $john, true, null], | ||||
]; | ]; | ||||
} | } | ||||
/** | /** | ||||
* User email/alias validation. | * User email/alias validation. | ||||
* | * | ||||
* Note: Technically these include unit tests, but let's keep it here for now. | * Note: Technically these include unit tests, but let's keep it here for now. | ||||
* FIXME: Shall we do a http request for each case? | * FIXME: Shall we do a http request for each case? | ||||
* | * | ||||
* @dataProvider dataValidateEmail | * @dataProvider dataValidateEmail | ||||
*/ | */ | ||||
public function testValidateEmail($alias, $user, $is_alias, $expected_result): void | public function testValidateEmail($alias, $user, $is_alias, $expected_result): void | ||||
{ | { | ||||
$result = $this->invokeMethod(new \App\Utils(), 'validateEmail', [$alias, $user, $is_alias]); | $args = [$alias, $user, $is_alias]; | ||||
$result = $this->invokeMethod(new UsersController(), 'validateEmail', $args); | |||||
$this->assertSame($expected_result, $result); | $this->assertSame($expected_result, $result); | ||||
} | } | ||||
} | } |