pestphp / drift Goto Github PK
View Code? Open in Web Editor NEW[WIP] Command-line tool to migrate your PHPUnit tests to Pest
Home Page: https://pestphp.com/docs/guides/drift
License: MIT License
[WIP] Command-line tool to migrate your PHPUnit tests to Pest
Home Page: https://pestphp.com/docs/guides/drift
License: MIT License
So as drift is going to have a command line tool, I think we should discuss how the command should work and what should be available.
My first idea is the following
# Change the code to pest test classes
$ drift migrate {path}
# Show the diff instead of actually changing the code.
$ drift show {$path}
Would love to hear if you guys have some better ideas for naming ๐
For example rector uses the following syntax
# Change code based in the specified path based on the specified set
$ vendor/bin/rector process {path} --set {set-name}
# Show the diffs instead
$ vendor/bin/rector process {path} --set {set-name} --dry-run
A new core feature for phpunit depends has been added, so we need a new rector is needed.
Hi all and many thanks for trying to get such a transformation package available.
While following the basic installations steps from https://pestphp.com/docs/installation/ followed by https://pestphp.com/docs/guides/drift/. I end up with an error Your requirements could not be resolved to an installable set of packages.
It seems there is some conflicts going on.
Full error from running composer require pestphp/drift --dev --update-with-all-dependencies
:
Problem 1
- pestphp/pest v0.2.x-dev conflicts with pestphp/pest-plugin-init[v0.3.0].
- pestphp/pest v0.2.x-dev conflicts with pestphp/pest-plugin-init[v0.3.0].
- pestphp/pest v0.2.x-dev conflicts with pestphp/pest-plugin-init[v0.3.0].
- pestphp/drift dev-master requires pestphp/pest ^0.2 -> satisfiable by pestphp/pest[v0.2.x-dev].
- Installation request for pestphp/drift dev-master -> satisfiable by pestphp/drift[dev-master].
- Installation request for pestphp/pest-plugin-init (locked at v0.3.0) -> satisfiable by pestphp/pest-plugin-init[v0.3.0].
Composer.json and Composer.lock created can be found at https://gist.github.com/DannyvdSluijs/92f1b30ba65de5122b5285fa443ec0eb
Let's create a new rector which orders the test alphabetically
The reason for using a new rector is so we can optionally enable/disable it and decouple it from the base rector which is about just refactoring to pest test cases, not making them nicer.
Let's create a new rector which refactors the dataset to a shared dataset.
The reason for using a new rector is so we can optionally enable/disable it and decouple it from the base rector which is about just refactoring to pest test cases, not making them nicer.
We have a small CLI tool which has no documentation at all.
We should write a small section in the readme file on how to use it.
Create a new rector which is responsible for removing $this
on methods that doesn't need them.
it('asserts true is true', function () {
$this->assertTrue(true);
// Same as
assertTrue(true);
});
The reason for using a new rector is so we can optionally enable/disable it and decouple it from the base rector which is about just refactoring to pest test cases, not making them nicer.
I think drift could benefit from a phar with dependencies, as that would remove all conflicts caused by the dependencies.
This package does currently not support PHP8.
Let's create a new rector which can migrate a pest test into a higher order test.
The reason for using a new rector is so we can optionally enable/disable it and decouple it from the base rector which is about just refactoring to pest test cases, not making them nicer.
Rector is a big reason why this project is possible, we should give them the proper acknowledgement.
Right now drift is not complete at all, there are still a bunch of features which it cannot migrate.
Here is a list of it, so we know what we need to work on before having "complete" refactor. (if something is missing, just edit the list and add it or post a comment and I'll add it)
Hey friends, Can you tell me how to run tests in drift? They seem to be failing in my machine.
Create a new rector for renaming the test.
For example when migrating a phpunit test it will take the method name directly and not touch the name. This rectors responsible should be to rename the test to have a more pest like naming.
Right now we have a test which fails because we are trying to migrate a class method to a pest helper method.
However the original class method was used in string interpolation which is not supported by functions, so the string interpolation has to be split up, so it can use the pest helper.
Example:
We have the following php class
class MethodStringInterpolationTest extends TestCase
{
private function alwaysTrueHelper()
{
return "true";
}
public function testMethod()
{
"{$this->alwaysTrueHelper()} works";
}
}
Which should be converted to
function alwaysTrueHelper()
{
return "true";
}
test('testMethod', function () {
alwaysTrueHelper() . " works";
});
Because doing "{alwaysTrueHelper()} works";
is not valid php code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.