Skip to content

🧪 Add tests for Clientes_model::add#7

Open
cezargf wants to merge 1 commit into
masterfrom
improve-clientes-model-tests-5955551112788441469
Open

🧪 Add tests for Clientes_model::add#7
cezargf wants to merge 1 commit into
masterfrom
improve-clientes-model-tests-5955551112788441469

Conversation

@cezargf
Copy link
Copy Markdown
Owner

@cezargf cezargf commented May 18, 2026

🎯 What: Added tests for the Clientes_model::add() function, which lacked tests for returning the correct insert_id and 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

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>
@google-labs-jules
Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread composer.json
"vendor-dir": "application/vendor"
"vendor-dir": "application/vendor",
"platform": {
"php": "8.3.6"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

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.

Comment on lines +36 to +37
->method('insert_id')
->willReturn($expectedInsertId);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The mock expectation for insert_id should verify that it is called with the $table argument, as the Clientes_model::add method passes this argument when calling $this->db->insert_id($table).

            ->method('insert_id')
            ->with($table)
            ->willReturn($expectedInsertId);

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.

1 participant