Skip to content

Commit

Permalink
Test: Guest search refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
barbosa89 committed Feb 27, 2021
1 parent 94597fd commit 1777c2a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/Helpers/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function clean($value = null, $encoding = 'UTF-8')
return null;
}

return htmlentities($value, ENT_QUOTES | ENT_HTML5, $encoding);
return htmlentities((string) $value, ENT_QUOTES | ENT_HTML5, $encoding);
}

/**
Expand All @@ -43,4 +43,4 @@ public static function bool($value = null): bool

return false;
}
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/GuestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function index()
$validated = request()->validate([
'from_date' => 'bail|nullable|date|before_or_equal:today',
'status' => 'bail|nullable|string|in:is_staying,is_not_staying',
'query_by' => 'bail|nullable|string|min:3|max:50',
'query_by' => 'bail|nullable|alpha_num|min:3|max:50',
]);

$guests = $this->guest->paginate(
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Guest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ public function scopeStatus($query, string $status)
*/
public function scopeQueryBy($query, string $text)
{
return $query->whereLike(['name', 'last_name', 'dni', 'email'], $text);
return $query->whereLike(['name', 'last_name', 'dni'], $text);
}
}
2 changes: 1 addition & 1 deletion tests/Feature/Api/GuestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function test_user_can_filter_guests_by_query()
'GET',
'/api/v1/web/guests',
[
'query_by' => $guest->name,
'query_by' => $guest->dni,
]
);

Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/VoucherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function test_user_can_search_guests_to_add_to_voucher()
'GET',
'/api/v1/web/guests',
[
'query_by' => $guest->name,
'query_by' => $guest->dni,
]
);

Expand Down

0 comments on commit 1777c2a

Please sign in to comment.