view src/Generator/Test/TestGenerator.php @ 40:2cf26b593f4a ls_dev_2025_09 tip

better support for different column types
author Luka Sitas <sitas.luka.97@gmail.com>
date Thu, 16 Oct 2025 10:54:04 -0400
parents 116b36f5e73b
children
line wrap: on
line source

<?php

namespace Wizard\MagicForger\Generator\Test;

use Symfony\Component\Console\Attribute\AsCommand;
use Wizard\MagicForger\Generator\BaseGenerator;
use Wizard\MagicForger\Replacer;
use Illuminate\Support\Str;

#[AsCommand(name: 'mf:test')]
class TestGenerator extends BaseGenerator
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $name = 'mf:test';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generates the Test File for a table.';

    /**
     * The type of class being generated.
     *
     * @var string
     */
    protected $type = 'Test';

    /**
     * Execute the console command.
     */
    public function handle()
    {
			parent::handle();
    }

    /**
     * Get the stub file for the generator.
     *
     * @return string
     */
    protected function getStub()
    {
        return $this->resolveStubPath('/stubs/test.stub');
    }

    /**
     * Resolve the fully-qualified path to the stub.
     *
     * @param  string  $stub
     * @return string
     */
    protected function resolveStubPath($stub)
    {
        return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
            ? $customPath
            : __DIR__.$stub;
    }

    protected function getClassName($name)
    {
        return $this->test_name($name);
    }

    /**
     * Get the stub file for the generator.
     *
     * @return string
     */
    protected function getPath($name = null)
    {
        return str_replace(['App\\', '\\'], ['app/', '/'], $this->getTestNamespace() . '/' . $this->test_name($this->getTableInput()) . '.php');
    }
}