Changeset View
Changeset View
Standalone View
Standalone View
src/tests/TestCase.php
Show All 26 Lines | abstract class TestCase extends BaseTestCase | ||||
protected static function useRegularUrl(): void | protected static function useRegularUrl(): void | ||||
{ | { | ||||
// This will set base URL for all tests in a file. | // This will set base URL for all tests in a file. | ||||
// If we wanted to access both user and admin in one test | // If we wanted to access both user and admin in one test | ||||
// we can also just call post/get/whatever with full url | // we can also just call post/get/whatever with full url | ||||
\config( | \config( | ||||
[ | [ | ||||
'app.url' => str_replace( | 'app.url' => str_replace( | ||||
['//admin.', '//reseller.'], | ['//admin.', '//reseller.', '//services.'], | ||||
['//', '//'], | ['//', '//', '//'], | ||||
\config('app.url') | \config('app.url') | ||||
) | ) | ||||
] | ] | ||||
); | ); | ||||
url()->forceRootUrl(config('app.url')); | url()->forceRootUrl(config('app.url')); | ||||
} | } | ||||
/** | /** | ||||
* Set baseURL to the admin UI location | * Set baseURL to the admin UI location | ||||
*/ | */ | ||||
protected static function useAdminUrl(): void | protected static function useAdminUrl(): void | ||||
{ | { | ||||
// This will set base URL for all tests in a file. | // This will set base URL for all tests in a file. | ||||
// If we wanted to access both user and admin in one test | // If we wanted to access both user and admin in one test | ||||
// we can also just call post/get/whatever with full url | // we can also just call post/get/whatever with full url | ||||
// reset to base | |||||
self::useRegularUrl(); | |||||
// then modify it | |||||
\config(['app.url' => str_replace('//', '//admin.', \config('app.url'))]); | \config(['app.url' => str_replace('//', '//admin.', \config('app.url'))]); | ||||
url()->forceRootUrl(config('app.url')); | url()->forceRootUrl(config('app.url')); | ||||
} | } | ||||
/** | /** | ||||
* Set baseURL to the reseller UI location | * Set baseURL to the reseller UI location | ||||
*/ | */ | ||||
protected static function useResellerUrl(): void | protected static function useResellerUrl(): void | ||||
{ | { | ||||
// This will set base URL for all tests in a file. | // This will set base URL for all tests in a file. | ||||
// If we wanted to access both user and admin in one test | // If we wanted to access both user and admin in one test | ||||
// we can also just call post/get/whatever with full url | // we can also just call post/get/whatever with full url | ||||
// reset to base | |||||
self::useRegularUrl(); | |||||
// then modify it | |||||
\config(['app.url' => str_replace('//', '//reseller.', \config('app.url'))]); | \config(['app.url' => str_replace('//', '//reseller.', \config('app.url'))]); | ||||
url()->forceRootUrl(config('app.url')); | url()->forceRootUrl(config('app.url')); | ||||
} | } | ||||
/** | /** | ||||
* Set baseURL to the services location | * Set baseURL to the services location | ||||
*/ | */ | ||||
protected static function useServicesUrl(): void | protected static function useServicesUrl(): void | ||||
{ | { | ||||
// This will set base URL for all tests in a file. | // This will set base URL for all tests in a file. | ||||
// If we wanted to access both user and admin in one test | |||||
// we can also just call post/get/whatever with full url | |||||
// reset to base | |||||
self::useRegularUrl(); | |||||
// then modify it | |||||
\config(['app.url' => str_replace('//', '//services.', \config('app.url'))]); | \config(['app.url' => str_replace('//', '//services.', \config('app.url'))]); | ||||
url()->forceRootUrl(config('app.url')); | url()->forceRootUrl(config('app.url')); | ||||
} | } | ||||
} | } |