🧪 Add tests for Clientes_model::add#7
Conversation
This commit adds a test suite for `Clientes_model::add()` which handles inserting into the database. We test for successful insertions as well as handling failures when no rows are affected or when the database returns an error. A mock CI_Model was set up in `bootstrap.php` to run the tests in isolation. Co-authored-by: cezargf <25113573+cezargf@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request introduces unit testing infrastructure by adding a bootstrap file, unit tests for the Clientes_model, and including PHPUnit in the development dependencies. Feedback includes addressing a PHP version conflict in composer.json where the platform version is lower than the required version, and updating a mock expectation in the ClientesModelTest to verify the table argument passed to the insert_id method.
| "vendor-dir": "application/vendor" | ||
| "vendor-dir": "application/vendor", | ||
| "platform": { | ||
| "php": "8.3.6" |
There was a problem hiding this comment.
The platform PHP version 8.3.6 conflicts with the requirement ^8.4 specified in the require section of this file. This will cause Composer to fail during dependency resolution because the platform version does not satisfy the minimum required version. Please ensure the platform version is at least 8.4.0 or update the requirement to ^8.3 if the project is intended to support PHP 8.3.
| ->method('insert_id') | ||
| ->willReturn($expectedInsertId); |
There was a problem hiding this comment.
🎯 What: Added tests for the
Clientes_model::add()function, which lacked tests for returning the correctinsert_idand handling DB errors.📊 Coverage: Covered 3 scenarios: Success (returns insert ID), Failure due to zero affected rows (returns false), Failure due to database error (returns false).
✨ Result: Increased code coverage by adding unit tests that properly isolate and verify CodeIgniter's database interactions for this model method. Tests can be run via
./application/vendor/bin/phpunit --bootstrap application/tests/bootstrap.php application/tests/models/ClientesModelTest.php.PR created automatically by Jules for task 5955551112788441469 started by @cezargf