1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
<?php
namespace Illuminate\Tests\Integration\Generators;
class TestMakeCommandTest extends TestCase
{
protected $files = [
'tests/Feature/FooTest.php',
'tests/Unit/FooTest.php',
];
public function testItCanGenerateFeatureTest()
{
$this->artisan('make:test', ['name' => 'FooTest'])
->assertExitCode(0);
$this->assertFileContains([
'namespace Tests\Feature;',
'use Illuminate\Foundation\Testing\RefreshDatabase;',
'use Illuminate\Foundation\Testing\WithFaker;',
'use Tests\TestCase;',
'class FooTest extends TestCase',
], 'tests/Feature/FooTest.php');
}
public function testItCanGenerateUnitTest()
{
$this->artisan('make:test', ['name' => 'FooTest', '--unit' => true])
->assertExitCode(0);
$this->assertFileContains([
'namespace Tests\Unit;',
'use PHPUnit\Framework\TestCase;',
'class FooTest extends TestCase',
], 'tests/Unit/FooTest.php');
}
public function testItCanGenerateFeatureTestUsingPest()
{
$this->artisan('make:test', ['name' => 'FooTest', '--pest' => true])
->assertExitCode(0);
$this->assertFileContains([
'test(\'example\', function () {',
'$response = $this->get(\'/\');',
'$response->assertStatus(200);',
], 'tests/Feature/FooTest.php');
}
public function testItCanGenerateUnitTestUsingPest()
{
$this->artisan('make:test', ['name' => 'FooTest', '--unit' => true, '--pest' => true])
->assertExitCode(0);
$this->assertFileContains([
'test(\'example\', function () {',
'expect(true)->toBeTrue();',
], 'tests/Unit/FooTest.php');
}
}
|