83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?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 для проверки пароля"
|
|
);
|