Skip to content

Commit

Permalink
Merge pull request #9 from fintechbd/LP-102-registration-test-case
Browse files Browse the repository at this point in the history
Lp 102 registration test case
  • Loading branch information
hafijul233 authored Oct 13, 2023
2 parents e5c3e21 + fbc6282 commit 5a692c5
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/Http/Requests/RegistrationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ public function authorize(): bool
*/
public function rules(): array
{
return config('fintech.auth.register_rules', [
$rules = config('fintech.auth.register_rules', [
//user
'name' => ['required', 'string', 'min:2', 'max:255'],
'mobile' => ['required', 'string', 'min:10'],
'email' => ['required', 'string', 'email:rfc,dns', 'min:2', 'max:255'],
'login_id' => ['required', 'string', 'min:6', 'max:255'],
'password' => ['required', 'string', Password::default()],
'pin' => ['required', 'string', 'min:4', 'max:16'],
'parent_id' => ['nullable', 'integer'],
'app_version' => ['nullable', 'string'],
Expand Down Expand Up @@ -67,5 +65,11 @@ public function rules(): array
'note' => ['string', 'nullable'],
'nationality' => ['string', 'nullable'],
]);

$rules[config('fintech.auth.auth_field', 'login_id')] = config('fintech.auth.auth_field_rules', ['required', 'string', 'min:6', 'max:255']);

$rules[config('fintech.auth.password_field', 'password')] = config('fintech.auth.password_field_rules', ['required', 'string', Password::default()]);

return $rules;
}
}
5 changes: 5 additions & 0 deletions tests/Feature/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

test('example', function () {
expect(true)->toBeTrue();
});
42 changes: 42 additions & 0 deletions tests/Feature/RegistrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php


use function Pest\Laravel\postJson;

test('registration', function () {
postJson('/api/auth/register', [
"name" => "MT TECHNOLOGIES",
"mobile" => "01700000001",
"email" => "[email protected]",
"login_id" => "01700000001",
"pin" => "123456",
"password" => "12345678",
"app_version" => "0.0.1",
"language" => "bd",
"currency" => "BDT",
"father_name" => "MT",
"mother_name" => "TECHNOLOGIES",
"gender" => "male",
"marital_status" => "unmarried",
"occupation" => "service",
"source_of_income" => "salary",
"id_type" => "passport",
"id_no" => "1234567890",
"id_issue_country" => "BANGLADESH",
"id_expired_at" => "2030-12-31",
"id_issue_at" => "2020-01-01",
"date_of_birth" => "1985-02-19",
"permanent_address" => "DHAKA",
"city_id" => "1",
"state_id" => "1",
"country_id" => "18",
"post_code" => "1100",
"present_address" => "DHAKA",
"present_city_id" => "1",
"present_state_id" => "1",
"present_country_id" => "18",
"present_post_code" => "1100",
"nationality" => "BANGLADESHI"
])->dd();
//assertStatus(201);
});
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class TestCase extends Orchestra
{
use DatabaseMigrations;
//use DatabaseMigrations;

protected function setUp(): void
{
Expand All @@ -31,8 +31,8 @@ public function getEnvironmentSetUp($app)


$migrations = [
// include __DIR__ . '/../../../database/migrations/2014_10_12_000000_create_users_table.php',
// include __DIR__ . '/../database/migrations/2023_09_25_201621_update_add_columns_in_users_table.php',
include __DIR__ . '/../../../database/migrations/2014_10_12_000000_create_users_table.php',
include __DIR__ . '/../database/migrations/2023_09_25_201621_update_add_columns_in_users_table.php',
include __DIR__ . '/../database/migrations/2023_09_25_201631_create_user_profiles_table.php',
include __DIR__ . '/../database/migrations/2023_09_28_224955_create_permission_tables.php',
include __DIR__ . '/../database/migrations/2023_09_28_230630_create_teams_table.php'
Expand Down
5 changes: 5 additions & 0 deletions tests/Unit/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

test('example', function () {
expect(true)->toBeTrue();
});

0 comments on commit 5a692c5

Please sign in to comment.