Hello people,
Hope you are doing awesome stuff in your area. I am back with another cool blog…! I know it’s only cool for me but its ok, Right…! I am learning anyway…
So today’s blog as the title suggest, its about the testing…
Hey developer, where are you going? Wait and read it, It will helpful for you.
When we create CRUD operations on any feature we sometimes miss many things and then we need to make changes again and again after it comes from QA. So today I am going to share few checkpoints which you must check before submitting it to your QA.
Let’s see checkpoints for all for all feature one by one:
CREATE FEATURE:
Check Validation
Check for duplicate records
Take only needed information
Here is an example in laravel framework of a create function
public function createArticleCategory(Request $request)
{
$data = $request->all();
// Create a new validator instance.
$request->validate([
'name' => 'required',
]);
$isCtegory = ArticleCategory::select('name')->where('name', '=', $request->input('name'))->first();
if ($isCtegory != null) {
return response()->json(['message' => 'Category already exist', 'success' => false]);
} else {
$category = ArticleCategory::create($data);
$content = array(
'success' => true,
'data' => $category,
'message' => 'Category Added successfully'
);
return response($content)->setStatusCode(200);
}
}
UPDATE FEATURE:
Check Validation
Check for duplicate records
Take only needed information
Here is an example in laravel framework of a create function
public function editArticleCategory(Request $request)
{
$data = $request->all();
// Create a new validator instance.
$request->validate([
'id' => 'required',
'name' => 'required',
]);
$category = ArticleCategory::find($data['id']);
if ($category != null) {
$isCtegory = ArticleCategory::select('name')
->where([['name', '=', $request->input('name')], ['id', '<>', $request->input('id')]])
->first();
if ($isCtegory != null) {
return response()->json(['message' => 'Category already exist', 'success' => false]);
} else {
$category->name = $data['name'];
$category->save();
$content = array(
'success' => true,
'data' => $category,
'message' => 'Category updated successfully'
);
return response($content)->setStatusCode(200);
}
}
return response()->json(['success' => false, "message" => 'Data not found'], 422);
}
DELETE FEATURE:
Check Validation
Take only needed information
Check for dependency
Here is an example in laravel framework of a create function
public function deleteArticleCategory(Request $request, $id)
{
if (!$request->user()->id) {
return response()->json(["message" => "unauthorised", 'success' => false], 422);
}
$category = ArticleCategory::where('id', $id)->first();
if ($category != null) {
$blogs = Blog::select('blogs.id')
->leftJoin('blog_categories as b', 'blogs.id', '=', 'b.blog_id', 'left')
->where('b.article_category_id', $id)
->where('blogs.deleted_at', null)->first();
if ($blogs != null) {
return response()->json(['message' => 'You can't delete this category as its already assigned with blog', 'success' => false]);
} else {
ArticleCategory::find($id)->delete();
return response()->json(['message' => 'Category deleted successfully', 'success' => true]);
}
return response()->json(['success' => false, "message" => trans('messages.no_data_found')], 422);
}
}
some common tips:
Always put try … catch block in your functionality to handling the error
Check as many combination you can add on a particular function according to your feature.
So I hope you got my point.
Thank you for reading…!
Happy Coding… 🙂

Greetings from Idaho! I’m bored to tears at work so I decided to
check out your site on my iphone during lunch break.
I enjoy the knowledge you provide here and can’t wait to
take a look when I get home. I’m surprised at how fast your blog loaded on my mobile
.. I’m not even using WIFI, just 3G .. Anyhow, excellent
blog!
Feel free to visit my web page :: Best london domination In Wandsworth, London
LikeLiked by 1 person
Thank you!
LikeLike
My relatives always say that I am killing my time here at web, however I
know I am getting know-how daily by reading thes pleasant
content.
LikeLiked by 1 person
Thanks!
LikeLike
You can definitely see your expertise within the work you write.
The world hopes for more passionate writers like you who aren’t afraid to say
how they believe. At all times go after your heart.
LikeLiked by 1 person
Thank you 🙂
LikeLike