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

Tests Generator #2231

Closed
wants to merge 5 commits into from
Closed

Tests Generator #2231

wants to merge 5 commits into from

Conversation

alainvd
Copy link
Collaborator

@alainvd alainvd commented Apr 24, 2024

This pull request includes foundational components for testing your application by generating model factories, HTTP tests, unit tests, and test case stubs for common code paths.

Before merging, you need to:

  • Checkout the shift-117163 branch
  • Review all pull request comments for additional changes
  • Run composer update
  • Run vendor/bin/phpunit
  • Review the incomplete tests

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 24, 2024

⚠️ Shift could not verify the following core testing files since they differed from the default Laravel version. You should compare these files against the Laravel 10 versions to review any differences:

  • phpunit.xml
  • tests/CreatesApplication.php
  • tests/TestCase.php

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 24, 2024

❌ Shift could not generate factories for your application models. This is often due to a failure when running the php artisan migrate:fresh from the Shift build server.

Shift added a factory generator package as a development dependency so you may generate your model factories locally.

To do so, run php artisan generate:factory. You may use the --force option to regenerate any partial factories added by Shift or pass the model name to regenerate a specific factory.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 24, 2024

ℹ️ Using your routes, Shift generated HTTP tests for 42 Controllers. While test cases were stubbed using the route definitions and inspecting the return statements within the controller action, they are marked as incomplete for you to review and add any remaining setup and assertions. You may review the documentation on HTTP Tests for additional reference.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 24, 2024

ℹ️ Shift generated unit tests for 4 Form Requests. While test cases were stubbed for each of the existing methods, they are marked as incomplete for you to review and add any remaining setup and assertions. You may review this alternative Form Request testing strategy as a guide to how these unit tests are written.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 24, 2024

ℹ️ Shift generated tests for 89 Commands. While test cases were stubbed to call the command, they are marked as incomplete for you to review and add any setup and assertions. You may review the documentation on Console Tests for additional reference.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 24, 2024

ℹ️ Shift set some basic testing configuration values in your phpunit.xml file. Depending on your application, you may need to adjust these.

For example, the database was configured to use SQLite. However, your application may depend on a specific database. As such, you will want to set up and configure an equivalent database for testing.

Shift also changed any <server> configuration elements to <env> elements to address configuration precedence.

@alainvd
Copy link
Collaborator Author

alainvd commented Apr 24, 2024

⚗️ This Shift pairs with the Confident Laravel video course. If you are getting started with testing Laravel applications, it will guide you step-by-step from writing your first test to a confidently tested Laravel application.

@alainvd alainvd closed this Aug 9, 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