From 775861ab8892cb68716a6f0affa0e4decf3f13dd Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Mon, 3 Dec 2018 10:06:40 +0100 Subject: [PATCH] Allow non-numeric app ids --- src/Apps/App.php | 6 +----- src/Apps/AppProvider.php | 2 +- src/Apps/ConfigAppProvider.php | 2 +- tests/ClientProviders/AppTest.php | 8 -------- tests/HttpApi/FetchChannelTest.php | 10 ++++++++++ 5 files changed, 13 insertions(+), 15 deletions(-) create mode 100644 tests/HttpApi/FetchChannelTest.php diff --git a/src/Apps/App.php b/src/Apps/App.php index 0b8e836..1b279dc 100644 --- a/src/Apps/App.php +++ b/src/Apps/App.php @@ -21,7 +21,7 @@ class App /** @var bool */ public $clientMessagesEnabled = false; - public static function findById(int $appId) + public static function findById($appId) { return app(AppProvider::class)->findById($appId); } @@ -33,10 +33,6 @@ class App public function __construct($appId, string $appKey, string $appSecret) { - if (!is_numeric($appId)) { - throw InvalidApp::appIdIsNotNumeric($appId); - } - if ($appKey === '') { throw InvalidApp::valueIsRequired('appKey', $appId); } diff --git a/src/Apps/AppProvider.php b/src/Apps/AppProvider.php index a0a5b54..04ee2b6 100644 --- a/src/Apps/AppProvider.php +++ b/src/Apps/AppProvider.php @@ -7,7 +7,7 @@ interface AppProvider /** @return array[BeyondCode\LaravelWebSockets\AppProviders\App] */ public function all(): array; - public function findById(int $appId): ?App; + public function findById($appId): ?App; public function findByKey(string $appKey): ?App; } \ No newline at end of file diff --git a/src/Apps/ConfigAppProvider.php b/src/Apps/ConfigAppProvider.php index 3ee0ad4..03754b4 100644 --- a/src/Apps/ConfigAppProvider.php +++ b/src/Apps/ConfigAppProvider.php @@ -24,7 +24,7 @@ class ConfigAppProvider implements AppProvider ->toArray(); } - public function findById(int $appId): ?App + public function findById($appId): ?App { $appAttributes = $this ->apps diff --git a/tests/ClientProviders/AppTest.php b/tests/ClientProviders/AppTest.php index 2fc13eb..12dd4c3 100644 --- a/tests/ClientProviders/AppTest.php +++ b/tests/ClientProviders/AppTest.php @@ -31,12 +31,4 @@ class AppTest extends TestCase new App(1, 'appKey', '', 'new'); } - - /** @test */ - public function it_will_not_accept_an_non_numeric_appId() - { - $this->expectException(InvalidApp::class); - - new App('appId', 'appKey', '', 'new'); - } } \ No newline at end of file diff --git a/tests/HttpApi/FetchChannelTest.php b/tests/HttpApi/FetchChannelTest.php new file mode 100644 index 0000000..0cda8fd --- /dev/null +++ b/tests/HttpApi/FetchChannelTest.php @@ -0,0 +1,10 @@ +