Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding helpers for asserting database query count #208

Conversation

yalsicor
Copy link
Contributor

@yalsicor yalsicor commented Sep 12, 2024

Description

Dealing with performance and scaling issues due to poorly designed code logic can cause a lot of hard to pin problems, especially in bigger projects. This PR adds some helpers to give the tools during development and in tests to check for hidden N+1 problems.

This PR adds the documentation for the functionality.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (refactoring a current feature, method, etc...)
  • Code Coverage (adding/removing/updating/refactoring tests)
  • New feature (non-breaking change which adds functionality)
  • Remove feature (non-breaking change which removes functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 90.74074% with 5 lines in your changes missing coverage. Please review.

Project coverage is 5.13%. Comparing base (7ef3525) to head (e84abef).
Report is 21 commits behind head on 8.x.

Files with missing lines Patch % Lines
...s/TestTraits/PhpUnit/TestDatabaseProfilerTrait.php 90.74% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               8.x    #208      +/-   ##
==========================================
+ Coverage     3.42%   5.13%   +1.70%     
- Complexity     659     677      +18     
==========================================
  Files           99     100       +1     
  Lines         2713    2767      +54     
==========================================
+ Hits            93     142      +49     
- Misses        2620    2625       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yalsicor
Copy link
Contributor Author

@Mohammad-Alavi Any ideas how I can add tests for the trait?

@yalsicor
Copy link
Contributor Author

@Mohammad-Alavi I have excluded the test traits from code coverage. I dont think it makes sense to specifically test test case helper traits.

@Mohammad-Alavi
Copy link
Member

@Mohammad-Alavi I have excluded the test traits from code coverage. I dont think it makes sense to specifically test test case helper traits.

@yalsicor I think the traits should be tested in the Core.
The end user doesn't need to test them in their project but we have to test them here to make sure they are working as expected.
I have included them in the coverage again. I am all ears if you think otherwise.

I have prepared the test file for your code to help you kickstart writing the tests for your new features.
Everything else looks good to me 💪 Add the tests and we are good to go.
This would be a nice addition in oour testing toolset 💪 Thank you 😎

@yalsicor
Copy link
Contributor Author

yalsicor commented Sep 29, 2024

@Mohammad-Alavi I have added the tests and fixed some issues with my code.

I have removed the setUp method from the test class, since all of the methods are private methods and we dont have access to them on another class. The trait is added to the TestParent anyway, so we have access to the methods directly in the test class.

Let me know what you think.

@Mohammad-Alavi Mohammad-Alavi merged commit 3e839a7 into apiato:8.x Oct 7, 2024
5 checks passed
Sign up for free to 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.

2 participants