chore: add composer + phpunit dev scaffolding

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vladimir Bryzgalov
2026-04-17 21:53:22 +05:00
parent be00b7996c
commit 6aa1ef41e6
4 changed files with 76 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
/tests export-ignore
/docs export-ignore
/phpunit.xml export-ignore
/composer.json export-ignore
/composer.lock export-ignore
/.gitignore export-ignore
/.gitattributes export-ignore
+23
View File
@@ -0,0 +1,23 @@
{
"name": "sidelkin/cf7-spam-to-telegram",
"description": "Forwards CF7 spam submissions to Telegram",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.4"
},
"require-dev": {
"phpunit/phpunit": "^9.6"
},
"autoload-dev": {
"psr-4": {
"Cf7stg\\Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit"
},
"config": {
"sort-packages": true
}
}
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true"
cacheResultFile=".phpunit.result.cache">
<testsuites>
<testsuite name="unit">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
+34
View File
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
// Simple autoloader that mirrors the runtime plugin autoloader,
// mapping Cf7stg\ClassName → includes/class-class-name.php
spl_autoload_register(static function (string $class): void {
if (strpos($class, 'Cf7stg\\') !== 0) {
return;
}
$relative = substr($class, strlen('Cf7stg\\'));
// Turn "PhoneParser" into "phone-parser"
$slug = strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1-$2', $relative));
$path = __DIR__ . '/../includes/class-' . $slug . '.php';
if (is_file($path)) {
require_once $path;
}
});
// Minimal shims for functions used by pure-logic classes when WP is absent.
if (!function_exists('apply_filters')) {
function apply_filters($tag, $value) { return $value; }
}
if (!function_exists('esc_html')) {
function esc_html($s) { return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); }
}
if (!function_exists('esc_url')) {
function esc_url($s) { return filter_var((string)$s, FILTER_SANITIZE_URL); }
}
if (!function_exists('wp_strip_all_tags')) {
function wp_strip_all_tags($s) { return trim(strip_tags((string)$s)); }
}
if (!function_exists('__')) {
function __($text) { return $text; }
}