Skip to content

Commit

Permalink
Merge pull request #1923 from solomon-ochepa/optimize-unit-tests
Browse files Browse the repository at this point in the history
Optimize unit tests
  • Loading branch information
dcblogdev authored Sep 10, 2024
2 parents 59cf936 + 651a267 commit 7a2a65e
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 59 deletions.
6 changes: 1 addition & 5 deletions src/Commands/Make/TestMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ protected function getOptions()
protected function getTemplateContents()
{
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
$stub = '/unit-test.stub';

if ($this->option('feature')) {
$stub = '/feature-test.stub';
}
$stub = '/tests/'.(($this->option('feature')) ? 'feature' : 'unit').'.stub';

return (new Stub($stub, [
'NAMESPACE' => $this->getClassNamespace($module),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
namespace $NAMESPACE$;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class $CLASS$ extends TestCase
{
/**
* A basic feature test example.
* A basic test example.
*/
public function testExample(): void
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');

Expand Down
16 changes: 16 additions & 0 deletions src/Commands/stubs/tests/unit.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace $NAMESPACE$;

use Tests\TestCase;

class $CLASS$ extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}
20 changes: 0 additions & 20 deletions src/Commands/stubs/unit-test.stub

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
namespace Modules\Blog\SuperTests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class EloquentPostRepositoryTest extends TestCase
{
/**
* A basic feature test example.
* A basic test example.
*/
public function testExample(): void
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
namespace Modules\Blog\SuperTests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class EloquentPostRepositoryTest extends TestCase
{
/**
* A basic feature test example.
* A basic test example.
*/
public function testExample(): void
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
namespace Modules\Blog\SuperTests\Unit;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class EloquentPostRepositoryTest extends TestCase
{
/**
* A basic unit test example.
*
* @return void
* A basic test example.
*/
public function testExample()
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
namespace Modules\Blog\Tests\Unit;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class EloquentPostRepositoryTest extends TestCase
{
/**
* A basic unit test example.
*
* @return void
* A basic test example.
*/
public function testExample()
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
namespace Modules\Blog\Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class EloquentPostRepositoryTest extends TestCase
{
/**
* A basic feature test example.
* A basic test example.
*/
public function testExample(): void
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
namespace Modules\Blog\Tests\Unit;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class EloquentPostRepositoryTest extends TestCase
{
/**
* A basic unit test example.
*
* @return void
* A basic test example.
*/
public function testExample()
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
Expand Down

0 comments on commit 7a2a65e

Please sign in to comment.