Fase 0: Configuración inicial del proyecto

- Configuración de Composer con PSR-4
- Configuración de PHPUnit
- Configuración de PHPCS
- Scripts de backup y rollback
- Estructura de carpetas inicial
- Documentación de procedimientos
This commit is contained in:
FrankZamora
2025-11-17 12:01:51 -06:00
parent a6578f4973
commit b782ebceee
6 changed files with 161 additions and 0 deletions

5
.gitignore vendored
View File

@@ -42,6 +42,11 @@ npm-debug.log
# Composer (si hay dependencias PHP) # Composer (si hay dependencias PHP)
vendor/ vendor/
composer.lock
# PHPUnit
.phpunit.result.cache
/tests/_output/
# Environment files # Environment files
.env .env

39
composer.json Normal file
View File

@@ -0,0 +1,39 @@
{
"name": "roi/roi-theme",
"description": "ROI Theme - Migración a Clean Architecture + POO",
"type": "wordpress-theme",
"license": "proprietary",
"require": {
"php": ">=8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.7",
"wp-coding-standards/wpcs": "^3.0",
"mockery/mockery": "^1.5"
},
"autoload": {
"psr-4": {
"ROITheme\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"ROITheme\\Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit",
"phpcs": "phpcs --standard=WordPress src/",
"phpcbf": "phpcbf --standard=WordPress src/"
},
"config": {
"secure-http": true,
"disable-tls": false,
"preferred-install": "dist",
"platform-check": false,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}

30
phpcs.xml Normal file
View File

@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<ruleset name="ROI Theme Coding Standards">
<description>Estándares de código para ROI Theme</description>
<!-- Paths a analizar -->
<file>src</file>
<!-- Paths a excluir -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/admin/*</exclude-pattern><!-- Legacy code -->
<!-- Usar estándar WordPress -->
<rule ref="WordPress">
<!-- Excluir reglas que no aplican para código nuevo -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
</rule>
<!-- Configuraciones adicionales -->
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="8"/>
<!-- Mostrar progreso -->
<arg value="sp"/>
<!-- PHP 8.0+ -->
<config name="testVersion" value="8.0-"/>
</ruleset>

36
phpunit.xml Normal file
View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="tests/_bootstrap/bootstrap.php"
colors="true"
verbose="true"
stopOnFailure="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true">
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory>tests/Integration</directory>
</testsuite>
<testsuite name="E2E">
<directory>tests/E2E</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>src/Infrastructure/UI/Views</directory>
</exclude>
</coverage>
<php>
<env name="APP_ENV" value="testing"/>
</php>
</phpunit>

View File

@@ -0,0 +1,30 @@
<?php
namespace ROITheme\Tests\Unit;
use PHPUnit\Framework\TestCase;
/**
* Test de ejemplo para verificar que PHPUnit funciona
*/
class ExampleTest extends TestCase
{
public function testPhpUnitIsWorking(): void
{
$this->assertTrue(true, 'PHPUnit está funcionando correctamente');
}
public function testPhpVersion(): void
{
$version = PHP_VERSION;
$this->assertGreaterThanOrEqual('8.0.0', $version, 'PHP debe ser versión 8.0 o superior');
}
public function testComposerAutoloadIsLoaded(): void
{
$this->assertTrue(
class_exists('PHPUnit\Framework\TestCase'),
'Composer autoload está funcionando'
);
}
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* PHPUnit Bootstrap
*
* Se ejecuta antes de todos los tests
*/
// Cargar autoloader de Composer
require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
// Definir constantes de WordPress si no existen (para tests unitarios puros)
if (!defined('ABSPATH')) {
define('ABSPATH', dirname(__DIR__, 5) . '/');
}
if (!defined('WP_DEBUG')) {
define('WP_DEBUG', true);
}
// Para tests de integración, se cargará WordPress completo
// Esto se hará en un bootstrap separado para tests de integración