Story 1.1: initialisation projet
This commit is contained in:
4
tests/run.ps1
Normal file
4
tests/run.ps1
Normal file
@@ -0,0 +1,4 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
& (Join-Path $here 'structure.test.ps1')
|
||||
'OK'
|
||||
73
tests/structure.test.ps1
Normal file
73
tests/structure.test.ps1
Normal file
@@ -0,0 +1,73 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Assert-True {
|
||||
param(
|
||||
[bool]$Condition,
|
||||
[string]$Message
|
||||
)
|
||||
if (-not $Condition) { throw $Message }
|
||||
}
|
||||
|
||||
$dirs = @(
|
||||
'pages',
|
||||
'templates',
|
||||
'includes',
|
||||
'api',
|
||||
'assets/css',
|
||||
'assets/js',
|
||||
'assets/img',
|
||||
'assets/img/projects',
|
||||
'assets/fonts',
|
||||
'data',
|
||||
'logs'
|
||||
)
|
||||
|
||||
foreach ($d in $dirs) {
|
||||
Assert-True (Test-Path $d) "Missing dir: $d"
|
||||
}
|
||||
|
||||
Assert-True (Test-Path 'logs/.gitkeep') 'Missing logs/.gitkeep'
|
||||
|
||||
Assert-True (Test-Path 'index.php') 'Missing index.php'
|
||||
$index = Get-Content -Raw 'index.php'
|
||||
Assert-True ($index -match 'Hello World') 'index.php missing Hello World'
|
||||
Assert-True ($index -match 'meta name="viewport"') 'index.php missing viewport meta'
|
||||
|
||||
Assert-True (Test-Path '.gitignore') 'Missing .gitignore'
|
||||
$gitignore = Get-Content -Raw '.gitignore'
|
||||
$required = @(
|
||||
'.env',
|
||||
'vendor/',
|
||||
'node_modules/',
|
||||
'logs/*.log',
|
||||
'assets/css/output.css',
|
||||
'.idea/',
|
||||
'.vscode/',
|
||||
'.DS_Store'
|
||||
)
|
||||
foreach ($r in $required) {
|
||||
Assert-True ($gitignore -match [regex]::Escape($r)) "Missing .gitignore entry: $r"
|
||||
}
|
||||
|
||||
Assert-True (Test-Path '.env.example') 'Missing .env.example'
|
||||
$env = Get-Content -Raw '.env.example'
|
||||
$requiredEnv = @(
|
||||
'APP_ENV=',
|
||||
'APP_DEBUG=',
|
||||
'APP_URL=',
|
||||
'RECAPTCHA_SITE_KEY=',
|
||||
'RECAPTCHA_SECRET_KEY=',
|
||||
'CONTACT_EMAIL=',
|
||||
'APP_SECRET='
|
||||
)
|
||||
foreach ($r in $requiredEnv) {
|
||||
Assert-True ($env -match [regex]::Escape($r)) "Missing env var: $r"
|
||||
}
|
||||
|
||||
Assert-True (Test-Path 'composer.json') 'Missing composer.json'
|
||||
$composer = Get-Content -Raw 'composer.json' | ConvertFrom-Json
|
||||
$dotenv = $composer.require.'vlucas/phpdotenv'
|
||||
$phpReq = $composer.require.php
|
||||
Assert-True (-not [string]::IsNullOrWhiteSpace($dotenv)) 'Missing vlucas/phpdotenv dependency'
|
||||
Assert-True (-not [string]::IsNullOrWhiteSpace($phpReq)) 'Missing php requirement'
|
||||
'OK'
|
||||
Reference in New Issue
Block a user