Skip to content

Commit

Permalink
Accept clientID and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Chan authored and henrylamchan committed Jan 13, 2021
1 parent 926ac6f commit 24ee56a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/workos.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
// WorkOS API Key
"api_key" => env("WORKOS_API_KEY"),

// WorkOS Client ID
"client_id" => env("WORKOS_CLIENT_ID"),

// WorkOS Project ID
"project_id" => env("WORKOS_PROJECT_ID"),

Expand Down
7 changes: 6 additions & 1 deletion lib/WorkOSServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ public function register()

$config = $this->app["config"]->get("workos");
\WorkOS\WorkOS::setApiKey($config["api_key"]);
\WorkOS\WorkOS::setProjectId($config["project_id"]);
\WorkOS\WorkOS::setClientId($config["client_id"]);

if ($config["project_id"]) {
\WorkOS\WorkOS::setProjectId($config["project_id"]);
}

\WorkOS\WorkOS::setIdentifier(\WorkOS\Laravel\Version::SDK_IDENTIFIER);
\WorkOS\WorkOS::setVersion(\WorkOS\Laravel\Version::SDK_VERSION);

Expand Down
4 changes: 2 additions & 2 deletions tests/WorkOS/WorkOSServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ protected function setUp()
public function testRegisterWorkOSServiceProviderYieldsExpectedConfig()
{
$this->app["config"]->set("workos.api_key", "pk_secretsauce");
$this->app["config"]->set("workos.project_id", "project_pizza");
$this->app["config"]->set("workos.client_id", "client_pizza");
$this->app["config"]->set("workos.api_base_url", "https://workos-hop.com/");
$this->setupProvider($this->app);

$this->assertEquals("pk_secretsauce", \WorkOS\WorkOS::getApiKey());
$this->assertEquals("project_pizza", \WorkOS\WorkOS::getProjectId());
$this->assertEquals("client_pizza", \WorkOS\WorkOS::getClientId());
$this->assertEquals("https://workos-hop.com/", \WorkOS\WorkOS::getApiBaseUrl());
}
}

0 comments on commit 24ee56a

Please sign in to comment.