小程序用户改用门店登录
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\UserModel;
|
||||
use App\Models\StoreModel;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Modules\SystemUser\Models\SysUserModel;
|
||||
use Tests\TestCase;
|
||||
@@ -13,6 +13,7 @@ use Tests\TestCase;
|
||||
* - SQLite :memory: + RefreshDatabase,每个测试方法独立迁移
|
||||
* - 双端认证辅助:createToken 签发 Sanctum token,withToken 注入 Authorization 头,
|
||||
* 走真实链路(auth:sanctum → AuthGuardMiddleware 双端隔离 → abilities 校验)
|
||||
* - 门店即用户:小程序端登录主体为 StoreModel(store 表)
|
||||
*/
|
||||
abstract class ProcurementTestCase extends TestCase
|
||||
{
|
||||
@@ -52,16 +53,16 @@ abstract class ProcurementTestCase extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* 以小程序用户身份发起后续请求(token abilities 默认 ['mini'])
|
||||
* 以门店身份(小程序端)发起后续请求(token abilities 默认 ['mini'])
|
||||
*
|
||||
* @param array<int, string> $abilities
|
||||
*/
|
||||
protected function actingAsMiniUser(UserModel $user, array $abilities = ['mini']): UserModel
|
||||
protected function actingAsMiniStore(StoreModel $store, array $abilities = ['mini']): StoreModel
|
||||
{
|
||||
$this->app['auth']->forgetGuards();
|
||||
|
||||
$this->withToken($user->createToken('mini', $abilities)->plainTextToken);
|
||||
$this->withToken($store->createToken('mini', $abilities)->plainTextToken);
|
||||
|
||||
return $user;
|
||||
return $store;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user