. */ namespace Tests\Feature; use App\Account; use App\Space; use App\AccountCreationRequestToken; use App\AccountCreationToken; use App\Http\Middleware\ValidateJSON; use Tests\TestCase; use Carbon\Carbon; class ApiPushNotificationTest extends TestCase { protected $tokenRoute = '/api/push_notification'; protected $method = 'POST'; protected $pnProvider = 'fcm'; protected $pnParam = 'param'; protected $pnPrid = 'id'; protected $type = 'message'; public function testCorrectParameters() { $account = Account::factory()->create(); $account->generateUserApiKey(); $this->keyAuthenticated($account) ->json($this->method, $this->tokenRoute, [ 'pn_provider' => $this->pnProvider, 'pn_param' => $this->pnParam, 'pn_prid' => $this->pnPrid, 'type' => $this->type, 'call_id' => '@blabla@' ])->assertJsonValidationErrors(['call_id']); $this->keyAuthenticated($account) ->json($this->method, $this->tokenRoute, [ 'pn_provider' => $this->pnProvider, 'pn_param' => $this->pnParam, 'pn_prid' => $this->pnPrid, 'type' => $this->type ])->assertStatus(503); $this->keyAuthenticated($account) ->json($this->method, $this->tokenRoute, [ 'pn_provider' => $this->pnProvider, 'pn_param' => $this->pnParam, 'pn_prid' => $this->pnPrid, 'type' => $this->type, 'call_id' => 'call_id-123' ])->assertStatus(503); $this->keyAuthenticated($account) ->json($this->method, $this->tokenRoute, [ 'pn_provider' => $this->pnProvider, 'pn_param' => 'ABCD1234.org.linphone.phone.voip', 'pn_prid' => $this->pnPrid, 'type' => $this->type, 'call_id' => 'call_id-123' ])->assertStatus(503); $this->keyAuthenticated($account) ->json($this->method, $this->tokenRoute, [ 'pn_provider' => $this->pnProvider, 'pn_param' => '@blabla@', 'pn_prid' => $this->pnPrid, 'type' => $this->type, 'call_id' => 'call_id-123' ])->assertJsonValidationErrors(['pn_param']); } }