Skip to content

Commit

Permalink
Adds command and stub for generating a Blitz load test in the correct…
Browse files Browse the repository at this point in the history
… place
  • Loading branch information
craigpaul committed Nov 26, 2023
1 parent deb4bb3 commit 1604df8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/Console/Commands/TestMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace CraigPaul\Blitz\Console\Commands;

use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand('blitz:make', 'Create a new test class')]
class TestMakeCommand extends GeneratorCommand
{
/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'Test';

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return __DIR__.'/stubs/test.stub';
}

/**
* Get the destination class path.
*
* @param string $name
*
* @return string
*/
protected function getPath($name)
{
$name = Str::replaceFirst($this->rootNamespace(), '', $name);

return $this->getLaravel()->basePath('tests/Blitz').str_replace('\\', '/', $name).'.php';
}

/**
* Get the root namespace for the class.
*
* @return string
*/
protected function rootNamespace()
{
return 'Tests\\Blitz';
}
}
13 changes: 13 additions & 0 deletions src/Console/Commands/stubs/test.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace {{ namespace }};

use CraigPaul\Blitz\Testing\TestCase;

class {{ class }} extends TestCase
{
public function handle(): void
{
//
}
}

0 comments on commit 1604df8

Please sign in to comment.