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

PHPUnit 10 Shift #155

Closed
wants to merge 6 commits into from
Closed

PHPUnit 10 Shift #155

wants to merge 6 commits into from

Conversation

uyab
Copy link
Contributor

@uyab uyab commented Apr 5, 2024

This pull request contains changes for upgrading to PHPUnit 10 automated by the PHPUnit 10 Shift.

Before merging, you need to:

  • Checkout the shift-115119 branch
  • Review all pull request comments for additional changes
  • Run composer update (if the scripts fail, try with --no-scripts)
  • Run your tests suite: vendor/bin/phpunit

If there were changes you felt could have been automated, please reply to the follow-up email with your feedback or on Twitter.

From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type:

- `setUpBeforeClass()`
- `setUp()`
- `assertPreConditions()`
- `assertPostConditions()`
- `tearDown()`
- `tearDownAfterClass()`
- `onNotSuccessfulTest()`

[1]: https://phpunit.de/announcements/phpunit-8.html
@uyab
Copy link
Contributor Author

uyab commented Apr 5, 2024

⚠️ PHPUnit 10 requires PHP version 8.1 or higher. Be sure to verify you met this requirement by running php -v in your test environment.

@uyab
Copy link
Contributor Author

uyab commented Apr 5, 2024

⚠️ PHPUnit 10 has made several changes to the configuration file. After running composer update, you may run vendor/bin/phpunit --migrate-configuration to have PHPUnit upgrade your configuration file.

@uyab
Copy link
Contributor Author

uyab commented Apr 5, 2024

ℹ️ PHPUnit has documented using return types for test cases and data providers since PHPUnit 8. In an effort to modernize your test suite, Shift added a return type of void to your test cases and a return type of array to your data providers.

Shift understands developers have different preferences when it comes to type hints. If you do not wish to add return types, you may undo this change by running: git revert 9ad19e6f

@uyab
Copy link
Contributor Author

uyab commented Apr 5, 2024

ℹ️ PHPUnit has documented declaring test classes as final since PHPUnit 8. In an effort to modernize your test suite, Shift has declared your test classes as final.

Shift understands developers have different preferences when it comes to using final. If you do not wish to declare your test classes as final, you may undo this change by running: git revert 3ce9bd6e

@uyab
Copy link
Contributor Author

uyab commented Apr 5, 2024

⚠️ PHPUnit 10 now requires any base test class to have a TestCase suffix. In addition, this class should be defined as abstract. If you have a custom base test class, you should ensure it meets these new requirements.

@uyab
Copy link
Contributor Author

uyab commented Apr 5, 2024

⚗️ This Shift is still being refined. Please report any issues or suggestions to [email protected]. Your feedback is what helps improve the experience for everyone.

class AvatarLaravelTest extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\Attributes\Test;

final class AvatarLaravelTest extends \PHPUnit\Framework\TestCase

Choose a reason for hiding this comment

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

Each class must be in a namespace of at least one level (a top-level vendor name)

*/
public function it_can_override_attributes_when_instantiated()
#[Test]
public function it_can_override_attributes_when_instantiated(): void

Choose a reason for hiding this comment

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

Method name AvatarLaravelTest::it_can_override_attributes_when_instantiated is not in camel caps format

*/
public function it_have_no_border_radius_as_default()
#[Test]
public function it_have_no_border_radius_as_default(): void

Choose a reason for hiding this comment

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

Method name AvatarLaravelTest::it_have_no_border_radius_as_default is not in camel caps format

*/
public function it_can_override_attributes_after_set_name()
#[Test]
public function it_can_override_attributes_after_set_name(): void

Choose a reason for hiding this comment

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

Method name AvatarLaravelTest::it_can_override_attributes_after_set_name is not in camel caps format

*/
public function it_has_correct_random_background()
#[Test]
public function it_has_correct_random_background(): void

Choose a reason for hiding this comment

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

Method name AvatarLaravelTest::it_has_correct_random_background is not in camel caps format

*/
public function it_has_different_random_background()
#[Test]
public function it_has_different_random_background(): void

Choose a reason for hiding this comment

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

Method name AvatarLaravelTest::it_has_different_random_background is not in camel caps format

class AvatarPhpTest extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\Attributes\Test;

final class AvatarPhpTest extends \PHPUnit\Framework\TestCase

Choose a reason for hiding this comment

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

Each class must be in a namespace of at least one level (a top-level vendor name)

*/
public function it_can_override_attributes_when_instantiated()
#[Test]
public function it_can_override_attributes_when_instantiated(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_override_attributes_when_instantiated is not in camel caps format

*/
public function it_can_override_attributes_after_set_name()
#[Test]
public function it_can_override_attributes_after_set_name(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_override_attributes_after_set_name is not in camel caps format

*/
public function it_has_correct_random_background()
#[Test]
public function it_has_correct_random_background(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_has_correct_random_background is not in camel caps format

*/
public function it_has_different_random_background()
#[Test]
public function it_has_different_random_background(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_has_different_random_background is not in camel caps format

*/
public function it_can_resolve_random_themes_and_then_overrides()
#[Test]
public function it_can_resolve_random_themes_and_then_overrides(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_resolve_random_themes_and_then_overrides is not in camel caps format

*/
public function it_can_handle_invalid_theme()
#[Test]
public function it_can_handle_invalid_theme(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_handle_invalid_theme is not in camel caps format

*/
public function it_can_create_initials_from_name()
#[Test]
public function it_can_create_initials_from_name(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_create_initials_from_name is not in camel caps format

*/
public function it_can_set_chars_length()
#[Test]
public function it_can_set_chars_length(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_set_chars_length is not in camel caps format

*/
public function it_accept_valid_font_file()
#[Test]
public function it_accept_valid_font_file(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_accept_valid_font_file is not in camel caps format

*/
public function it_cannot_accept_invalid_font_file()
#[Test]
public function it_cannot_accept_invalid_font_file(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_cannot_accept_invalid_font_file is not in camel caps format

*/
public function it_can_generate_base64()
#[Test]
public function it_can_generate_base64(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_base64 is not in camel caps format

*/
public function it_can_generate_base64_from_cache()
#[Test]
public function it_can_generate_base64_from_cache(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_base64_from_cache is not in camel caps format

*/
public function it_can_generate_file()
#[Test]
public function it_can_generate_file(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_file is not in camel caps format

*/
public function it_can_generate_circle_svg()
#[Test]
public function it_can_generate_circle_svg(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_circle_svg is not in camel caps format

*/
public function it_can_generate_rectangle_svg()
#[Test]
public function it_can_generate_rectangle_svg(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_rectangle_svg is not in camel caps format

*/
public function it_can_generate_svg_with_custom_font_family()
#[Test]
public function it_can_generate_svg_with_custom_font_family(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_svg_with_custom_font_family is not in camel caps format

*/
public function it_can_use_the_foreground_color_for_the_svg_border()
#[Test]
public function it_can_use_the_foreground_color_for_the_svg_border(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_use_the_foreground_color_for_the_svg_border is not in camel caps format

*/
public function it_can_use_the_background_color_for_the_svg_border()
#[Test]
public function it_can_use_the_background_color_for_the_svg_border(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_use_the_background_color_for_the_svg_border is not in camel caps format

*/
public function it_can_generate_gravatar()
#[Test]
public function it_can_generate_gravatar(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_gravatar is not in camel caps format

*/
public function it_can_generate_gravatar_with_size()
#[Test]
public function it_can_generate_gravatar_with_size(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_gravatar_with_size is not in camel caps format

*/
public function it_can_generate_gravatar_with_default()
#[Test]
public function it_can_generate_gravatar_with_default(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_gravatar_with_default is not in camel caps format

*/
public function it_can_generate_gravatar_with_default_and_rating()
#[Test]
public function it_can_generate_gravatar_with_default_and_rating(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_gravatar_with_default_and_rating is not in camel caps format

*/
public function it_can_generate_gravatar_with_size_overriden()
#[Test]
public function it_can_generate_gravatar_with_size_overriden(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_generate_gravatar_with_size_overriden is not in camel caps format

*/
public function it_can_set_background()
#[Test]
public function it_can_set_background(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_set_background is not in camel caps format

*/
public function it_can_set_foreground()
#[Test]
public function it_can_set_foreground(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_set_foreground is not in camel caps format

*/
public function it_can_set_dimension()
#[Test]
public function it_can_set_dimension(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_set_dimension is not in camel caps format

*/
public function it_can_set_font_size()
#[Test]
public function it_can_set_font_size(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_set_font_size is not in camel caps format

*/
public function it_can_set_font_family()
#[Test]
public function it_can_set_font_family(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_set_font_family is not in camel caps format

*/
public function it_can_set_border()
#[Test]
public function it_can_set_border(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_set_border is not in camel caps format

*/
public function it_can_set_border_radius()
#[Test]
public function it_can_set_border_radius(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_set_border_radius is not in camel caps format

*/
public function it_can_accept_valid_shape()
#[Test]
public function it_can_accept_valid_shape(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_accept_valid_shape is not in camel caps format

*/
public function it_throw_exception_for_invalid_shape()
#[Test]
public function it_throw_exception_for_invalid_shape(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_throw_exception_for_invalid_shape is not in camel caps format

*/
public function it_can_get_raw_image_object()
#[Test]
public function it_can_get_raw_image_object(): void

Choose a reason for hiding this comment

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

Method name AvatarPhpTest::it_can_get_raw_image_object is not in camel caps format

@uyab uyab closed this Apr 5, 2024
@uyab uyab deleted the shift-115119 branch September 20, 2024 17:05
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.

3 participants