laravel-websockets/tests/ClientProviders/ConfigAppProviderTest.php

88 lines
2.6 KiB
PHP
Raw Normal View History

2018-12-01 13:12:15 +00:00
<?php
namespace BeyondCode\LaravelWebSockets\Tests\ClientProviders;
use BeyondCode\LaravelWebSockets\Apps\ConfigAppProvider;
use BeyondCode\LaravelWebSockets\Tests\TestCase;
class ConfigAppProviderTest extends TestCase
{
/** @var \BeyondCode\LaravelWebSockets\Apps\ConfigAppProvider */
protected $configAppProvider;
public function setUp()
{
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-01 13:17:32 +00:00
/** @var $app */
$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-01 13:12:15 +00:00
}