Skip to content

Instantly share code, notes, and snippets.

View devmsh's full-sized avatar
👨‍💻
Available for new projects

Mohammed S Shurrab devmsh

👨‍💻
Available for new projects
View GitHub Profile
@devmsh
devmsh / gist:2cdd2a9f8eba19271821f7bc55bbd5a1
Last active September 10, 2020 10:08
Easily change laravel routes from strings to static class references
# Easily change laravel routes from strings to static class references
1. Open your route file in your prefered IDE
2. Find and replace using regex
3. Find \'([A-Za-z]*)\@([A-Za-z]*)\'
4. Replace with [App\\Http\\Controllers\\$1::class,'$2']
5. Find \'([A-Za-z]*Controller)\'
6. Replace with App\\Http\\Controllers\\$1::class
5. Done!
@devmsh
devmsh / distribute-android-staging.sh
Last active July 11, 2020 08:12
Build and distribute flutter app to Firebase App Distribution
echo "Building flutter Android release"
flutter build apk --release -t lib/main_staging.dart --flavor staging
echo "Distribut Android release"
firebase appdistribution:distribute \
./build/app/outputs/flutter-apk/app-staging-release.apk \
--app 1:612834649949:android:b8f54d1cdb7c3f611caab4 \
--release-notes-file ./release_notes.txt \
--groups="internal-testers"
import 'dart:convert';
import 'package:equatable/equatable.dart';
import 'package:iStoria/core/models/links.dart';
import 'package:iStoria/core/models/meta.dart';
import 'package:iStoria/core/models/response_converter.dart';
import 'package:json_annotation/json_annotation.dart';
part 'list_response.g.dart';
test(
'should get invaled data from login use case on error data',
() async {
mockPost(
url: Constant.api + "login",
response: fixture('login', "failed.json"),
status: 422,
);
var authBloc = sl<AuthBloc>();
@devmsh
devmsh / macro.php
Created March 27, 2020 10:00
Laravel assertPaginated macro
<?php
// Usgae
// test that posts api return a 15 post/page paginated response.
$this->get('api/posts')->assertPaginated(15);
/**
* If you use Laravel API resources and want test if an endpoint
* is paginated use can use: $this->get('...')->assertPaginated();
*
@devmsh
devmsh / bitbucket-pipelines.yml
Created March 18, 2020 20:52
The simplest bitbucket flutter testing pipelines
image: cirrusci/flutter:latest
pipelines:
default:
- step:
script:
- flutter test test
@devmsh
devmsh / 12.php
Created February 16, 2020 20:22
Write better Laravel tests
<?php
class LoanTest extends TestCase
{
public function test_loan_generate_corresponding_transaction()
{
$wallet = factory(Wallet::class)->create();
$loan = Loan::log(factory(Loan::class)->make([
'wallet_id' => $wallet->id
@devmsh
devmsh / 11.php
Created February 16, 2020 20:11
Write better Laravel tests
<?php
class LoanTest extends TestCase{
public function test_can_log_a_loan()
{
// ...
$this->passportAs($user)
// ..
@devmsh
devmsh / 10.php
Created February 16, 2020 20:00
Write better Laravel tests
<?php
class LoanTest{
public function test_can_log_a_loan()
{
$user = factory(User::class)->create();
$wallet = factory(Wallet::class)->create([
'user_id' => $user->id
]);
@devmsh
devmsh / 9.php
Created February 16, 2020 19:59
Write better Laravel tests
<?php
class LoanController extends Controller
{
public function store(Request $request)
{
return Loan::log(array_merge($request->all(), [
'user_id' => Auth::id(),
]));
}