. */ namespace Tests\Feature; use App\Password; use Illuminate\Testing\Fluent\AssertableJson; use Tests\TestCase; class ApiAccountMessageTest extends TestCase { protected $route = '/api/messages'; protected $method = 'POST'; public function testRequest() { $password = Password::factory()->admin()->create(); $password->account->generateUserApiKey(); $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'); }); } }