Skip to content

feat: Add pan:delete command with ID-specific deletion and test case. - #10

Merged
MrPunyapal merged 15 commits into
panphp:mainfrom
ruchit288:main
Apr 7, 2026
Merged

feat: Add pan:delete command with ID-specific deletion and test case.#10
MrPunyapal merged 15 commits into
panphp:mainfrom
ruchit288:main

Conversation

@ruchit288

@ruchit288ruchit288 commented Oct 15, 2024

Copy link
Copy Markdown
Contributor

This PR contain:

  • Implement a new Artisan command pan delete to remove specific analytic by ID.
  • Command e.g. -> php artisan pan:delete 1

@taghwotaghwo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work here, simple and clear 🚀

Comment threadsrc/Adapters/Laravel/Console/Commands/PanDeleteCommand.php Outdated
Comment threadsrc/Adapters/Laravel/Console/Commands/PanDeleteCommand.php Outdated
<?php

beforeEach(function (): void {
$this->repository = mock(AnalyticsRepository::class)->makePartial();

@taghwotaghwoOct 16, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the test here, the way it's broken down.
What is the performance gain in using a mock versus hitting the DB here?
I would suggest hitting the DB and confirming the row is actually deleted or test the repository method in isolation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruchit288 can you assert the database is missing the ID after deleting in these tests instead of the mock? Another way would be, leave the command class test as it is, and have a separate test for the delete of method of the repository (assert database missing the ID deleted).

You can check the merged branches, look at the feature test cases on how you can insert some data into the table. That would even prevent hard coding the id like ['id' => 1]. You can use insertGetId, which would make the tests more stable and less prone to failure.

ruchit288and others added 3 commits October 17, 2024 10:51
Co-authored-by: Taghwo Millionaire <40868373+taghwo@users.noreply.github.com>
Co-authored-by: Taghwo Millionaire <40868373+taghwo@users.noreply.github.com>
Comment threadsrc/Adapters/Laravel/Console/Commands/PanDeleteCommand.php Outdated
Comment threadsrc/Adapters/Laravel/Console/Commands/PanDeleteCommand.php
Comment threadsrc/Adapters/Laravel/Repositories/DatabaseAnalyticsRepository.php Outdated
taghwo

This comment was marked as off-topic.

@MrPunyapalMrPunyapal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update needed tests locally

@MrPunyapal
MrPunyapal merged commit d3a8044 into panphp:mainApr 7, 2026
0 of 4 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ruchit288@taghwo@MrPunyapal