ver. 0.283: Legacy class cleanup — S, Html, Email, Image, Log, Mobile_Detect → Shared namespace
- Migrate class.S → Shared\Helpers\Helpers (140+ files), remove 12 unused methods - Migrate class.Html → Shared\Html\Html - Migrate class.Email → Shared\Email\Email - Migrate class.Image → Shared\Image\ImageManipulator - Delete class.Log (unused), class.Mobile_Detect (outdated UA detection) - Remove grid library loading from admin (index.php, ajax.php) - Replace gridEdit usage in 10 admin templates with grid-edit-replacement.php - Fix grid-edit-replacement.php AJAX to send values as JSON (grid.js compat) - Remove mobile layout conditionals (m_html/m_css/m_js) from Site + LayoutsRepository - Remove \Log::save_log() calls from OrderAdminService, ShopOrder, Order Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@ use Domain\Cache\CacheRepository;
|
||||
* Testy dla CacheRepository
|
||||
*
|
||||
* Testujemy logikę Redis (mockowaną) oraz strukturę odpowiedzi.
|
||||
* Czyszczenie katalogów delegowane do \S::delete_dir() - nietestowalne unit testami.
|
||||
* Czyszczenie katalogów delegowane do \Shared\Helpers\Helpers::delete_dir() - nietestowalne unit testami.
|
||||
*/
|
||||
class CacheRepositoryTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ use Domain\Settings\SettingsRepository;
|
||||
* Testy dla SettingsController
|
||||
*
|
||||
* Kontroler używa SettingsRepository (DI).
|
||||
* Cache czyszczony bezpośrednio przez \S::delete_dir() i \Shared\Cache\RedisConnection.
|
||||
* Cache czyszczony bezpośrednio przez \Shared\Helpers\Helpers::delete_dir() i \Shared\Cache\RedisConnection.
|
||||
*/
|
||||
class SettingsControllerTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -38,25 +38,8 @@ require_once __DIR__ . '/../libraries/medoo/medoo.php';
|
||||
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('Shared\\Helpers\\Helpers')) {
|
||||
require_once __DIR__ . '/stubs/Helpers.php';
|
||||
}
|
||||
|
||||
if (!class_exists('Shared\\Cache\\RedisConnection')) {
|
||||
|
||||
21
tests/stubs/Helpers.php
Normal file
21
tests/stubs/Helpers.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Shared\Helpers;
|
||||
|
||||
class Helpers
|
||||
{
|
||||
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_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); }
|
||||
}
|
||||
Reference in New Issue
Block a user