#!/usr/bin/env sh

set -eu

printf '%s\n' 'WebMarket Phase 16 acceptance tests'
php -r "exit(version_compare(PHP_VERSION, '8.2.0', '>=') ? 0 : 1);"

if [ ! -f vendor/autoload.php ]; then
    composer install --no-interaction --prefer-dist --optimize-autoloader
fi

mkdir -p bootstrap/cache storage/app/private storage/app/public storage/framework/cache/data storage/framework/sessions storage/framework/testing storage/framework/views storage/logs

php artisan optimize:clear
php artisan webmarket:legacy-audit
php artisan migrate --force
php artisan migrate:status
php artisan webmarket:legacy-integrity
php artisan route:list --except-vendor
php artisan test
php artisan webmarket:deployment-check
printf '%s\n' 'All automated acceptance checks passed.'
