From af04066dd0f72cb040463bf39db62150c40b80ff Mon Sep 17 00:00:00 2001 From: Italo Baeza Cabrera Date: Fri, 28 Oct 2022 17:17:07 -0300 Subject: [PATCH] Adds Service Provider tests. --- tests/ServiceProviderTest.php | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/ServiceProviderTest.php diff --git a/tests/ServiceProviderTest.php b/tests/ServiceProviderTest.php new file mode 100644 index 0000000..758878d --- /dev/null +++ b/tests/ServiceProviderTest.php @@ -0,0 +1,64 @@ +app->make('config')->get('webauthn') + ); + } + + public function test_publishes_config(): void + { + static::assertSame( + [WebAuthnServiceProvider::CONFIG => $this->app->configPath('webauthn.php')], + ServiceProvider::$publishGroups['config'] + ); + } + + public function test_publishes_migrations(): void + { + $format = now()->format('Y_m_d_His'); + + static::assertSame( + [ + realpath(WebAuthnServiceProvider::MIGRATIONS . '/2022_07_01_000000_create_webauthn_credentials.php') => + $this->app->databasePath("migrations/{$format}_create_webauthn_credentials.php"), + ], + ServiceProvider::pathsToPublish(WebAuthnServiceProvider::class, 'migrations') + ); + } + + public function test_bounds_user(): void + { + static::assertNull($this->app->make(WebAuthnAuthenticatable::class)); + + $user = new class extends Fluent implements WebAuthnAuthenticatable { + use WebAuthnAuthentication; + }; + + $this->app->instance(Authenticatable::class, $user); + + static::assertSame($user, $this->app->make(WebAuthnAuthenticatable::class)); + } + + public function test_publishes_routes_file(): void + { + static::assertSame( + [WebAuthnServiceProvider::ROUTES => $this->app->basePath('routes/webauthn.php')], + ServiceProvider::$publishGroups['routes'] + ); + } +}