Skip to content

Commit

Permalink
refactor: Update EloquentType::make() method signature
Browse files Browse the repository at this point in the history
The `EloquentType::make()` method signature has been updated to correctly instantiate the `EloquentConfig` object. This change ensures that the method behaves as expected and avoids any potential errors related to object instantiation.
  • Loading branch information
ewilan-riviere committed Jul 25, 2024
1 parent 4face42 commit 7f9715d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Typed/EloquentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function __construct(
protected ?string $typescript = null,
) {}

public static function make(EloquentConfig $config = new EloquentConfig): self
public static function make(EloquentConfig $config = new EloquentConfig()): self
{
return new self($config);
}
Expand Down
18 changes: 18 additions & 0 deletions tests/EloquentTypeArtisanMysqlTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Kiwilan\Typescriptable\Tests\TestCase;
use Kiwilan\Typescriptable\Typed\EloquentType;
use Kiwilan\Typescriptable\TypescriptableConfig;

beforeEach(function () {
eloquentConfig();
});

it('can be run with artisan', function () {
TestCase::setupDatabase('mysql');

EloquentType::make()->execute();

$eloquent = outputDir(TypescriptableConfig::eloquentFilename());
expect($eloquent)->toBeFile();
});
3 changes: 1 addition & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class TestCase extends Orchestra
protected function setUp(): void
{
parent::setUp();
self::init();

Factory::guessFactoryNamesUsing(
fn (string $modelName) => 'Kiwilan\\Typescriptable\\Database\\Factories\\'.class_basename($modelName).'Factory'
Expand Down Expand Up @@ -122,8 +123,6 @@ public static function init()

public static function setupDatabase(?string $type = null): void
{
self::init();

if (! $type) {
return;
}
Expand Down

0 comments on commit 7f9715d

Please sign in to comment.