Skip to content

Commit

Permalink
[11.x] Add tests for make:interface and make:class command (larav…
Browse files Browse the repository at this point in the history
…el#50395)

* add tests for interface command

* add tests for  `make:class` command

* add testItCanGenerateInvokableClassFile
  • Loading branch information
milwad-dev committed Mar 7, 2024
1 parent f7f8784 commit b8313c9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/Integration/Generators/ClassMakeCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Integration\Generators;

use Illuminate\Tests\Integration\Generators\TestCase;

class ClassMakeCommandTest extends TestCase
{
public function testItCanGenerateClassFile()
{
$this->artisan('make:class', ['name' => 'Reverb'])
->assertExitCode(0);

$this->assertFileContains([
'namespace App;',
'class Reverb',
'public function __construct()',
], 'app/Reverb.php');
}

public function testItCanGenerateInvokableClassFile()
{
$this->artisan('make:class', ['name' => 'Notification', '--invokable' => true])
->assertExitCode(0);

$this->assertFileContains([
'namespace App;',
'class Notification',
'public function __construct()',
'public function __invoke()',
], 'app/Notification.php');
}
}
19 changes: 19 additions & 0 deletions tests/Integration/Generators/InterfaceMakeCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Integration\Generators;

use Illuminate\Tests\Integration\Generators\TestCase;

class InterfaceMakeCommandTest extends TestCase
{
public function testItCanGenerateEnumFile()
{
$this->artisan('make:interface', ['name' => 'Gateway'])
->assertExitCode(0);

$this->assertFileContains([
'namespace App;',
'interface Gateway',
], 'app/Gateway.php');
}
}

0 comments on commit b8313c9

Please sign in to comment.