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

Add unit tests #176

Merged
merged 5 commits into from
Jan 9, 2024
Merged

Add unit tests #176

merged 5 commits into from
Jan 9, 2024

Conversation

msmakouz
Copy link
Contributor

@msmakouz msmakouz commented Jan 9, 2024

Q A
Is bugfix?
New feature?
Breaks BC?

Part of #22

What was changed

  1. Unit tests have been added to the files that had a low coverage level according to the coverage report: https://scrutinizer-ci.com/g/yiisoft/yii-cycle/code-structure/master/code-coverage/src/
  2. In the console command Yiisoft\Yii\Cycle\Command\Migration\DownCommand the unused variable $exist was removed and the result of the rollback method was added to the $migration variable. This method returns the migration to which the rollback was applied and it contains the new status.
  3. In the console command Yiisoft\Yii\Cycle\Command\Migration\GenerateCommand the retrieval of the helper has been moved to the block with the condition $input->isInteractive(), as it is only used within it.
  4. In the Yiisoft\Yii\Cycle\Factory\RepositoryContainer class, the private property rootContainer has been removed. It was only set in the constructor and was not used anywhere else.

Copy link

codecov bot commented Jan 9, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (6b734c9) 48.52% compared to head (de7f20a) 77.90%.
Report is 3 commits behind head on master.

Files Patch % Lines
src/Command/Migration/GenerateCommand.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master     #176       +/-   ##
=============================================
+ Coverage     48.52%   77.90%   +29.37%     
  Complexity      400      400               
=============================================
  Files            59       59               
  Lines          1088     1086        -2     
=============================================
+ Hits            528      846      +318     
+ Misses          560      240      -320     

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

Copy link

what-the-diff bot commented Jan 9, 2024

PR Summary

Modifications in Command Files

  • In src/Command/Migration/DownCommand.php, a line of code was tweaked so that a rollback operation now assigns its result to a variable.

  • src/Command/Migration/GenerateCommand.php was updated to improve the handling of user inputs. This includes removing and adding specific code to assist with this input handling, and adjusting specific conditions related to input.

  • Extraneous code in src/Factory/RepositoryContainer.php was removed, simplifying its structure.

New Test Files and Test Case

Many new test files were added, particularly focusing on testing command migrations, and schema aspects. This amplifies the testing suite and improves the robustness of the repository.

Additionally, a new test case was added to tests/Unit/Factory/RepositoryContainerTest.php to specifically test the get() method functionality.

File Renaming and Tweaking

Various test files were renamed to make their naming more descriptive or moved to better located directories. This helps maintain the clarity and organization of your repository's testing framework.

New Classes

New classes FakeEntity and FakeRepository were added. Having these fake/testing classes allows us to test components in isolated scenarios, ensuring that each unit of the code is working as expected.

Overall Benefits

These changes enhance code maintainability and readability. They pave the way for a more robust testing environment and also help in managing user interactions better.

@roxblnfk roxblnfk self-requested a review January 9, 2024 12:52
@roxblnfk roxblnfk added this to the 2.0 milestone Jan 9, 2024
@roxblnfk roxblnfk merged commit baff189 into yiisoft:master Jan 9, 2024
10 of 11 checks passed
@msmakouz msmakouz deleted the tests branch January 30, 2024 09:30
@msmakouz msmakouz mentioned this pull request Jan 30, 2024
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