Files
Portfolio-Codex/tests/templates.test.ps1
2026-02-04 16:58:07 +01:00

38 lines
1.5 KiB
PowerShell

$ErrorActionPreference = 'Stop'
function Assert-True {
param(
[bool]$Condition,
[string]$Message
)
if (-not $Condition) { throw $Message }
}
Assert-True (Test-Path 'includes/functions.php') 'Missing includes/functions.php'
$functions = Get-Content -Raw 'includes/functions.php'
Assert-True ($functions -match 'function\s+include_template') 'Missing include_template function'
Assert-True (Test-Path 'templates/header.php') 'Missing templates/header.php'
$header = Get-Content -Raw 'templates/header.php'
Assert-True ($header -match '<!DOCTYPE html>') 'Header missing doctype'
Assert-True ($header -match 'meta name="viewport"') 'Header missing viewport meta'
Assert-True ($header -match 'output\.css') 'Header missing output.css link'
Assert-True ($header -match '\$pageTitle') 'Header missing pageTitle'
Assert-True (Test-Path 'templates/footer.php') 'Missing templates/footer.php'
$footer = Get-Content -Raw 'templates/footer.php'
Assert-True ($footer -match 'main\.js') 'Footer missing main.js'
Assert-True ($footer -match '</body>') 'Footer missing closing body'
Assert-True (Test-Path 'index.php') 'Missing index.php'
$index = Get-Content -Raw 'index.php'
if (-not ($index -match 'include_template\(')) {
Assert-True (Test-Path 'pages/home.php') 'Missing pages/home.php for templates usage'
$homeContent = Get-Content -Raw 'pages/home.php'
Assert-True ($homeContent -match 'include_template\(') 'pages/home.php missing include_template usage'
}
Assert-True (Test-Path 'assets/js/main.js') 'Missing assets/js/main.js'
'OK'