chore: add spec-kit and standardize signatures
- Added GitHub spec-kit for development workflow - Standardized file signatures to Descomplicar® format - Updated development configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Descomplicar® Crescimento Digital
|
||||
* https://descomplicar.pt
|
||||
*/
|
||||
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . '/../modules/desk_moloni/controllers/ClientPortalController.php');
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Descomplicar® Crescimento Digital
|
||||
* https://descomplicar.pt
|
||||
*/
|
||||
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/TestCase.php';
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Descomplicar® Crescimento Digital
|
||||
* https://descomplicar.pt
|
||||
*/
|
||||
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/TestCase.php';
|
||||
@@ -33,16 +38,44 @@ class IntegrationTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
// Initialize all services
|
||||
parent::setUp(); // This will call initializeCodeIgniter() from TestCase.php
|
||||
|
||||
// Define mock for get_option if it doesn't exist
|
||||
if (!function_exists('get_option')) {
|
||||
function get_option($name, $default = '') {
|
||||
$options = [
|
||||
'desk_moloni_redis_host' => '127.0.0.1',
|
||||
'desk_moloni_redis_port' => 6379,
|
||||
'desk_moloni_redis_password' => '',
|
||||
'desk_moloni_redis_db' => 1,
|
||||
'desk_moloni_sync_enabled' => '1',
|
||||
'desk_moloni_sync_customers' => '1',
|
||||
'desk_moloni_sync_invoices' => '1',
|
||||
'desk_moloni_sync_products' => '1',
|
||||
'desk_moloni_sync_estimates' => '1',
|
||||
'desk_moloni_sync_payments' => '1',
|
||||
];
|
||||
return $options[$name] ?? $default;
|
||||
}
|
||||
}
|
||||
|
||||
// These services don't have complex dependencies in their constructors yet
|
||||
$this->entity_mapping = new EntityMappingService();
|
||||
$this->client_sync = new ClientSyncService();
|
||||
$this->product_sync = new ProductSyncService();
|
||||
$this->invoice_sync = new InvoiceSyncService();
|
||||
$this->estimate_sync = new EstimateSyncService();
|
||||
$this->queue_processor = new QueueProcessor();
|
||||
|
||||
// Instantiate PerfexHooks, which will create the QueueProcessor with all its dependencies
|
||||
$this->perfex_hooks = new PerfexHooks();
|
||||
$this->entity_mapping = new EntityMappingService();
|
||||
|
||||
// Clear any existing test data
|
||||
|
||||
// Get the QueueProcessor instance from the hooks class for test assertions
|
||||
$reflection = new \ReflectionClass($this->perfex_hooks);
|
||||
$queue_processor_property = $reflection->getProperty('queue_processor');
|
||||
$queue_processor_property->setAccessible(true);
|
||||
$this->queue_processor = $queue_processor_property->getValue($this->perfex_hooks);
|
||||
|
||||
// Clean up any existing test data
|
||||
$this->cleanupTestData();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Descomplicar® Crescimento Digital
|
||||
* https://descomplicar.pt
|
||||
*/
|
||||
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/TestCase.php';
|
||||
@@ -22,48 +27,33 @@ class QueueProcessorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private $queue_processor;
|
||||
private $redis_mock;
|
||||
private $model_mock;
|
||||
private $entity_mapping_mock;
|
||||
private $error_handler_mock;
|
||||
private $retry_handler_mock;
|
||||
private $CI_mock;
|
||||
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
// Create mocks for dependencies
|
||||
$this->redis_mock = $this->createMock(Redis::class);
|
||||
$this->redis_mock = $this->createMock(\Redis::class);
|
||||
$this->model_mock = $this->createMock(Desk_moloni_model::class);
|
||||
$this->entity_mapping_mock = $this->createMock(EntityMappingService::class);
|
||||
$this->error_handler_mock = $this->createMock(ErrorHandler::class);
|
||||
$this->retry_handler_mock = $this->createMock(RetryHandler::class);
|
||||
|
||||
|
||||
// Mock CodeIgniter instance
|
||||
$this->CI_mock = $this->createMock(stdClass::class);
|
||||
$this->CI_mock->desk_moloni_model = $this->createMock(stdClass::class);
|
||||
|
||||
// Initialize service
|
||||
$this->queue_processor = new QueueProcessor();
|
||||
|
||||
// Use reflection to inject mocks
|
||||
$reflection = new ReflectionClass($this->queue_processor);
|
||||
|
||||
$redis_property = $reflection->getProperty('redis');
|
||||
$redis_property->setAccessible(true);
|
||||
$redis_property->setValue($this->queue_processor, $this->redis_mock);
|
||||
|
||||
$entity_mapping_property = $reflection->getProperty('entity_mapping');
|
||||
$entity_mapping_property->setAccessible(true);
|
||||
$entity_mapping_property->setValue($this->queue_processor, $this->entity_mapping_mock);
|
||||
|
||||
$error_handler_property = $reflection->getProperty('error_handler');
|
||||
$error_handler_property->setAccessible(true);
|
||||
$error_handler_property->setValue($this->queue_processor, $this->error_handler_mock);
|
||||
|
||||
$retry_handler_property = $reflection->getProperty('retry_handler');
|
||||
$retry_handler_property->setAccessible(true);
|
||||
$retry_handler_property->setValue($this->queue_processor, $this->retry_handler_mock);
|
||||
|
||||
$ci_property = $reflection->getProperty('CI');
|
||||
$ci_property->setAccessible(true);
|
||||
$ci_property->setValue($this->queue_processor, $this->CI_mock);
|
||||
$this->CI_mock->desk_moloni_model = $this->model_mock;
|
||||
|
||||
// Initialize service with DI
|
||||
$this->queue_processor = new QueueProcessor(
|
||||
$this->redis_mock,
|
||||
$this->model_mock,
|
||||
$this->entity_mapping_mock,
|
||||
$this->error_handler_mock,
|
||||
$this->retry_handler_mock
|
||||
);
|
||||
}
|
||||
|
||||
public function testAddToQueueSuccess()
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Descomplicar® Crescimento Digital
|
||||
* https://descomplicar.pt
|
||||
*/
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Descomplicar® Crescimento Digital
|
||||
* https://descomplicar.pt
|
||||
*/
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user