2018-12-01 13:12:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace BeyondCode\LaravelWebSockets\Tests\ClientProviders;
|
|
|
|
|
|
2018-12-04 21:22:33 +00:00
|
|
|
use BeyondCode\LaravelWebSockets\Apps\ConfigAppProvider;
|
2020-03-04 09:58:39 +00:00
|
|
|
use BeyondCode\LaravelWebSockets\Tests\TestCase;
|
2018-12-01 13:12:15 +00:00
|
|
|
|
|
|
|
|
class ConfigAppProviderTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
/** @var \BeyondCode\LaravelWebSockets\Apps\ConfigAppProvider */
|
|
|
|
|
protected $configAppProvider;
|
|
|
|
|
|
2019-02-27 14:27:21 +00:00
|
|
|
public function setUp(): void
|
2018-12-01 13:12:15 +00:00
|
|
|
{
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
$this->configAppProvider = new ConfigAppProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @test */
|
2018-12-01 13:17:32 +00:00
|
|
|
public function it_can_get_apps_from_the_config_file()
|
2018-12-01 13:12:15 +00:00
|
|
|
{
|
|
|
|
|
$apps = $this->configAppProvider->all();
|
|
|
|
|
|
|
|
|
|
$this->assertCount(1, $apps);
|
|
|
|
|
|
2018-12-04 21:22:33 +00:00
|
|
|
/** @var $app */
|
2018-12-01 13:17:32 +00:00
|
|
|
$app = $apps[0];
|
2018-12-01 13:12:15 +00:00
|
|
|
|
2018-12-01 13:17:32 +00:00
|
|
|
$this->assertEquals('Test App', $app->name);
|
|
|
|
|
$this->assertEquals(1234, $app->id);
|
|
|
|
|
$this->assertEquals('TestKey', $app->key);
|
|
|
|
|
$this->assertEquals('TestSecret', $app->secret);
|
2018-12-01 15:24:36 +00:00
|
|
|
$this->assertFalse($app->clientMessagesEnabled);
|
2018-12-03 10:58:42 +00:00
|
|
|
$this->assertTrue($app->statisticsEnabled);
|
2018-12-01 13:12:15 +00:00
|
|
|
}
|
2018-12-04 09:15:37 +00:00
|
|
|
|
|
|
|
|
/** @test */
|
|
|
|
|
public function it_can_find_app_by_id()
|
|
|
|
|
{
|
|
|
|
|
$app = $this->configAppProvider->findById(0000);
|
|
|
|
|
|
|
|
|
|
$this->assertNull($app);
|
|
|
|
|
|
|
|
|
|
$app = $this->configAppProvider->findById(1234);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Test App', $app->name);
|
|
|
|
|
$this->assertEquals(1234, $app->id);
|
|
|
|
|
$this->assertEquals('TestKey', $app->key);
|
|
|
|
|
$this->assertEquals('TestSecret', $app->secret);
|
|
|
|
|
$this->assertFalse($app->clientMessagesEnabled);
|
|
|
|
|
$this->assertTrue($app->statisticsEnabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @test */
|
|
|
|
|
public function it_can_find_app_by_key()
|
|
|
|
|
{
|
|
|
|
|
$app = $this->configAppProvider->findByKey('InvalidKey');
|
|
|
|
|
|
|
|
|
|
$this->assertNull($app);
|
|
|
|
|
|
|
|
|
|
$app = $this->configAppProvider->findByKey('TestKey');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Test App', $app->name);
|
|
|
|
|
$this->assertEquals(1234, $app->id);
|
|
|
|
|
$this->assertEquals('TestKey', $app->key);
|
|
|
|
|
$this->assertEquals('TestSecret', $app->secret);
|
|
|
|
|
$this->assertFalse($app->clientMessagesEnabled);
|
|
|
|
|
$this->assertTrue($app->statisticsEnabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @test */
|
|
|
|
|
public function it_can_find_app_by_secret()
|
|
|
|
|
{
|
|
|
|
|
$app = $this->configAppProvider->findBySecret('InvalidSecret');
|
|
|
|
|
|
|
|
|
|
$this->assertNull($app);
|
|
|
|
|
|
|
|
|
|
$app = $this->configAppProvider->findBySecret('TestSecret');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Test App', $app->name);
|
|
|
|
|
$this->assertEquals(1234, $app->id);
|
|
|
|
|
$this->assertEquals('TestKey', $app->key);
|
|
|
|
|
$this->assertEquals('TestSecret', $app->secret);
|
|
|
|
|
$this->assertFalse($app->clientMessagesEnabled);
|
|
|
|
|
$this->assertTrue($app->statisticsEnabled);
|
|
|
|
|
}
|
2018-12-04 21:22:33 +00:00
|
|
|
}
|