-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Support PHPUnit 10" from 0.12.x (#475)"
This reverts commit 9b6517e.
- Loading branch information
Showing
135 changed files
with
637 additions
and
564 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Helper script to convert the tests/ folder to a PSR-4 folder structure. | ||
* | ||
* Moves tests/example/sub/File.php to tests/Example/Sub/FileTest.php. Only | ||
* convert the sub-part of the path (ignore anything before and including | ||
* tests/). | ||
* | ||
* phpcs:disable | ||
*/ | ||
|
||
use Mantle\Support\Str; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
use function Mantle\Support\Helpers\str; | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$finder = ( new Finder() ) | ||
->in( realpath( __DIR__ . '/../tests' ) ) | ||
->directories() | ||
->notPath( '#fixtures|__snapshots__|template-parts#' ); | ||
|
||
$base = Str::trailing_slash( realpath( __DIR__ . '/../tests/' ) ); | ||
|
||
foreach ( $finder as $dir ) { | ||
$old_dir = $dir->getRealPath(); | ||
|
||
if ( ! is_dir( $old_dir ) ) { | ||
continue; | ||
} | ||
|
||
$parts = str( $old_dir )->after( $base )->explode( '/' ); | ||
|
||
$parts = $parts->map( | ||
fn ( string $part ) => str( $part )->studly()->value(), | ||
); | ||
|
||
$new_dir = $base . $parts->implode( '/' ); | ||
|
||
dump( "Moving {$old_dir} to {$new_dir}" ); | ||
|
||
shell_exec( "git mv {$old_dir} {$old_dir}-tmp" ); | ||
shell_exec( "git mv {$old_dir}-tmp {$new_dir}" ); | ||
} | ||
|
||
echo "\nDONE!\n"; | ||
|
||
exit( 0 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
/** | ||
* Helper script to convert the tests/ package to PSR-4 coding standards. | ||
* | ||
* The eventual plan is to use this for the rest of the project when that can be | ||
* converted over. Ideally this can be a reusable command in the future. | ||
* | ||
* phpcs:disable | ||
*/ | ||
|
||
use Symfony\Component\Finder\Finder; | ||
|
||
use function Mantle\Support\Helpers\str; | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$finder = ( new Finder() ) | ||
->in( realpath( __DIR__ . '/../tests' ) ) | ||
->name( '*.php' ) | ||
->notName( [ 'bootstrap.php', 'sub-example.php', 'base-example.php' ] ) | ||
->notPath( '#fixtures|__snapshots__|template-parts#' ); | ||
|
||
$index = []; | ||
$pass = true; | ||
|
||
foreach ( $finder as $file ) { | ||
$filename = str( $file->getFilename() )->lower(); | ||
|
||
if ( $filename->startsWith( 'test-' ) ) { | ||
$new_filename = $filename | ||
->after( 'test-' ) | ||
->before( '.php' ) | ||
->studly() | ||
->append( 'Test.php' ) | ||
->replace( 'Wordpress', 'WordPress' ); | ||
|
||
$old_class_name = $filename | ||
->before( '.php' ) | ||
->studlyUnderscore() | ||
->replace( 'Wordpress', 'WordPress' ); | ||
|
||
$new_class_name = $filename | ||
->after( 'test-' ) | ||
->before( '.php' ) | ||
->studly() | ||
->append( 'Test' ) | ||
->replace( 'Wordpress', 'WordPress' ); | ||
} else { | ||
foreach ( [ 'trait', 'class' ] as $type ) { | ||
if ( ! $filename->startsWith( "{$type}-" ) ) { | ||
continue; | ||
} | ||
|
||
$new_filename = $filename | ||
->after( "{$type}-" ) | ||
->before( '.php' ) | ||
->studly() | ||
->append( '.php' ) | ||
->replace( 'Wordpress', 'WordPress' ); | ||
|
||
$old_class_name = $filename | ||
->after( "{$type}-" ) | ||
->before( '.php' ) | ||
->studlyUnderscore(); | ||
|
||
$new_class_name = $filename | ||
->after( "{$type}-" ) | ||
->before( '.php' ) | ||
->studly() | ||
->replace( 'Wordpress', 'WordPress' ); | ||
} | ||
} | ||
|
||
// Check if the file contains the class. | ||
$contents = str( file_get_contents( $file->getRealPath() ) ); | ||
|
||
$type = $filename->startsWith( 'trait-' ) ? 'trait' : 'class'; | ||
|
||
if ( ! $contents->contains( "{$type} {$old_class_name->value()} ", true ) ) { | ||
echo $file->getRealPath() . ' does not contain the expected legacy ' . $type . ' ' . $old_class_name->value() . PHP_EOL; | ||
|
||
$pass = false; | ||
|
||
continue; | ||
} | ||
|
||
$index[] = [ | ||
$type, | ||
[ | ||
$file->getRealPath(), | ||
$old_class_name->value(), | ||
], | ||
[ | ||
$file->getPath() . '/' . $new_filename->value(), | ||
$new_class_name->value(), | ||
], | ||
]; | ||
} | ||
|
||
if ( ! $pass ) { | ||
echo "\n\nPlease fix the above errors before continuing.\n"; | ||
|
||
exit( 1 ); | ||
} | ||
|
||
echo 'Processing ' . count( $index ) . ' files...'; | ||
|
||
foreach ( $index as $item ) { | ||
[ $type, $old, $new ] = $item; | ||
|
||
[ $old_file, $old_class ] = $old; | ||
[ $new_file, $new_class ] = $new; | ||
|
||
// Update the file with the new class name. | ||
file_put_contents( | ||
$old_file, | ||
str( file_get_contents( $old_file ) )->replace( "{$type} {$old_class} ", "{$type} {$new_class} ", false )->value(), | ||
); | ||
|
||
// Update the file name. | ||
if ( ! rename( $old_file, $new_file ) ) { | ||
echo "Failed to rename {$old_file} to {$new_file}.\n"; | ||
|
||
exit( 1 ); | ||
} | ||
|
||
echo "Updated {$old_file} to {$new_file} ({$old_class} to {$new_class}).\n"; | ||
} | ||
|
||
echo "\nDONE!\n"; | ||
|
||
exit( 0 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
<?xml version="1.0"?> | ||
<phpunit | ||
bootstrap="tests/bootstrap.php" | ||
backupGlobals="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
bootstrap="tests/bootstrap.php" | ||
backupGlobals="false" | ||
colors="true" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" | ||
> | ||
<testsuites> | ||
<testsuite name="mantle-framework"> | ||
<directory prefix="test-" suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<testsuites> | ||
<testsuite name="mantle-framework"> | ||
<directory suffix="Test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.