|
@@ -1,7 +1,8 @@
|
|
|
<?php
|
|
<?php
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Manual Test Script for SixShop Maker Bundle
|
|
* Manual Test Script for SixShop Maker Bundle
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* This script performs comprehensive tests of all functionality
|
|
* This script performs comprehensive tests of all functionality
|
|
|
* Run: php tests/manual_test.php
|
|
* Run: php tests/manual_test.php
|
|
|
*/
|
|
*/
|
|
@@ -21,7 +22,6 @@ use SixShop\MakerBundle\Generator\ModelGenerator;
|
|
|
use SixShop\MakerBundle\Generator\EntityGenerator;
|
|
use SixShop\MakerBundle\Generator\EntityGenerator;
|
|
|
use SixShop\MakerBundle\Generator\ControllerGenerator;
|
|
use SixShop\MakerBundle\Generator\ControllerGenerator;
|
|
|
use SixShop\MakerBundle\Generator\ComposerGenerator;
|
|
use SixShop\MakerBundle\Generator\ComposerGenerator;
|
|
|
-use SixShop\MakerBundle\Generator\RouteUpdater;
|
|
|
|
|
|
|
|
|
|
echo "🧪 SixShop Maker Bundle - Comprehensive Test Suite\n";
|
|
echo "🧪 SixShop Maker Bundle - Comprehensive Test Suite\n";
|
|
|
echo "=" . str_repeat("=", 50) . "\n\n";
|
|
echo "=" . str_repeat("=", 50) . "\n\n";
|
|
@@ -34,7 +34,7 @@ function test(string $name, callable $test): void
|
|
|
{
|
|
{
|
|
|
global $passed, $failed;
|
|
global $passed, $failed;
|
|
|
echo "📋 Testing: {$name}... ";
|
|
echo "📋 Testing: {$name}... ";
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
$result = $test();
|
|
$result = $test();
|
|
|
if ($result) {
|
|
if ($result) {
|
|
@@ -67,7 +67,7 @@ function cleanupTestDir(): void
|
|
|
new RecursiveDirectoryIterator($testDir, RecursiveDirectoryIterator::SKIP_DOTS),
|
|
new RecursiveDirectoryIterator($testDir, RecursiveDirectoryIterator::SKIP_DOTS),
|
|
|
RecursiveIteratorIterator::CHILD_FIRST
|
|
RecursiveIteratorIterator::CHILD_FIRST
|
|
|
);
|
|
);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
foreach ($iterator as $file) {
|
|
foreach ($iterator as $file) {
|
|
|
if ($file->isDir()) {
|
|
if ($file->isDir()) {
|
|
|
rmdir($file->getRealPath());
|
|
rmdir($file->getRealPath());
|
|
@@ -80,179 +80,179 @@ function cleanupTestDir(): void
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Test 1: MigrationGenerator
|
|
// Test 1: MigrationGenerator
|
|
|
-test("MigrationGenerator - Create Table", function() {
|
|
|
|
|
|
|
+test("MigrationGenerator - Create Table", function () {
|
|
|
$testDir = setupTestDir();
|
|
$testDir = setupTestDir();
|
|
|
$generator = new MigrationGenerator($testDir . '/migrations');
|
|
$generator = new MigrationGenerator($testDir . '/migrations');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$fields = [
|
|
$fields = [
|
|
|
['name' => 'id', 'type' => 'biginteger', 'null' => false],
|
|
['name' => 'id', 'type' => 'biginteger', 'null' => false],
|
|
|
['name' => 'name', 'type' => 'string', 'length' => 100, 'null' => false],
|
|
['name' => 'name', 'type' => 'string', 'length' => 100, 'null' => false],
|
|
|
['name' => 'email', 'type' => 'string', 'length' => 255, 'null' => false, 'unique' => true]
|
|
['name' => 'email', 'type' => 'string', 'length' => 255, 'null' => false, 'unique' => true]
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = $generator->generateMigration('users', $fields, 'create');
|
|
$result = $generator->generateMigration('users', $fields, 'create');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Check if file was created
|
|
// Check if file was created
|
|
|
$files = glob($testDir . '/migrations/*_create_users_table.php');
|
|
$files = glob($testDir . '/migrations/*_create_users_table.php');
|
|
|
return $result && count($files) === 1;
|
|
return $result && count($files) === 1;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-test("MigrationGenerator - Add Column", function() {
|
|
|
|
|
|
|
+test("MigrationGenerator - Add Column", function () {
|
|
|
$testDir = setupTestDir();
|
|
$testDir = setupTestDir();
|
|
|
$generator = new MigrationGenerator($testDir . '/migrations');
|
|
$generator = new MigrationGenerator($testDir . '/migrations');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$fields = [
|
|
$fields = [
|
|
|
['name' => 'phone', 'type' => 'string', 'length' => 20, 'null' => true]
|
|
['name' => 'phone', 'type' => 'string', 'length' => 20, 'null' => true]
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = $generator->generateMigration('users', $fields, 'add_column');
|
|
$result = $generator->generateMigration('users', $fields, 'add_column');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$files = glob($testDir . '/migrations/*_add_column_to_users_table.php');
|
|
$files = glob($testDir . '/migrations/*_add_column_to_users_table.php');
|
|
|
return $result && count($files) === 1;
|
|
return $result && count($files) === 1;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-test("MigrationGenerator - Drop Column", function() {
|
|
|
|
|
|
|
+test("MigrationGenerator - Drop Column", function () {
|
|
|
$testDir = setupTestDir();
|
|
$testDir = setupTestDir();
|
|
|
$generator = new MigrationGenerator($testDir . '/migrations');
|
|
$generator = new MigrationGenerator($testDir . '/migrations');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$fields = [
|
|
$fields = [
|
|
|
['name' => 'deprecated_field']
|
|
['name' => 'deprecated_field']
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = $generator->generateMigration('users', $fields, 'drop_column');
|
|
$result = $generator->generateMigration('users', $fields, 'drop_column');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$files = glob($testDir . '/migrations/*_drop_column_from_users_table.php');
|
|
$files = glob($testDir . '/migrations/*_drop_column_from_users_table.php');
|
|
|
return $result && count($files) === 1;
|
|
return $result && count($files) === 1;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Test 2: ComposerGenerator
|
|
// Test 2: ComposerGenerator
|
|
|
-test("ComposerGenerator - Package Name Validation", function() {
|
|
|
|
|
|
|
+test("ComposerGenerator - Package Name Validation", function () {
|
|
|
$generator = new ComposerGenerator();
|
|
$generator = new ComposerGenerator();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$validNames = ['vendor/package', 'sixshop/hello-world'];
|
|
$validNames = ['vendor/package', 'sixshop/hello-world'];
|
|
|
$invalidNames = ['invalid', 'vendor/', '/package'];
|
|
$invalidNames = ['invalid', 'vendor/', '/package'];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
foreach ($validNames as $name) {
|
|
foreach ($validNames as $name) {
|
|
|
if (!$generator->validatePackageName($name)) {
|
|
if (!$generator->validatePackageName($name)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
foreach ($invalidNames as $name) {
|
|
foreach ($invalidNames as $name) {
|
|
|
if ($generator->validatePackageName($name)) {
|
|
if ($generator->validatePackageName($name)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-test("ComposerGenerator - Namespace Conversion", function() {
|
|
|
|
|
|
|
+test("ComposerGenerator - Namespace Conversion", function () {
|
|
|
$generator = new ComposerGenerator();
|
|
$generator = new ComposerGenerator();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$testCases = [
|
|
$testCases = [
|
|
|
'sixshop/hello-world' => 'SixShop\\HelloWorld\\',
|
|
'sixshop/hello-world' => 'SixShop\\HelloWorld\\',
|
|
|
'vendor/simple' => 'Vendor\\Simple\\',
|
|
'vendor/simple' => 'Vendor\\Simple\\',
|
|
|
'my-vendor/complex-name' => 'MyVendor\\ComplexName\\'
|
|
'my-vendor/complex-name' => 'MyVendor\\ComplexName\\'
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
foreach ($testCases as $package => $expected) {
|
|
foreach ($testCases as $package => $expected) {
|
|
|
$result = $generator->convertPackageNameToNamespace($package);
|
|
$result = $generator->convertPackageNameToNamespace($package);
|
|
|
if ($result !== $expected) {
|
|
if ($result !== $expected) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-test("ComposerGenerator - Generate composer.json", function() {
|
|
|
|
|
|
|
+test("ComposerGenerator - Generate composer.json", function () {
|
|
|
$testDir = setupTestDir();
|
|
$testDir = setupTestDir();
|
|
|
$generator = new ComposerGenerator();
|
|
$generator = new ComposerGenerator();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$packageInfo = [
|
|
$packageInfo = [
|
|
|
'packageName' => 'sixshop/test-extension',
|
|
'packageName' => 'sixshop/test-extension',
|
|
|
'description' => 'A test extension',
|
|
'description' => 'A test extension',
|
|
|
'namespace' => 'SixShop\\TestExtension\\',
|
|
'namespace' => 'SixShop\\TestExtension\\',
|
|
|
'id' => 'sixshop-test-extension'
|
|
'id' => 'sixshop-test-extension'
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = $generator->generateComposerJson($packageInfo, $testDir);
|
|
$result = $generator->generateComposerJson($packageInfo, $testDir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return $result && file_exists($testDir . '/composer.json');
|
|
return $result && file_exists($testDir . '/composer.json');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Test 3: ModelGenerator
|
|
// Test 3: ModelGenerator
|
|
|
-test("ModelGenerator - Generate Model", function() {
|
|
|
|
|
|
|
+test("ModelGenerator - Generate Model", function () {
|
|
|
$testDir = setupTestDir();
|
|
$testDir = setupTestDir();
|
|
|
$generator = new ModelGenerator();
|
|
$generator = new ModelGenerator();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$fields = [
|
|
$fields = [
|
|
|
['name' => 'id', 'type' => 'biginteger'],
|
|
['name' => 'id', 'type' => 'biginteger'],
|
|
|
['name' => 'name', 'type' => 'string', 'length' => 100],
|
|
['name' => 'name', 'type' => 'string', 'length' => 100],
|
|
|
['name' => 'price', 'type' => 'decimal', 'precision' => 10, 'scale' => 2]
|
|
['name' => 'price', 'type' => 'decimal', 'precision' => 10, 'scale' => 2]
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$extensionInfo = [
|
|
$extensionInfo = [
|
|
|
'namespace' => 'SixShop\\Test\\',
|
|
'namespace' => 'SixShop\\Test\\',
|
|
|
'packageName' => 'sixshop/test',
|
|
'packageName' => 'sixshop/test',
|
|
|
'id' => 'sixshop-test'
|
|
'id' => 'sixshop-test'
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = $generator->generateModel('products', 'Products table', $fields, $extensionInfo, $testDir);
|
|
$result = $generator->generateModel('products', 'Products table', $fields, $extensionInfo, $testDir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return $result && file_exists($testDir . '/src/Model/ProductModel.php');
|
|
return $result && file_exists($testDir . '/src/Model/ProductModel.php');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-// Test 4: EntityGenerator
|
|
|
|
|
-test("EntityGenerator - Generate Entity", function() {
|
|
|
|
|
|
|
+// Test 4: EntityGenerator
|
|
|
|
|
+test("EntityGenerator - Generate Entity", function () {
|
|
|
$testDir = setupTestDir();
|
|
$testDir = setupTestDir();
|
|
|
$generator = new EntityGenerator();
|
|
$generator = new EntityGenerator();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$fields = [
|
|
$fields = [
|
|
|
['name' => 'id', 'type' => 'biginteger'],
|
|
['name' => 'id', 'type' => 'biginteger'],
|
|
|
['name' => 'name', 'type' => 'string']
|
|
['name' => 'name', 'type' => 'string']
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$extensionInfo = [
|
|
$extensionInfo = [
|
|
|
'namespace' => 'SixShop\\Test\\',
|
|
'namespace' => 'SixShop\\Test\\',
|
|
|
'packageName' => 'sixshop/test',
|
|
'packageName' => 'sixshop/test',
|
|
|
'id' => 'sixshop-test'
|
|
'id' => 'sixshop-test'
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = $generator->generateEntity('products', 'Products table', $fields, $extensionInfo, $testDir);
|
|
$result = $generator->generateEntity('products', 'Products table', $fields, $extensionInfo, $testDir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return $result && file_exists($testDir . '/src/Entity/ProductEntity.php');
|
|
return $result && file_exists($testDir . '/src/Entity/ProductEntity.php');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Test 5: ControllerGenerator
|
|
// Test 5: ControllerGenerator
|
|
|
-test("ControllerGenerator - Generate Controllers", function() {
|
|
|
|
|
|
|
+test("ControllerGenerator - Generate Controllers", function () {
|
|
|
$testDir = setupTestDir();
|
|
$testDir = setupTestDir();
|
|
|
$generator = new ControllerGenerator();
|
|
$generator = new ControllerGenerator();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$fields = [
|
|
$fields = [
|
|
|
['name' => 'id', 'type' => 'biginteger'],
|
|
['name' => 'id', 'type' => 'biginteger'],
|
|
|
['name' => 'name', 'type' => 'string']
|
|
['name' => 'name', 'type' => 'string']
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$extensionInfo = [
|
|
$extensionInfo = [
|
|
|
'namespace' => 'SixShop\\Test\\',
|
|
'namespace' => 'SixShop\\Test\\',
|
|
|
'packageName' => 'sixshop/test',
|
|
'packageName' => 'sixshop/test',
|
|
|
'id' => 'sixshop-test'
|
|
'id' => 'sixshop-test'
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = $generator->generateControllers('products', 'Products table', $fields, $extensionInfo, $testDir);
|
|
$result = $generator->generateControllers('products', 'Products table', $fields, $extensionInfo, $testDir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$adminExists = file_exists($testDir . '/src/Controller/Admin/ProductController.php');
|
|
$adminExists = file_exists($testDir . '/src/Controller/Admin/ProductController.php');
|
|
|
$apiExists = file_exists($testDir . '/src/Controller/Api/ProductController.php');
|
|
$apiExists = file_exists($testDir . '/src/Controller/Api/ProductController.php');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return $result && $adminExists && $apiExists;
|
|
return $result && $adminExists && $apiExists;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Test 6: Complete Workflow
|
|
// Test 6: Complete Workflow
|
|
|
-test("Complete Workflow - All Components", function() {
|
|
|
|
|
|
|
+test("Complete Workflow - All Components", function () {
|
|
|
$testDir = setupTestDir();
|
|
$testDir = setupTestDir();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$tableName = 'orders';
|
|
$tableName = 'orders';
|
|
|
$tableComment = 'Orders management';
|
|
$tableComment = 'Orders management';
|
|
|
$fields = [
|
|
$fields = [
|
|
@@ -261,64 +261,64 @@ test("Complete Workflow - All Components", function() {
|
|
|
['name' => 'total', 'type' => 'decimal', 'precision' => 10, 'scale' => 2],
|
|
['name' => 'total', 'type' => 'decimal', 'precision' => 10, 'scale' => 2],
|
|
|
['name' => 'status', 'type' => 'string', 'length' => 20, 'default' => 'pending']
|
|
['name' => 'status', 'type' => 'string', 'length' => 20, 'default' => 'pending']
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$extensionInfo = [
|
|
$extensionInfo = [
|
|
|
'namespace' => 'SixShop\\Shop\\',
|
|
'namespace' => 'SixShop\\Shop\\',
|
|
|
'packageName' => 'sixshop/shop',
|
|
'packageName' => 'sixshop/shop',
|
|
|
'id' => 'sixshop-shop'
|
|
'id' => 'sixshop-shop'
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Generate migration
|
|
// Generate migration
|
|
|
$migrationGenerator = new MigrationGenerator($testDir . '/database/migrations');
|
|
$migrationGenerator = new MigrationGenerator($testDir . '/database/migrations');
|
|
|
$migrationResult = $migrationGenerator->generateMigration($tableName, $fields, 'create');
|
|
$migrationResult = $migrationGenerator->generateMigration($tableName, $fields, 'create');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Generate model
|
|
// Generate model
|
|
|
$modelGenerator = new ModelGenerator();
|
|
$modelGenerator = new ModelGenerator();
|
|
|
$modelResult = $modelGenerator->generateModel($tableName, $tableComment, $fields, $extensionInfo, $testDir);
|
|
$modelResult = $modelGenerator->generateModel($tableName, $tableComment, $fields, $extensionInfo, $testDir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Generate entity
|
|
// Generate entity
|
|
|
$entityGenerator = new EntityGenerator();
|
|
$entityGenerator = new EntityGenerator();
|
|
|
$entityResult = $entityGenerator->generateEntity($tableName, $tableComment, $fields, $extensionInfo, $testDir);
|
|
$entityResult = $entityGenerator->generateEntity($tableName, $tableComment, $fields, $extensionInfo, $testDir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Generate controllers
|
|
// Generate controllers
|
|
|
$controllerGenerator = new ControllerGenerator();
|
|
$controllerGenerator = new ControllerGenerator();
|
|
|
$controllerResult = $controllerGenerator->generateControllers($tableName, $tableComment, $fields, $extensionInfo, $testDir);
|
|
$controllerResult = $controllerGenerator->generateControllers($tableName, $tableComment, $fields, $extensionInfo, $testDir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Verify all files exist
|
|
// Verify all files exist
|
|
|
$migrationExists = !empty(glob($testDir . '/database/migrations/*_create_orders_table.php'));
|
|
$migrationExists = !empty(glob($testDir . '/database/migrations/*_create_orders_table.php'));
|
|
|
$modelExists = file_exists($testDir . '/src/Model/OrderModel.php');
|
|
$modelExists = file_exists($testDir . '/src/Model/OrderModel.php');
|
|
|
$entityExists = file_exists($testDir . '/src/Entity/OrderEntity.php');
|
|
$entityExists = file_exists($testDir . '/src/Entity/OrderEntity.php');
|
|
|
$adminControllerExists = file_exists($testDir . '/src/Controller/Admin/OrderController.php');
|
|
$adminControllerExists = file_exists($testDir . '/src/Controller/Admin/OrderController.php');
|
|
|
$apiControllerExists = file_exists($testDir . '/src/Controller/Api/OrderController.php');
|
|
$apiControllerExists = file_exists($testDir . '/src/Controller/Api/OrderController.php');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return $migrationResult && $modelResult && $entityResult && $controllerResult &&
|
|
return $migrationResult && $modelResult && $entityResult && $controllerResult &&
|
|
|
$migrationExists && $modelExists && $entityExists && $adminControllerExists && $apiControllerExists;
|
|
$migrationExists && $modelExists && $entityExists && $adminControllerExists && $apiControllerExists;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Test 7: Field Type Handling
|
|
// Test 7: Field Type Handling
|
|
|
-test("Field Type Support", function() {
|
|
|
|
|
|
|
+test("Field Type Support", function () {
|
|
|
$generator = new MigrationGenerator();
|
|
$generator = new MigrationGenerator();
|
|
|
$supportedTypes = $generator->getSupportedFieldTypes();
|
|
$supportedTypes = $generator->getSupportedFieldTypes();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$expectedTypes = [
|
|
$expectedTypes = [
|
|
|
'integer', 'biginteger', 'string', 'text', 'boolean',
|
|
'integer', 'biginteger', 'string', 'text', 'boolean',
|
|
|
'decimal', 'float', 'datetime', 'timestamp', 'date',
|
|
'decimal', 'float', 'datetime', 'timestamp', 'date',
|
|
|
'time', 'binary', 'json'
|
|
'time', 'binary', 'json'
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
foreach ($expectedTypes as $type) {
|
|
foreach ($expectedTypes as $type) {
|
|
|
if (!in_array($type, $supportedTypes)) {
|
|
if (!in_array($type, $supportedTypes)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Test 8: Template Content Validation
|
|
// Test 8: Template Content Validation
|
|
|
-test("Template Content Quality", function() {
|
|
|
|
|
|
|
+test("Template Content Quality", function () {
|
|
|
$testDir = setupTestDir();
|
|
$testDir = setupTestDir();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Generate complete set
|
|
// Generate complete set
|
|
|
$generator = new ModelGenerator();
|
|
$generator = new ModelGenerator();
|
|
|
$extensionInfo = [
|
|
$extensionInfo = [
|
|
@@ -326,15 +326,15 @@ test("Template Content Quality", function() {
|
|
|
'packageName' => 'sixshop/test',
|
|
'packageName' => 'sixshop/test',
|
|
|
'id' => 'sixshop-test'
|
|
'id' => 'sixshop-test'
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$fields = [
|
|
$fields = [
|
|
|
['name' => 'name', 'type' => 'string', 'length' => 100]
|
|
['name' => 'name', 'type' => 'string', 'length' => 100]
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$generator->generateModel('items', 'Test items', $fields, $extensionInfo, $testDir);
|
|
$generator->generateModel('items', 'Test items', $fields, $extensionInfo, $testDir);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$content = file_get_contents($testDir . '/src/Model/ItemModel.php');
|
|
$content = file_get_contents($testDir . '/src/Model/ItemModel.php');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Check for required elements
|
|
// Check for required elements
|
|
|
$checks = [
|
|
$checks = [
|
|
|
'class ItemModel extends Model',
|
|
'class ItemModel extends Model',
|
|
@@ -343,13 +343,13 @@ test("Template Content Quality", function() {
|
|
|
"'pk' => 'id'",
|
|
"'pk' => 'id'",
|
|
|
"'auto_timestamp' => true"
|
|
"'auto_timestamp' => true"
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
foreach ($checks as $check) {
|
|
foreach ($checks as $check) {
|
|
|
if (strpos($content, $check) === false) {
|
|
if (strpos($content, $check) === false) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -374,4 +374,4 @@ echo "- Comprehensive demo: php test/comprehensive_demo.php\n";
|
|
|
// Cleanup
|
|
// Cleanup
|
|
|
cleanupTestDir();
|
|
cleanupTestDir();
|
|
|
|
|
|
|
|
-echo "\n🧹 Cleanup completed.\n";
|
|
|
|
|
|
|
+echo "\n🧹 Cleanup completed.\n";
|