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 to Pest Converter #13

Merged
merged 10 commits into from Dec 10, 2021
Merged

PHPUnit to Pest Converter #13

merged 10 commits into from Dec 10, 2021

Conversation

freekmurze
Copy link
Member

This pull request contains changes for migrating your test suite from PHPUnit to Pest automated by the Pest Converter.

Before merging, you need to:

  • Checkout the shift-52829 branch
  • Review all of the comments below for additional changes
  • Run composer update to install Pest with your dependencies
  • Run vendor/bin/pest to verify the conversion

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
@freekmurze
Copy link
Member Author

⚠️ Shift detected helper methods in the following PHPUnit tests. Currently Pest does not support namespaces. As such, these functions may result in a naming conflict.

While Shift converted these methods to functions in the new Pest test, you should review these files to see if these functions may be inlined or extracted to a custom helper.

  • tests/FlareTest.php
  • tests/IntegrationTest.php
  • tests/Solutions/UndefinedPropertySolutionProviderTest.php

@freekmurze
Copy link
Member Author

ℹ️ Shift converted common PHPUnit assertions to Pest expectations. However, there may also be opportunities to chain your expectations together.

For example:

// Before
expect($comment)->toBeArray();
expect($comment)->toHaveCount(3);
expect($comment)->toContain('foo');

// After
expect($comment)->toBeArray()->toHaveCount(3)->toContain('foo');

@freekmurze
Copy link
Member Author

⚠️ Shift detected references to the PHPUnit test runner (vendor/bin/phpunit) in the following files. You should review these instances to see if they may be updated to the Pest test runner (vendor/bin/pest).

  • ./composer.json

@freekmurze
Copy link
Member Author

ℹ️ Pest is currently beta testing their Parallel Plugin. If you would like to save time by running your tests in parallel, you may install this plugin and run your tests with the -p options.

composer require pestphp/pest-plugin-parallel --dev
vendor/bin/pest -p

@freekmurze
Copy link
Member Author

⚗️ This Shift is still being refined. Please report any issues or suggestions to shift@laravelshift.com. Your feedback is what helps improve the experience for everyone.

@freekmurze freekmurze merged commit f54de39 into main Dec 10, 2021
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.

None yet

2 participants