153 - Testing a Console Command

This commit is contained in:
Adam Wathan
2017-12-08 14:35:50 -05:00
parent d5cf2592b1
commit d4bcb02a8e
8 changed files with 65 additions and 5 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace Tests\Feature;
use App\Invitation;
use Tests\TestCase;
use App\Facades\InvitationCode;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class InvitePromoterTest extends TestCase
{
use RefreshDatabase;
/** @test */
function inviting_a_promoter_via_the_cli()
{
InvitationCode::shouldReceive('generate')->andReturn('TESTCODE1234');
$this->artisan('invite-promoter', ['email' => 'john@example.com']);
$this->assertEquals(1, Invitation::count());
$invitation = Invitation::first();
$this->assertEquals('john@example.com', $invitation->email);
$this->assertEquals('TESTCODE1234', $invitation->code);
}
}