Fix LESS import error and refactor project structure
This commit is contained in:
70
tests/UserRegistrationTest.php
Normal file
70
tests/UserRegistrationTest.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
echo "Проверка модели User:\n";
|
||||
|
||||
$userModelPath = __DIR__ . '/../app/Models/User.php';
|
||||
$test->assert(file_exists($userModelPath), "Файл модели User существует");
|
||||
|
||||
$userModelContent = file_get_contents($userModelPath);
|
||||
|
||||
$test->assertContains(
|
||||
"'is_admin' => \$isAdmin ? 'true' : 'false'",
|
||||
$userModelContent,
|
||||
"is_admin преобразуется в строку для PostgreSQL"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"'is_active' => 'true'",
|
||||
$userModelContent,
|
||||
"is_active преобразуется в строку для PostgreSQL"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"public function register(array \$data)",
|
||||
$userModelContent,
|
||||
"Метод register существует в модели User"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"public function authenticate(string \$email, string \$password)",
|
||||
$userModelContent,
|
||||
"Метод authenticate существует в модели User"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"public function hashPassword(string \$password)",
|
||||
$userModelContent,
|
||||
"Метод hashPassword существует в модели User"
|
||||
);
|
||||
|
||||
echo "\nПроверка register_handler.php:\n";
|
||||
|
||||
$registerHandlerPath = __DIR__ . '/../register_handler.php';
|
||||
$test->assert(file_exists($registerHandlerPath), "Файл register_handler.php существует");
|
||||
|
||||
$registerHandlerContent = file_get_contents($registerHandlerPath);
|
||||
|
||||
$test->assertContains(
|
||||
"filter_var(\$email, FILTER_VALIDATE_EMAIL)",
|
||||
$registerHandlerContent,
|
||||
"Валидация email присутствует"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"strlen(\$password) < 6",
|
||||
$registerHandlerContent,
|
||||
"Проверка минимальной длины пароля присутствует"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"\$password !== \$confirm_password",
|
||||
$registerHandlerContent,
|
||||
"Проверка совпадения паролей присутствует"
|
||||
);
|
||||
|
||||
$hasBooleanConversion = str_contains($registerHandlerContent, "\$is_admin ? 'true' : 'false'")
|
||||
|| str_contains($registerHandlerContent, "\$is_admin ? 1 : 0");
|
||||
$test->assert(
|
||||
$hasBooleanConversion,
|
||||
"is_admin преобразуется для PostgreSQL в register_handler"
|
||||
);
|
||||
Reference in New Issue
Block a user