FakeAuthManager class
A fake AuthManager for testing.
Routes all guard operations through an in-memory _FakeGuard instead of
resolving real guards from config. Supports assertions and login tracking.
final fake = Auth.fake(user: myUser);
expect(Auth.check(), isTrue);
expect(Auth.user<User>(), same(myUser));
await Auth.logout();
fake.assertLoggedOut();
- Inheritance
-
- Object
- AuthManager
- FakeAuthManager
Constructors
- FakeAuthManager({Authenticatable? user})
- Creates a fake auth manager.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasUserFactory → bool
-
Whether a user factory has been registered.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
assertLoggedIn(
) → void - Assert that a user is currently authenticated.
-
assertLoggedOut(
) → void - Assert that no user is currently authenticated.
-
assertLoginAttempted(
) → void - Assert that at least one login attempt was made.
-
assertLoginCount(
int expected) → void -
Assert that exactly
expectedlogin attempts were made. -
createUser(
Map< String, dynamic> data) → Authenticatable -
Create a user instance from data using the registered factory.
inherited
-
extend(
String driver, Guard factory(Map< String, dynamic> config)) → void -
Register a custom guard driver.
inherited
-
forgetGuards(
) → void -
Clears the fake guard state.
override
-
guard(
[String? name]) → Guard -
Always returns the internal
_FakeGuard, regardless of guard name.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Clear all fake state — user, token, and login attempts.
-
setUserFactory(
Authenticatable factory(Map< String, dynamic> data)) → void -
Register the user factory for session restoration.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited