Skip to content

Commit b8313c9

Browse files
authored
[11.x] Add tests for make:interface and make:class command (#50395)
* add tests for interface command * add tests for `make:class` command * add testItCanGenerateInvokableClassFile
1 parent f7f8784 commit b8313c9

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Integration\Generators;
4+
5+
use Illuminate\Tests\Integration\Generators\TestCase;
6+
7+
class ClassMakeCommandTest extends TestCase
8+
{
9+
public function testItCanGenerateClassFile()
10+
{
11+
$this->artisan('make:class', ['name' => 'Reverb'])
12+
->assertExitCode(0);
13+
14+
$this->assertFileContains([
15+
'namespace App;',
16+
'class Reverb',
17+
'public function __construct()',
18+
], 'app/Reverb.php');
19+
}
20+
21+
public function testItCanGenerateInvokableClassFile()
22+
{
23+
$this->artisan('make:class', ['name' => 'Notification', '--invokable' => true])
24+
->assertExitCode(0);
25+
26+
$this->assertFileContains([
27+
'namespace App;',
28+
'class Notification',
29+
'public function __construct()',
30+
'public function __invoke()',
31+
], 'app/Notification.php');
32+
}
33+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Integration\Generators;
4+
5+
use Illuminate\Tests\Integration\Generators\TestCase;
6+
7+
class InterfaceMakeCommandTest extends TestCase
8+
{
9+
public function testItCanGenerateEnumFile()
10+
{
11+
$this->artisan('make:interface', ['name' => 'Gateway'])
12+
->assertExitCode(0);
13+
14+
$this->assertFileContains([
15+
'namespace App;',
16+
'interface Gateway',
17+
], 'app/Gateway.php');
18+
}
19+
}

0 commit comments

Comments
 (0)