laravel-websockets/tests/Dashboard/SendMessageTest.php

44 lines
1.3 KiB
PHP
Raw Normal View History

2020-08-24 06:03:52 +00:00
<?php
2020-09-10 19:59:26 +00:00
namespace BeyondCode\LaravelWebSockets\Test\Dashboard;
2020-08-24 06:03:52 +00:00
2020-09-10 19:59:26 +00:00
use BeyondCode\LaravelWebSockets\Test\Models\User;
use BeyondCode\LaravelWebSockets\Test\TestCase;
2020-08-24 06:03:52 +00:00
class SendMessageTest extends TestCase
{
2020-09-10 19:59:26 +00:00
public function test_can_send_message()
2020-08-24 06:03:52 +00:00
{
$this->actingAs(factory(User::class)->create())
->json('POST', route('laravel-websockets.event'), [
'appId' => '1234',
2020-09-15 20:46:37 +00:00
'key' => 'TestKey',
'secret' => 'TestSecret',
2020-08-24 06:03:52 +00:00
'channel' => 'test-channel',
'event' => 'some-event',
'data' => json_encode(['data' => 'yes']),
])
->seeJson([
2020-09-15 20:46:37 +00:00
'ok' => false,
2020-08-24 06:03:52 +00:00
]);
2020-08-24 06:39:05 +00:00
2020-09-15 20:46:37 +00:00
$this->markTestIncomplete(
'Broadcasting is not possible to be tested without receiving a Pusher error.'
);
2020-08-24 06:39:05 +00:00
}
2020-09-10 19:59:26 +00:00
public function test_cant_send_message_for_invalid_app()
2020-08-24 06:03:52 +00:00
{
$this->actingAs(factory(User::class)->create())
->json('POST', route('laravel-websockets.event'), [
'appId' => '9999',
2020-09-15 20:46:37 +00:00
'key' => 'TestKey',
'secret' => 'TestSecret',
2020-08-24 06:03:52 +00:00
'channel' => 'test-channel',
'event' => 'some-event',
'data' => json_encode(['data' => 'yes']),
])
->assertResponseStatus(422);
}
}