Files
shopPRO/tests/bootstrap.php
Jacek Pyziak 0402dbee76 ver. 0.280: Articles frontend migration, class.Article removal, Settings facade cleanup
- Add 8 frontend methods to ArticleRepository (with Redis cache)
- Create front\Views\Articles (rendering + utility methods)
- Rewire front\view\Site::show() and front\controls\Site::route() to repo + Views
- Update 5 article templates to use \front\Views\Articles::
- Convert front\factory\Articles and front\view\Articles to facades
- Remove class.Article (entity + static methods migrated to repo + Views)
- Remove front\factory\Settings facade (already migrated)
- Fix: eliminate global $lang from articleNoindex(), inline page sort query
- Tests: 450 OK, 1431 assertions (+13 new)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 15:52:03 +01:00

92 lines
3.5 KiB
PHP

<?php
/**
* Bootstrap dla testów PHPUnit
*/
// Załaduj Composer autoloader (jeśli istnieje)
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
} else {
// Ręczny autoloader PSR-4 dla autoload/
spl_autoload_register(function ($class) {
$prefixes = [
'Domain\\' => __DIR__ . '/../autoload/Domain/',
'admin\\Controllers\\' => __DIR__ . '/../autoload/admin/Controllers/',
'admin\\Support\\Forms\\' => __DIR__ . '/../autoload/admin/Support/Forms/',
'admin\\ViewModels\\Forms\\' => __DIR__ . '/../autoload/admin/ViewModels/Forms/',
'admin\\Validation\\' => __DIR__ . '/../autoload/admin/Validation/',
];
foreach ($prefixes as $prefix => $baseDir) {
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) === 0) {
$relativeClass = substr($class, $len);
$file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
if (file_exists($file)) {
require $file;
return;
}
}
}
});
}
// Załaduj Medoo
require_once __DIR__ . '/../libraries/medoo/medoo.php';
// Ustaw timezone
date_default_timezone_set('Europe/Warsaw');
// Stuby klas systemowych (nie dostępnych w testach unit)
if (!class_exists('S')) {
class S {
public static function seo($str) { return $str; }
public static function delete_dir($path) {}
public static function alert($msg) {}
public static function htacces() {}
public static function delete_cache() {}
public static function get($key) { return null; }
public static function set_message($msg) {}
public static function clear_redis_cache() {}
public static function clear_product_cache($id) {}
public static function email_check($email) { return filter_var($email, FILTER_VALIDATE_EMAIL); }
public static function get_session($key) { return $_SESSION[$key] ?? null; }
public static function set_session($key, $value) { $_SESSION[$key] = $value; }
public static function send_email($to, $subject, $body) { return true; }
public static function remove_special_chars($str) { return str_ireplace(['\'', '"', ',', ';', '<', '>'], ' ', $str); }
public static function normalize_decimal($val, $precision = 2) { return round((float)$val, $precision); }
public static function is_array_fix($value) { return is_array($value) && count($value); }
}
}
if (!class_exists('RedisConnection')) {
class RedisConnection {
private static $instance;
public static function getInstance() {
if (!self::$instance) self::$instance = new self();
return self::$instance;
}
public function getConnection() { return null; }
}
}
if (!class_exists('Redis')) {
class Redis {
public function flushAll() { return true; }
public function get($key) { return null; }
public function set($key, $value) { return true; }
public function del($key) { return 1; }
public function keys($pattern) { return []; }
}
}
if (!class_exists('CacheHandler')) {
class CacheHandler {
public function get($key) { return null; }
public function set($key, $value, $ttl = 86400) {}
public function exists($key) { return false; }
public function delete($key) {}
public function deletePattern($pattern) {}
}
}