diff --git a/src/Traits/TestCaseTrait.php b/src/Traits/TestCaseTrait.php new file mode 100644 index 00000000..b806eb91 --- /dev/null +++ b/src/Traits/TestCaseTrait.php @@ -0,0 +1,55 @@ +baseUrl; + + $info = parse_url($url); + + $array = explode('.', $info['host']); + + $withoutDomain = (array_key_exists( + count($array) - 2, + $array, + ) ? $array[count($array) - 2] : '') . '.' . $array[count($array) - 1]; + + $newSubDomain = $info['scheme'] . '://' . $this->subDomain . '.' . $withoutDomain; + + return $this->baseUrl = $newSubDomain; + } + + /** + * Equivalent to passport:install but enough to run the tests. + */ + public function setupPassportOAuth2(): void + { + $client = (new ClientRepository())->createPersonalAccessClient( + null, + 'Testing Personal Access Client', + 'http://localhost', + ); + + $accessClient = new PersonalAccessClient(); + $accessClient->client_id = $client->id; + $accessClient->save(); + } +}