. */ namespace Tests\Feature; use App\Admin; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Testing\Fluent\AssertableJson; use Tests\TestCase; class AccountMessageTest extends TestCase { use RefreshDatabase; protected $route = '/api/messages'; protected $method = 'POST'; public function testRequest() { $admin = Admin::factory()->create(); $password = $admin->account->passwords()->first(); $password->account->generateApiKey(); $this->keyAuthenticated($password->account) ->json($this->method, $this->route, [ 'to' => '+badid', 'body' => 'foobar' ]) ->assertStatus(422); $this->keyAuthenticated($password->account) ->json($this->method, $this->route, [ 'to' => 'username@sip.linphone.org', 'body' => 'Message content' ]) ->assertStatus(200) ->assertJson(function (AssertableJson $json) { $json->has('id'); }); } }