Skip to content

Conversation

@UseTheFork
Copy link
Collaborator

@UseTheFork UseTheFork commented Sep 14, 2024

This PR is to get coverage up to 79%. I have transferred everything from the old testing repo.

It's difficult to get this above 80% as some functions in the build do not seem to be used anymore but I do not want to remove them.

- Added tests to verify Elasticsearch DB connection.
- Included reconnection tests to ensure proper purging.
- Validated schema builder and driver name functionality.

Testing is the new black! 🖤
- Added HiddenAnimal model connected to Elasticsearch.
- Implemented properties and hidden fields for the model.
- Created tests to verify hidden properties behavior.

Because some animals just prefer to keep a low profile. 🐑🔍
…zers

- Added tests for creating, modifying, and deleting indices.
- Verified field mappings, settings, and analyzer configurations.
- Included tests for failure scenarios and field existence checks.
- Ensured numeric type mapping validations.
- Cleaned up test indices after verification.

Now we're talking schema! 🧐
…ationships

- Added MySQL and ElasticSearch relationship tests for company and user models.
- Introduced `createCompanyData` helper function to streamline test data creation.
- Removed unnecessary `connection` attribute from User model.
- Created `EsPhotoFactory` for generating Elasticsearch photo instances.

Testing relationships like a boss! 🕵️‍♂️🧪
…any models

- Added `HasMany` relation to `User` model.
- Split `name` into `first_name` and `last_name` in `User` model.
- Introduced fillable fields in `UserLog` model.
- Created migration for `user_logs` table in Elasticsearch.
- Added `HybridRelations` trait to `Company` and `CompanyLog` models.

Data search game just got stronger! 💪🕵️‍♀️
- Added additional assertions for `getDsl`, `getTook`, `getTotal`, `getMaxScore`, and `getResults`.
- Included `QueryMetaData` instance check in assertions.
- Adjusted imports to include `QueryMetaData`.

More tests, more confidence! 🧪
…ption

- Deleted the redundant render method, which duplicated error response logic.

Trimmed the fat for leaner code! 🥓
- Added assertion for `getDetails` method in QueryException.
- Ensured error details are provided as an array.

Because catching errors isn't just a hobby, it's a skill! 🕵️‍♂️
- Reformatted phpunit.xml for better readability.
- Enabled strict output checking during tests.
- Added configuration to fail on risky tests.
- Disabled coverage for uncovered files.

Keepin' bugs at bay, one config at a time! 🐛✨
- Added new unit tests for `Meta` in `ModelTest.php`.
- Ensured metadata properties like `index`, `score`, `highlights`, and `id` are checked.
- Enhanced `asArray` method in `ModelMetaData.php` to return array type.

Who knew metadata could be so meta? 🧐
…ions

- Added assertions for paginator total records and last page.
- Verified paginator current page number is an integer.
- Validated paginator's array conversion.

Testing is believing, not just seeing. 😎📜

    Diff:
    Index: tests/Eloquent/SearchAfterPaginationTest.php
===================================================================
--- a/tests/Eloquent/SearchAfterPaginationTest.php	(revision 6cab981)
+++ b/tests/Eloquent/SearchAfterPaginationTest.php	(date 1726266436585)
@@ -33,11 +33,20 @@
     // Fetch the first page of posts
     $paginator = Post::orderBy('slug.keyword')->cursorPaginate($perPage)->withQueryString();

+  expect($paginator->totalRecords())->toBeInt()
+                               ->and($paginator->totalRecords())->toBeInt()
+                               ->and($paginator->totalRecords())->toBe(25000)
+                               ->and($paginator->lastPage())->toBe(250)
+                               ->and($paginator->toArray())->toBeArray();
     do {

         // Count the number of posts fetched in the current page
         $totalFetched += $paginator->count();

+        expect($paginator->currentPageNumber())->toBeInt()
+          ->and($paginator->totalRecords())->toBeInt()
+        ;
+
         // Move to the next page if possible
         if ($paginator->hasMorePages()) {
             $cursor = $paginator->nextCursor();

    Commit message:
- Added distinct product statuses retrieval test.
- Implemented count, max, min, avg, and sum tests for Product prices.
- Introduced test for retrieving multiple fields at once.
- Created matrix test for Product colors.

Testing the full spectrum of aggregations like a boss! 🧪
- Implemented various search term detection tests.
- Added tests for `minShouldMatch()` and `minScore()` functionalities.
- Confirmed search accuracy with `where` clauses and return limits.
- Included tests for term boosting and fuzzy searches.
- Validated search highlighting features.
- Updated products table migration to include text fields for `manufacturer.name` and `manufacturer.country`.

Making search great again! 🚀
- Removed 'todo' status from test for ordering products by creation date.
- Removed 'todo' status from test for ordering products by manufacturer location.
- Fixed missing end of test specification.

Finally, no more procrastination in our test suite! 🐢
- Introduced a new test case for multiple aggregations on Product.
- Verified the presence of keys: max_price, min_price, count_price, avg_price, and sum_price.

Why don't programmers like nature? It has too many bugs! 🐛
- Replaced static blog post factory creation with dynamic sequence generation.
- Removed incorrect 'FIXME' note from 'order blog posts by comments likes descending' test.
- Inserted blog posts dynamically using Eloquent sequences for better coverage.

Why not both dynamic and dramatic? 🎭📜
…eindexing flow

- Updated `Schema::create` and `deleteIfExists` to use Elasticsearch connection.
- Simplified product insertion with `Product::insert`.
- Adjusted reindexing assertions to use `getMetaData()->isSuccessful()`.
- Removed redundant sleep calls for better performance.

Elasticsearch indexing got an upgrade. Faster, stronger, better! 🚀
- Removed redundant 'includeUncoveredFiles' setting in phpunit.xml.
- Updated coverage commands in flake.nix:
  - Streamlined environment variable setting.
  - Added new command for generating coverage report in XML format.
- Included Xdebug configuration for memory and execution time settings.

Because debugging isn't just for your code, it's for your soul! 🧘‍♂️🔧
- Enhanced term search test to ensure count comparisons are more flexible.
- Updated state sequence in combined where clause test to include 'name' attributes.
- Adjusted search expectations to use greater-than checks.
- Simplified product name and color combinations in test cases.
- Added assertions for combined term and fuzzy term searches.

Keep calm and let the tests do the hunting! 🔍🐾
…serLog

- Introduced new aggregate tests: sum, max, min, and avg for `UserLog`.
- Ensured consistency between `distinct` and `groupBy` results.
- Added the `UserLog` model import for new tests.

Numbers game - now with more pizzazz! 🎲✨
- Introduced a new test for searching products by color using 'or' regex conditions.
- Verified the correct count of products matching the criteria 'red' or 'bl(ue)?(ack)?'.

Regex for everyone! 🧩🎨
…itions

- Added test for finding products with active status or stock greater than 50.
- Included test for finding products that are either black and active or blue and inactive.
- Introduced test for finding products that are either black or blue, combined with status equal to 1 or not active.

Let's get this query party started! 🎉🔍
- Fixed alignment issues in the 'Meta' test expectations.
- Changed identification logic in 'Soft Delete' tests from 'name' to 'status' field.
- Added 'status' field to 'Soft' model creation for better filtering.
- Removed unnecessary 'todo' annotation in 'Soft Delete' tests.

Improving tests one assertion at a time! 🛠️🔍
- Added export and unset for XDEBUG_MODE in coverage scripts.
- Fixed XDebug settings: 'start_with_request' and added 'start_upon_error'.

Just making sure XDebug doesn't bug out... 🐛🔍
- Updated 'status' to use a more appropriate range with `numberBetween(1, 10)`.

Why settle for randomness when you can be precisely random? 🎯🔢
@UseTheFork UseTheFork changed the title Refract/code coverage - Coverage up to 80% Refract/code coverage - Coverage up to 79% Sep 14, 2024
@UseTheFork UseTheFork marked this pull request as ready for review September 14, 2024 17:50
@UseTheFork
Copy link
Collaborator Author

@pdphilip This is ready for you to look at.

@pdphilip
Copy link
Owner

Fantastic @use-the-fork

I am in the process of bringing other packages of mine up to speed, and then I will get stuck in here. Looking forward to these!

@pdphilip pdphilip merged commit a0d3844 into pdphilip:main Sep 23, 2024
@UseTheFork UseTheFork deleted the refract/code-coverage branch May 7, 2025 23:36
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