Skip to content

chore: mockito dependency updates, dependency changes & analysis warnings/errors #5014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ import 'package:cloud_firestore_platform_interface/src/method_channel/method_cha

import '../utils/test_common.dart';

const String mockId = 'mock-id';
const String mockPath = 'foo/bar';

//ignore: avoid_implementing_value_types
class MockDocumentReference extends Mock implements DocumentReferencePlatform {
@override
String get path => super.noSuchMethod(Invocation.getter(#path), 'foo/bar');
String get path => super.noSuchMethod(Invocation.getter(#path),
returnValue: mockPath, returnValueForMissingStub: mockPath);
@override
String get id => super.noSuchMethod(Invocation.getter(#id), 'mock-id');
String get id => super.noSuchMethod(Invocation.getter(#id),
returnValue: mockId, returnValueForMissingStub: mockId);
}

const _kTransactionId = '1022';
Expand Down
1 change: 0 additions & 1 deletion packages/firebase_auth/firebase_auth/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
sdk: flutter
flutter_signin_button: ^1.0.0
google_sign_in: ^5.0.0-nullsafety
uuid: ^2.0.2

dependency_overrides:
firebase_auth:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @dart = 2.9

import 'dart:convert';
import 'dart:math';

import 'package:http/http.dart' as http;
import 'package:uuid/uuid.dart';
import 'package:firebase_auth/firebase_auth.dart';

FirebaseAuth auth = FirebaseAuth.instance;
Expand All @@ -19,7 +19,7 @@ String /*!*/ generateRandomEmail({
String prefix = '',
String suffix = '@foo.bar',
}) {
var uuid = Uuid().v1();
var uuid = createCryptoRandomString();
var testEmail = prefix + uuid + suffix;

return testEmail;
Expand Down Expand Up @@ -78,3 +78,11 @@ Future<void> ensureSignedOut() async {
await auth.signOut();
}
}

Random _random = Random.secure();

String createCryptoRandomString([int length = 32]) {
var values = List<int>.generate(length, (i) => _random.nextInt(256));

return base64Url.encode(values).toLowerCase();
}
88 changes: 59 additions & 29 deletions packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -651,31 +651,35 @@ class MockFirebaseAuth extends Mock
Stream<UserPlatform?> userChanges() {
return super.noSuchMethod(
Invocation.method(#userChanges, []),
const Stream<UserPlatform?>.empty(),
returnValue: const Stream<UserPlatform?>.empty(),
returnValueForMissingStub: const Stream<UserPlatform?>.empty(),
);
}

@override
Stream<UserPlatform?> idTokenChanges() {
return super.noSuchMethod(
Invocation.method(#idTokenChanges, []),
const Stream<UserPlatform?>.empty(),
returnValue: const Stream<UserPlatform?>.empty(),
returnValueForMissingStub: const Stream<UserPlatform?>.empty(),
);
}

@override
Stream<UserPlatform?> authStateChanges() {
return super.noSuchMethod(
Invocation.method(#authStateChanges, []),
const Stream<UserPlatform?>.empty(),
returnValue: const Stream<UserPlatform?>.empty(),
returnValueForMissingStub: const Stream<UserPlatform?>.empty(),
);
}

@override
FirebaseAuthPlatform delegateFor({FirebaseApp? app}) {
return super.noSuchMethod(
Invocation.method(#delegateFor, [], {#app: app}),
TestFirebaseAuthPlatform(),
returnValue: TestFirebaseAuthPlatform(),
returnValueForMissingStub: TestFirebaseAuthPlatform(),
);
}

Expand All @@ -686,7 +690,8 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#createUserWithEmailAndPassword, [email, password]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

Expand All @@ -700,7 +705,9 @@ class MockFirebaseAuth extends Mock
#signInWithPhoneNumber,
[phoneNumber, applicationVerifier],
),
neverEndingFuture<ConfirmationResultPlatform>(),
returnValue: neverEndingFuture<ConfirmationResultPlatform>(),
returnValueForMissingStub:
neverEndingFuture<ConfirmationResultPlatform>(),
);
}

Expand All @@ -710,15 +717,17 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#signInWithCredential, [credential]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

@override
Future<UserCredentialPlatform> signInWithCustomToken(String? token) {
return super.noSuchMethod(
Invocation.method(#signInWithCustomToken, [token]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

Expand All @@ -729,15 +738,17 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#signInWithEmailAndPassword, [email, password]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

@override
Future<UserCredentialPlatform> signInWithPopup(AuthProvider? provider) {
return super.noSuchMethod(
Invocation.method(#signInWithPopup, [provider]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

Expand All @@ -748,23 +759,26 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#signInWithEmailLink, [email, emailLink]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

@override
Future<void> signInWithRedirect(AuthProvider? provider) {
return super.noSuchMethod(
Invocation.method(#signInWithRedirect, [provider]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<UserCredentialPlatform> signInAnonymously() {
return super.noSuchMethod(
Invocation.method(#signInAnonymously, []),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

Expand All @@ -778,63 +792,71 @@ class MockFirebaseAuth extends Mock
#currentUser: currentUser,
#languageCode: languageCode,
}),
TestFirebaseAuthPlatform(),
returnValue: TestFirebaseAuthPlatform(),
returnValueForMissingStub: TestFirebaseAuthPlatform(),
);
}

@override
Future<UserCredentialPlatform> getRedirectResult() {
return super.noSuchMethod(
Invocation.method(#getRedirectResult, []),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

@override
Future<void> setLanguageCode(String? languageCode) {
return super.noSuchMethod(
Invocation.method(#setLanguageCode, [languageCode]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<void> useEmulator(String host, int port) {
return super.noSuchMethod(
Invocation.method(#useEmulator, [host, port]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<ActionCodeInfo> checkActionCode(String? code) {
return super.noSuchMethod(
Invocation.method(#checkActionCode, [code]),
neverEndingFuture<ActionCodeInfo>(),
returnValue: neverEndingFuture<ActionCodeInfo>(),
returnValueForMissingStub: neverEndingFuture<ActionCodeInfo>(),
);
}

@override
Future<void> confirmPasswordReset(String? code, String? newPassword) {
return super.noSuchMethod(
Invocation.method(#confirmPasswordReset, [code, newPassword]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<List<String>> fetchSignInMethodsForEmail(String? email) {
return super.noSuchMethod(
Invocation.method(#checkActionCode, [email]),
neverEndingFuture<List<String>>(),
returnValue: neverEndingFuture<List<String>>(),
returnValueForMissingStub: neverEndingFuture<List<String>>(),
);
}

@override
bool isSignInWithEmailLink(String? emailLink) {
return super.noSuchMethod(
Invocation.method(#isSignInWithEmailLink, [emailLink]),
false,
returnValue: false,
returnValueForMissingStub: false,
);
}

Expand All @@ -845,7 +867,8 @@ class MockFirebaseAuth extends Mock
]) {
return super.noSuchMethod(
Invocation.method(#sendPasswordResetEmail, [email, actionCodeSettings]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

Expand All @@ -856,7 +879,8 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#sendSignInLinkToEmail, [email, actionCodeSettings]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

Expand All @@ -870,31 +894,35 @@ class MockFirebaseAuth extends Mock
appVerificationDisabledForTesting,
userAccessGroup,
]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<void> setPersistence(Persistence? persistence) {
return super.noSuchMethod(
Invocation.method(#setPersistence, [persistence]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<void> signOut() {
return super.noSuchMethod(
Invocation.method(#signOut, [signOut]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<String> verifyPasswordResetCode(String? code) {
return super.noSuchMethod(
Invocation.method(#verifyPasswordResetCode, [code]),
neverEndingFuture<String>(),
returnValue: neverEndingFuture<String>(),
returnValueForMissingStub: neverEndingFuture<String>(),
);
}

Expand All @@ -920,7 +948,8 @@ class MockFirebaseAuth extends Mock
#forceResendingToken: forceResendingToken,
#autoRetrievedSmsCodeForTesting: autoRetrievedSmsCodeForTesting,
}),
neverEndingFuture<String>(),
returnValue: neverEndingFuture<String>(),
returnValueForMissingStub: neverEndingFuture<String>(),
);
}
}
Expand Down Expand Up @@ -1000,7 +1029,8 @@ class MockRecaptchaVerifier extends Mock
RecaptchaVerifierFactoryPlatform get delegate {
return super.noSuchMethod(
Invocation.getter(#delegate),
MockRecaptchaVerifierFactoryPlatform(),
returnValue: MockRecaptchaVerifierFactoryPlatform(),
returnValueForMissingStub: MockRecaptchaVerifierFactoryPlatform(),
);
}
}
Expand Down
Loading