Fix LESS import error and refactor project structure
This commit is contained in:
82
tests/SessionTest.php
Normal file
82
tests/SessionTest.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
echo "Проверка работы сессий на страницах:\n";
|
||||
|
||||
$pagesWithSession = [
|
||||
'Доставка.php',
|
||||
'Гарантия.php',
|
||||
'услуги.php',
|
||||
'cite_mebel.php',
|
||||
'catalog.php',
|
||||
'профиль.php',
|
||||
];
|
||||
|
||||
foreach ($pagesWithSession as $page) {
|
||||
$pagePath = __DIR__ . '/../' . $page;
|
||||
|
||||
if (file_exists($pagePath)) {
|
||||
$content = file_get_contents($pagePath);
|
||||
|
||||
$hasSessionStart = str_contains($content, 'session_start()');
|
||||
$test->assert($hasSessionStart, "$page содержит session_start()");
|
||||
|
||||
} else {
|
||||
$test->assert(false, "$page - файл не найден");
|
||||
}
|
||||
}
|
||||
|
||||
echo "\nПроверка header_common.php:\n";
|
||||
|
||||
$headerCommonPath = __DIR__ . '/../header_common.php';
|
||||
$test->assert(file_exists($headerCommonPath), "Файл header_common.php существует");
|
||||
|
||||
$headerContent = file_get_contents($headerCommonPath);
|
||||
|
||||
$test->assertContains(
|
||||
"session_status() == PHP_SESSION_NONE",
|
||||
$headerContent,
|
||||
"header_common.php проверяет статус сессии перед стартом"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"\$isAdmin",
|
||||
$headerContent,
|
||||
"header_common.php использует переменную isAdmin"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"Админ",
|
||||
$headerContent,
|
||||
"header_common.php отображает статус 'Админ'"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"Пользователь",
|
||||
$headerContent,
|
||||
"header_common.php отображает статус 'Пользователь'"
|
||||
);
|
||||
|
||||
echo "\nПроверка login_handler.php:\n";
|
||||
|
||||
$loginHandlerPath = __DIR__ . '/../login_handler.php';
|
||||
$test->assert(file_exists($loginHandlerPath), "Файл login_handler.php существует");
|
||||
|
||||
$loginHandlerContent = file_get_contents($loginHandlerPath);
|
||||
|
||||
$test->assertContains(
|
||||
"\$_SESSION['isAdmin']",
|
||||
$loginHandlerContent,
|
||||
"login_handler.php сохраняет isAdmin в сессию"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"\$_SESSION['isLoggedIn']",
|
||||
$loginHandlerContent,
|
||||
"login_handler.php сохраняет isLoggedIn в сессию"
|
||||
);
|
||||
|
||||
$test->assertContains(
|
||||
"password_verify",
|
||||
$loginHandlerContent,
|
||||
"login_handler.php использует password_verify для проверки пароля"
|
||||
);
|
||||
Reference in New Issue
Block a user