Files
shopPRO/tests/bootstrap.php
Jacek Pyziak 9cac0d1eeb ver. 0.296: REST API for ordersPRO — orders management, dictionaries, API key auth
- New API layer: ApiRouter, OrdersApiController, DictionariesApiController
- Orders API: list (with filters/pagination/updated_since), details, change status, set paid/unpaid
- Dictionaries API: order statuses, transport methods, payment methods
- X-Api-Key authentication via pp_settings.api_key
- OrderRepository: listForApi(), findForApi(), touchUpdatedAt()
- updated_at column on pp_shop_orders for polling support
- api.php: skip session for API requests, route to ApiRouter
- SettingsController: api_key field in system tab
- 30 new tests (666 total, 1930 assertions)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 20:25:07 +01:00

83 lines
2.8 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/',
'front\\Controllers\\' => __DIR__ . '/../autoload/front/Controllers/',
'admin\\Support\\Forms\\' => __DIR__ . '/../autoload/admin/Support/Forms/',
'admin\\ViewModels\\Forms\\' => __DIR__ . '/../autoload/admin/ViewModels/Forms/',
'admin\\Validation\\' => __DIR__ . '/../autoload/admin/Validation/',
'api\\' => __DIR__ . '/../autoload/api/',
];
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('Shared\\Helpers\\Helpers')) {
require_once __DIR__ . '/stubs/Helpers.php';
}
if (!class_exists('Shared\\Cache\\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; }
}
class_alias('RedisConnection', 'Shared\\Cache\\RedisConnection');
}
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('Shared\\Cache\\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) {}
}
class_alias('CacheHandler', 'Shared\\Cache\\CacheHandler');
}
if (!class_exists('shop\\Product')) {
require_once __DIR__ . '/stubs/ShopProduct.php';
}