From 281d3a6a09dc8252d70b9f5c677a312c4bb8bf60 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 27 Nov 2023 16:13:00 -0500 Subject: [PATCH 1/5] Revert "Revert "Support PHPUnit 10" from 0.12.x (#475)" This reverts commit 9b6517e660289e43074cf72329424b9e0395d16b. --- .gitignore | 3 +- CHANGELOG.md | 6 - bin/convert-psr4-dir.php | 49 +++++ bin/convert-psr4-file.php | 132 ++++++++++++++ composer.json | 21 ++- monorepo-builder.php | 2 +- phpunit.xml | 23 ++- src/mantle/assets/composer.json | 2 +- src/mantle/support/class-stringable.php | 9 + src/mantle/testing/class-assert.php | 54 ------ .../testing/concerns/trait-deprecations.php | 12 +- .../concerns/trait-incorrect-usage.php | 13 +- .../concerns/trait-reads-annotations.php | 57 ++++++ src/mantle/testkit/composer.json | 6 +- .../AssetLoaderTest.php} | 2 +- tests/Assets/AssetManagerTest.php | 107 +++++++++++ .../TestCase.php} | 3 +- .../CacheManagerTest.php} | 2 +- .../RepositoryTest.php} | 2 +- .../CommandTest.php} | 2 +- .../GeneratorCommandTest.php} | 2 +- .../HookUsageCommandTest.php.bak} | 2 +- .../ParserTest.php} | 2 +- .../generators/PrinterTest.php} | 2 +- .../hook-usage/base-example.php | 0 .../hook-usage/sub/sub-example.php | 0 tests/{console => Console}/test.stub | 0 .../ContainerCallTest.php} | 4 +- .../ContainerTest.php} | 4 +- .../Factory/FactoryTest.php} | 2 +- .../Factory/UnitTestingFactoryTest.php} | 2 +- .../Model/AttachmentTest.php} | 2 +- .../Model/CommentObjectTest.php} | 2 +- .../Model/ModelScopeTest.php} | 2 +- .../Model/ModelTest.php} | 2 +- .../Model/PermalinkGeneratorTest.php} | 2 +- .../Model/PostModelEventsTest.php} | 2 +- .../Model/PostObjectTest.php} | 2 +- .../Model/RestFieldTest.php} | 2 +- .../Model/SiteObjectTest.php} | 2 +- .../Model/TermModelEventsTest.php} | 2 +- .../Model/TermObjectTest.php} | 2 +- .../Model/UserObjectTest.php} | 2 +- .../Model/registration/RegisterMetaTest.php} | 2 +- .../registration/RegisterPostTypeTest.php} | 2 +- .../registration/RegisterTaxonomyTest.php} | 2 +- .../relations/BelongsToOneOrManyTest.php} | 2 +- .../Model/relations/HasOneOrManyTest.php} | 2 +- .../Query/EagerLoadRelationshipsTest.php} | 2 +- .../Query/PaginatorTest.php} | 2 +- .../Query/PostQueryBuilderTest.php} | 2 +- .../Query/PostQueryRelationshipsTest.php} | 2 +- .../Query/TermQueryBuilderTest.php} | 2 +- .../EventDispatcherTest.php} | 2 +- .../WordPressActionDispatcherTest.php} | 2 +- tests/{test-faker.php => FakerTest.php} | 2 +- .../FilesystemAdapterTest.php} | 6 +- .../FilesystemManagerTest.php} | 2 +- .../FilesystemTest.php} | 168 +++++++++--------- .../AliasLoaderTest.php} | 2 +- .../ApplicationTest.php} | 2 +- .../BootloaderTest.php} | 2 +- .../Events/DiscoverEventsTest.php} | 6 +- .../fixtures/events/class-event-one.php | 0 .../fixtures/events/class-event-two.php | 0 .../listeners/class-example-listener.php | 0 .../NullableCommentObjectsTestCaseTest.php} | 2 +- .../NullablePostObjectsTestCaseTest.php} | 2 +- .../NullableSiteObjectsTestCaseTest.php | 46 +++++ .../NullableTermObjectsTestCaseTest.php} | 2 +- .../NullableUserObjectsTestCaseTest.php} | 2 +- .../IsolatedFrameworkTest.php} | 2 +- .../PipelineTest.php} | 0 .../HelpersArrayTest.php} | 2 +- .../HelpersGeneralTest.php} | 4 +- .../HelpersTest.php} | 2 +- .../ControllerTest.php} | 2 +- .../RedirectorTest.php} | 2 +- .../ResponseFactoryTest.php} | 2 +- .../test-router.php => Http/RouterTest.php} | 2 +- .../Routing/PostModelRoutingTest.php} | 2 +- .../Routing/RestApiRoutingTest.php} | 2 +- .../Routing/TermModelRoutingTest.php} | 2 +- .../UploadedFileTest.php} | 2 +- .../UrlGeneratorTest.php} | 2 +- .../HttpClientTest.php} | 2 +- .../LogManagerTest.php} | 2 +- .../DispatcherTest.php} | 2 +- .../QueueManagerTest.php} | 2 +- .../test-worker.php => Queue/WorkerTest.php} | 2 +- .../providers/WordPressCronQueueTest.php} | 2 +- .../EventTest.php} | 2 +- .../FrequencyTest.php} | 2 +- .../test-arr.php => Support/ArrTest.php} | 2 +- .../CollectionTest.php} | 8 +- .../EnvironmentTest.php} | 2 +- .../ForwardCallsTest.php} | 2 +- .../PluralizerTest.php} | 2 +- .../Providers/ModelRegisterProviderTest.php} | 2 +- .../ServiceProviderTest.php} | 2 +- .../test-str.php => Support/StrTest.php} | 2 +- .../StringableTest.php} | 2 +- .../Concerns/BlockAssertionsTest.php} | 2 +- .../Concerns/DeprecationsTest.php} | 2 +- .../Concerns/ElementAssertionsTest.php} | 2 +- .../Concerns/IncorrectUsageTest.php} | 2 +- .../Concerns/InteractsWithConsoleTest.php} | 4 +- .../InteractsWithExternalRequestsTest.php} | 2 +- .../Concerns/InteractsWithHooksTest.php} | 2 +- .../Concerns/MakesHttpRequestsTest.php} | 2 +- .../Concerns/WordPressAuthenticationTest.php} | 4 +- ...pRequestsTest__test_match_snapshot__1.yml} | 0 ...stsTest__test_match_snapshot_http__1.html} | 0 ..._test_match_snapshot_http_partial__1.html} | 0 ...stsTest__test_match_snapshot_rest__1.json} | 0 ...stsTest__test_match_snapshot_rest__2.json} | 0 ...stsTest__test_match_snapshot_rest__3.json} | 0 ...questsTest__test_multiple_requests__1.yml} | 0 .../CoreTestShimTest.php} | 2 +- .../PermalinkStructureTest.php} | 2 +- .../WithFakerTest.php} | 5 +- .../Concerns/ExampleOverload.php} | 4 +- .../TestkitInstallWordPressTest.php} | 2 +- .../TestkitTestCaseTest.php} | 6 +- .../WithFakerTest.php} | 2 +- .../fixtures/global-functions.php | 0 .../BladeViewsTest.php} | 2 +- .../FileEngineTest.php} | 2 +- .../PhpViewsTest.php} | 2 +- .../ViewFinderTest.php} | 2 +- tests/assets/test-asset-manager.php | 108 ----------- .../fixtures/blocks/class-mock-block.php | 21 --- .../fixtures/dummy/class-example-block.php | 16 -- .../framework/blocks/test-block-provider.php | 76 -------- .../test-nullable-site-objects-test-case.php | 40 ----- 135 files changed, 637 insertions(+), 564 deletions(-) create mode 100644 bin/convert-psr4-dir.php create mode 100644 bin/convert-psr4-file.php delete mode 100644 src/mantle/testing/class-assert.php create mode 100644 src/mantle/testing/concerns/trait-reads-annotations.php rename tests/{assets/test-asset-loader.php => Assets/AssetLoaderTest.php} (98%) create mode 100644 tests/Assets/AssetManagerTest.php rename tests/{assets/class-test-case.php => Assets/TestCase.php} (95%) rename tests/{cache/test-cache-manager.php => Cache/CacheManagerTest.php} (97%) rename tests/{config/test-repository.php => Config/RepositoryTest.php} (97%) rename tests/{console/test-command.php => Console/CommandTest.php} (98%) rename tests/{console/test-generator-command.php => Console/GeneratorCommandTest.php} (98%) rename tests/{console/test-hook-usage-command.php => Console/HookUsageCommandTest.php.bak} (96%) rename tests/{console/test-parser.php => Console/ParserTest.php} (99%) rename tests/{console/generators/test-printer.php => Console/generators/PrinterTest.php} (98%) rename tests/{console => Console}/hook-usage/base-example.php (100%) rename tests/{console => Console}/hook-usage/sub/sub-example.php (100%) rename tests/{console => Console}/test.stub (100%) rename tests/{container/test-container-call.php => Container/ContainerCallTest.php} (99%) rename tests/{container/test-container.php => Container/ContainerTest.php} (99%) rename tests/{database/factory/test-factory.php => Database/Factory/FactoryTest.php} (99%) rename tests/{database/factory/test-unit-testing-factory.php => Database/Factory/UnitTestingFactoryTest.php} (99%) rename tests/{database/model/test-attachment.php => Database/Model/AttachmentTest.php} (93%) rename tests/{database/model/test-comment-object.php => Database/Model/CommentObjectTest.php} (97%) rename tests/{database/model/test-model-scope.php => Database/Model/ModelScopeTest.php} (98%) rename tests/{database/model/test-model.php => Database/Model/ModelTest.php} (99%) rename tests/{database/model/test-permalink-generator.php => Database/Model/PermalinkGeneratorTest.php} (94%) rename tests/{database/model/test-post-model-events.php => Database/Model/PostModelEventsTest.php} (98%) rename tests/{database/model/test-post-object.php => Database/Model/PostObjectTest.php} (99%) rename tests/{database/model/test-rest-field.php => Database/Model/RestFieldTest.php} (93%) rename tests/{database/model/test-site-object.php => Database/Model/SiteObjectTest.php} (94%) rename tests/{database/model/test-term-model-events.php => Database/Model/TermModelEventsTest.php} (98%) rename tests/{database/model/test-term-object.php => Database/Model/TermObjectTest.php} (98%) rename tests/{database/model/test-user-object.php => Database/Model/UserObjectTest.php} (97%) rename tests/{database/model/registration/test-register-meta.php => Database/Model/registration/RegisterMetaTest.php} (95%) rename tests/{database/model/registration/test-register-post-type.php => Database/Model/registration/RegisterPostTypeTest.php} (98%) rename tests/{database/model/registration/test-register-taxonomy.php => Database/Model/registration/RegisterTaxonomyTest.php} (96%) rename tests/{database/model/relations/test-belongs-to-one-or-many.php => Database/Model/relations/BelongsToOneOrManyTest.php} (98%) rename tests/{database/model/relations/test-has-one-or-many.php => Database/Model/relations/HasOneOrManyTest.php} (99%) rename tests/{database/query/test-eager-load-relationships.php => Database/Query/EagerLoadRelationshipsTest.php} (99%) rename tests/{database/query/test-paginator.php => Database/Query/PaginatorTest.php} (99%) rename tests/{database/query/test-post-query-builder.php => Database/Query/PostQueryBuilderTest.php} (99%) rename tests/{database/query/test-post-query-relationships.php => Database/Query/PostQueryRelationshipsTest.php} (97%) rename tests/{database/query/test-term-query-builder.php => Database/Query/TermQueryBuilderTest.php} (98%) rename tests/{events/test-event-dispatcher.php => Events/EventDispatcherTest.php} (97%) rename tests/{events/test-wordpress-action-dispatcher.php => Events/WordPressActionDispatcherTest.php} (98%) rename tests/{test-faker.php => FakerTest.php} (96%) rename tests/{filesystem/test-filesystem-adapter.php => Filesystem/FilesystemAdapterTest.php} (98%) rename tests/{filesystem/test-filesystem-manager.php => Filesystem/FilesystemManagerTest.php} (97%) rename tests/{filesystem/test-filesystem.php => Filesystem/FilesystemTest.php} (67%) rename tests/{framework/test-alias-loader.php => Framework/AliasLoaderTest.php} (97%) rename tests/{framework/test-application.php => Framework/ApplicationTest.php} (98%) rename tests/{framework/test-bootloader.php => Framework/BootloaderTest.php} (98%) rename tests/{framework/events/test-discover-events.php => Framework/Events/DiscoverEventsTest.php} (88%) rename tests/{framework/events => Framework/Events}/fixtures/events/class-event-one.php (100%) rename tests/{framework/events => Framework/Events}/fixtures/events/class-event-two.php (100%) rename tests/{framework/events => Framework/Events}/fixtures/listeners/class-example-listener.php (100%) rename tests/{framework/helpers/test-nullable-comment-objects-test-case.php => Framework/Helpers/NullableCommentObjectsTestCaseTest.php} (93%) rename tests/{framework/helpers/test-nullable-post-objects-test-case.php => Framework/Helpers/NullablePostObjectsTestCaseTest.php} (95%) create mode 100644 tests/Framework/Helpers/NullableSiteObjectsTestCaseTest.php rename tests/{framework/helpers/test-nullable-term-objects-test-case.php => Framework/Helpers/NullableTermObjectsTestCaseTest.php} (98%) rename tests/{framework/helpers/test-nullable-user-objects-test-case.php => Framework/Helpers/NullableUserObjectsTestCaseTest.php} (95%) rename tests/{framework/test-isolated-framework.php => Framework/IsolatedFrameworkTest.php} (95%) rename tests/{framework/test-pipeline.php => Framework/PipelineTest.php} (100%) rename tests/{helpers/test-helpers-array.php => Helpers/HelpersArrayTest.php} (99%) rename tests/{helpers/test-helpers-general.php => Helpers/HelpersGeneralTest.php} (98%) rename tests/{helpers/test-helpers.php => Helpers/HelpersTest.php} (98%) rename tests/{http/test-controller.php => Http/ControllerTest.php} (97%) rename tests/{http/test-redirector.php => Http/RedirectorTest.php} (98%) rename tests/{http/test-response-factory.php => Http/ResponseFactoryTest.php} (93%) rename tests/{http/test-router.php => Http/RouterTest.php} (99%) rename tests/{http/routing/test-post-model-routing.php => Http/Routing/PostModelRoutingTest.php} (97%) rename tests/{http/routing/test-rest-api-routing.php => Http/Routing/RestApiRoutingTest.php} (98%) rename tests/{http/routing/test-term-model-routing.php => Http/Routing/TermModelRoutingTest.php} (98%) rename tests/{http/test-uploaded-file.php => Http/UploadedFileTest.php} (94%) rename tests/{http/test-url-generator.php => Http/UrlGeneratorTest.php} (98%) rename tests/{http-client/test-http-client.php => HttpClient/HttpClientTest.php} (99%) rename tests/{log/test-log-manager.php => Log/LogManagerTest.php} (97%) rename tests/{queue/test-dispatcher.php => Queue/DispatcherTest.php} (96%) rename tests/{queue/test-queue-manager.php => Queue/QueueManagerTest.php} (94%) rename tests/{queue/test-worker.php => Queue/WorkerTest.php} (98%) rename tests/{queue/providers/test-wordpress-cron-queue.php => Queue/providers/WordPressCronQueueTest.php} (98%) rename tests/{scheduling/test-event.php => Scheduling/EventTest.php} (97%) rename tests/{scheduling/test-frequency.php => Scheduling/FrequencyTest.php} (98%) rename tests/{support/test-arr.php => Support/ArrTest.php} (99%) rename tests/{support/test-collection.php => Support/CollectionTest.php} (99%) rename tests/{support/test-environment.php => Support/EnvironmentTest.php} (94%) rename tests/{support/test-forward-calls.php => Support/ForwardCallsTest.php} (98%) rename tests/{support/test-pluralizer.php => Support/PluralizerTest.php} (99%) rename tests/{support/providers/test-model-register-provider.php => Support/Providers/ModelRegisterProviderTest.php} (94%) rename tests/{support/test-service-provider.php => Support/ServiceProviderTest.php} (99%) rename tests/{support/test-str.php => Support/StrTest.php} (99%) rename tests/{support/test-stringable.php => Support/StringableTest.php} (99%) rename tests/{testing/concerns/test-block-assertions.php => Testing/Concerns/BlockAssertionsTest.php} (95%) rename tests/{testing/concerns/test-deprecations.php => Testing/Concerns/DeprecationsTest.php} (96%) rename tests/{testing/concerns/test-element-assertions.php => Testing/Concerns/ElementAssertionsTest.php} (96%) rename tests/{testing/concerns/test-incorrect-usage.php => Testing/Concerns/IncorrectUsageTest.php} (96%) rename tests/{testing/concerns/test-interacts-with-console.php => Testing/Concerns/InteractsWithConsoleTest.php} (93%) rename tests/{testing/concerns/test-interacts-with-external-requests.php => Testing/Concerns/InteractsWithExternalRequestsTest.php} (99%) rename tests/{testing/concerns/test-interacts-with-hooks.php => Testing/Concerns/InteractsWithHooksTest.php} (98%) rename tests/{testing/concerns/test-makes-http-requests.php => Testing/Concerns/MakesHttpRequestsTest.php} (99%) rename tests/{testing/concerns/test-wordpress-authentication.php => Testing/Concerns/WordPressAuthenticationTest.php} (90%) rename tests/{testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot__1.yml => Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot__1.yml} (100%) rename tests/{testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_http__1.html => Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_http__1.html} (100%) rename tests/{testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_http_partial__1.html => Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_http_partial__1.html} (100%) rename tests/{testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_rest__1.json => Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_rest__1.json} (100%) rename tests/{testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_rest__2.json => Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_rest__2.json} (100%) rename tests/{testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_rest__3.json => Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_rest__3.json} (100%) rename tests/{testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_multiple_requests__1.yml => Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_multiple_requests__1.yml} (100%) rename tests/{testing/test-core-test-shim.php => Testing/CoreTestShimTest.php} (88%) rename tests/{testing/test-permalink-structure.php => Testing/PermalinkStructureTest.php} (97%) rename tests/{testing/test-with-faker.php => Testing/WithFakerTest.php} (62%) rename tests/{testkit/concerns/trait-example-overload.php => Testkit/Concerns/ExampleOverload.php} (83%) rename tests/{testkit/test-testkit-install-wordpress.php => Testkit/TestkitInstallWordPressTest.php} (92%) rename tests/{testkit/test-testkit-test-case.php => Testkit/TestkitTestCaseTest.php} (87%) rename tests/{testkit/test-with-faker.php => Testkit/WithFakerTest.php} (85%) rename tests/{testkit => Testkit}/fixtures/global-functions.php (100%) rename tests/{view/test-blade-views.php => View/BladeViewsTest.php} (93%) rename tests/{view/test-file-engine.php => View/FileEngineTest.php} (91%) rename tests/{view/test-php-views.php => View/PhpViewsTest.php} (99%) rename tests/{view/test-view-finder.php => View/ViewFinderTest.php} (96%) delete mode 100644 tests/assets/test-asset-manager.php delete mode 100644 tests/framework/blocks/fixtures/blocks/class-mock-block.php delete mode 100644 tests/framework/blocks/fixtures/dummy/class-example-block.php delete mode 100644 tests/framework/blocks/test-block-provider.php delete mode 100644 tests/framework/helpers/test-nullable-site-objects-test-case.php diff --git a/.gitignore b/.gitignore index 45629dbc1..60f1b8914 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ vendor # Cache files .phpcs/*.json .phpunit.result.cache +.phpunit.cache/ # Composer files composer.lock @@ -26,4 +27,4 @@ Thumbs.db # IDE files *.code-workspace .idea -.vscode \ No newline at end of file +.vscode diff --git a/CHANGELOG.md b/CHANGELOG.md index e61314bec..f0266a5e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,6 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## v0.12.9 - 2023-11-27 - -### Changed - -- Removed PHPUnit 10 support to prevent a breaking change. Moved to 1.x. - ## v0.12.8 - 2023-11-21 ### Changed diff --git a/bin/convert-psr4-dir.php b/bin/convert-psr4-dir.php new file mode 100644 index 000000000..0dc6e5352 --- /dev/null +++ b/bin/convert-psr4-dir.php @@ -0,0 +1,49 @@ +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 ); diff --git a/bin/convert-psr4-file.php b/bin/convert-psr4-file.php new file mode 100644 index 000000000..24085d0a8 --- /dev/null +++ b/bin/convert-psr4-file.php @@ -0,0 +1,132 @@ +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 ); diff --git a/composer.json b/composer.json index 5ebdbbf0b..714474f42 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "require": { "php": "^8.0", "alleyinteractive/composer-wordpress-autoloader": "^1.0", - "alleyinteractive/wp-asset-manager": "^1.3.3", + "alleyinteractive/wp-asset-manager": "^1.3.4", "alleyinteractive/wp-caper": "^2.0.1", "alleyinteractive/wp-concurrent-remote-requests": "^1.0.2", "alleyinteractive/wp-filter-side-effects": "^2.0", @@ -28,13 +28,13 @@ "monolog/monolog": "^2.9.1", "nesbot/carbon": "^2.68.1", "nette/php-generator": "^3.6.9", - "nunomaduro/collision": "^6.4", + "nunomaduro/collision": "^6.0 || ^7.0", "nunomaduro/termwind": "^1.15.1", "psr/container": "^1.1.1 || ^2.0.2", "psr/log": "^1.0.1 || ^2.0 || ^3.0", "psr/simple-cache": "^3.0", "ramsey/uuid": "^4.7.4", - "spatie/phpunit-snapshot-assertions": "^4.2", + "spatie/phpunit-snapshot-assertions": "^4.2 || ^5.1", "symfony/console": "^6.0.19", "symfony/finder": "^6.0.19", "symfony/http-foundation": "^6.0.20", @@ -54,8 +54,8 @@ "mockery/mockery": "^1.6.6", "php-stubs/wp-cli-stubs": "^2.8", "phpstan/phpdoc-parser": "^1.23.1", - "phpstan/phpstan": "1.10.43", - "phpunit/phpunit": "^9.3.3", + "phpstan/phpstan": "1.10.44", + "phpunit/phpunit": "^9.3.3 || ^10.0.7", "predis/predis": "^2.2.0", "squizlabs/php_codesniffer": "^3.7", "symplify/monorepo-builder": "^10.3.3", @@ -86,6 +86,8 @@ "mantle-framework/testkit": "self.version", "mantle-framework/view": "self.version" }, + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "files": [ "src/mantle/framework/helpers.php", @@ -100,6 +102,11 @@ "src/mantle/testing/autoload.php" ] }, + "autoload-dev": { + "psr-4": { + "Mantle\\Tests\\": "tests/" + } + }, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, @@ -137,7 +144,5 @@ "@phpstan", "@phpunit" ] - }, - "minimum-stability": "dev", - "prefer-stable": true + } } diff --git a/monorepo-builder.php b/monorepo-builder.php index e61ed5f87..f0ab4b804 100644 --- a/monorepo-builder.php +++ b/monorepo-builder.php @@ -54,7 +54,7 @@ ], ComposerJsonSection::REQUIRE_DEV => [ 'alleyinteractive/alley-coding-standards' => '^1.0', - 'phpunit/phpunit' => '^9.6.10', + 'phpunit/phpunit' => '^9.3.3|^10.0.7', ], ], ); diff --git a/phpunit.xml b/phpunit.xml index ee9e68869..397400ca9 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,15 +1,14 @@ + - - - ./tests/ - - + + + ./tests/ + + diff --git a/src/mantle/assets/composer.json b/src/mantle/assets/composer.json index 23467eb30..7ac86c95b 100644 --- a/src/mantle/assets/composer.json +++ b/src/mantle/assets/composer.json @@ -5,7 +5,7 @@ "require": { "php": "^8.0", "alleyinteractive/composer-wordpress-autoloader": "^1.0", - "alleyinteractive/wp-asset-manager": "^1.3.3", + "alleyinteractive/wp-asset-manager": "^1.3.4", "mantle-framework/contracts": "^0.12", "mantle-framework/support": "^0.12" }, diff --git a/src/mantle/support/class-stringable.php b/src/mantle/support/class-stringable.php index a8b47bf5b..b115b963e 100644 --- a/src/mantle/support/class-stringable.php +++ b/src/mantle/support/class-stringable.php @@ -737,6 +737,15 @@ public function studly() { return new static( Str::studly( $this->value ) ); } + /** + * Convert a value to studly caps case using underscores. + * + * @return static + */ + public function studlyUnderscore() { + return new static( Str::studly_underscore( $this->value ) ); + } + /** * Returns the portion of the string specified by the start and length parameters. * diff --git a/src/mantle/testing/class-assert.php b/src/mantle/testing/class-assert.php deleted file mode 100644 index 0d97a2322..000000000 --- a/src/mantle/testing/class-assert.php +++ /dev/null @@ -1,54 +0,0 @@ -getName() - ); - } else { - $annotations = $this->getAnnotations(); - } + $annotations = $this->get_annotations_for_method(); foreach ( [ 'class', 'method' ] as $depth ) { if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) { diff --git a/src/mantle/testing/concerns/trait-incorrect-usage.php b/src/mantle/testing/concerns/trait-incorrect-usage.php index 9f5ac3fd2..1c0e1d034 100644 --- a/src/mantle/testing/concerns/trait-incorrect-usage.php +++ b/src/mantle/testing/concerns/trait-incorrect-usage.php @@ -10,8 +10,6 @@ namespace Mantle\Testing\Concerns; use Mantle\Support\Str; -use PHPUnit\TextUI\XmlConfiguration\PHPUnit; -use PHPUnit\Util\Test; use function Mantle\Support\Helpers\collect; @@ -22,7 +20,7 @@ * as expected or ignored. */ trait Incorrect_Usage { - use Output_Messages; + use Output_Messages, Reads_Annotations; /** * Expected "doing it wrong" calls. @@ -56,14 +54,7 @@ trait Incorrect_Usage { * Sets up the expectations for testing a deprecated call. */ public function incorrect_usage_set_up() { - if ( ! method_exists( $this, 'getAnnotations' ) ) { - $annotations = Test::parseTestMethodAnnotations( - static::class, - $this->getName() - ); - } else { - $annotations = $this->getAnnotations(); - } + $annotations = $this->get_annotations_for_method(); foreach ( [ 'class', 'method' ] as $depth ) { if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) ) { diff --git a/src/mantle/testing/concerns/trait-reads-annotations.php b/src/mantle/testing/concerns/trait-reads-annotations.php new file mode 100644 index 000000000..6d64df2a0 --- /dev/null +++ b/src/mantle/testing/concerns/trait-reads-annotations.php @@ -0,0 +1,57 @@ +getAnnotations(); + } + + // Use the PHPUnit ^9.5 method if available. + if ( method_exists( Test::class, 'parseTestMethodAnnotations' ) ) { // @phpstan-ignore-line + return Test::parseTestMethodAnnotations( + static::class, + $this->getName(), // @phpstan-ignore-line + ); + } + + // Use the PHPUnit 10.x method if available. + if ( class_exists( Registry::class ) && class_exists( DocBlock::class ) ) { + $registry = Registry::getInstance(); + + return [ + 'class' => $registry->forClassName( static::class )->symbolAnnotations(), + 'method' => $registry->forMethod( static::class, $this->name() )->symbolAnnotations(), + ]; + } + + // Throw a warning if we can't read annotations. + trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error + 'Unable to read annotations for test method. Please file an issue with https://github.com/alleyinteractive/mantle-framework', + E_USER_WARNING + ); + + return []; + } +} diff --git a/src/mantle/testkit/composer.json b/src/mantle/testkit/composer.json index 5049aa74e..c707523bc 100644 --- a/src/mantle/testkit/composer.json +++ b/src/mantle/testkit/composer.json @@ -13,9 +13,9 @@ "mantle-framework/faker": "^0.12", "mantle-framework/support": "^0.12", "mantle-framework/testing": "^0.12", - "nunomaduro/collision": "^6.4", - "phpunit/phpunit": "^9.6.10", - "symfony/http-foundation": "^6.0.20" + "nunomaduro/collision": "^6.0 || ^7.0", + "phpunit/phpunit": "^9.3.3|^10.0.7", + "symfony/http-foundation": "^6.0" }, "extra": { "wordpress-autoloader": { diff --git a/tests/assets/test-asset-loader.php b/tests/Assets/AssetLoaderTest.php similarity index 98% rename from tests/assets/test-asset-loader.php rename to tests/Assets/AssetLoaderTest.php index 988286c2e..53b8c3d7a 100644 --- a/tests/assets/test-asset-loader.php +++ b/tests/Assets/AssetLoaderTest.php @@ -5,7 +5,7 @@ use Mantle\Assets\Asset_Loader; use Mantle\Assets\Exception\Asset_Not_Found; -class Test_Asset_Loader extends Test_Case { +class AssetLoaderTest extends TestCase { public string $build_dir = ''; public Asset_Loader $loader; diff --git a/tests/Assets/AssetManagerTest.php b/tests/Assets/AssetManagerTest.php new file mode 100644 index 000000000..43fb6f6b7 --- /dev/null +++ b/tests/Assets/AssetManagerTest.php @@ -0,0 +1,107 @@ +script( + 'script-handle', + 'https://example.org/script.js', + [ + 'jquery', + ], + 'global', + 'sync', + ); + + $this->assertStringContainsString( + '', + $this->get_wp_head(), + ); + } + + public function test_register_style() { + $manager = new Asset_Manager(); + $manager + ->style( + 'style-handle', + 'https://example.org/style.css', + [] + ); + + $this->assertStringContainsString( + '', + $this->get_wp_head(), + ); + } + + public function test_async_script() { + $manager = new Asset_Manager(); + $manager + ->script( + 'testsync-script-handle', + 'https://example.org/example-script.js', + ); + + $manager->async( 'testsync-script-handle' ); + + $this->assertStringContainsString( + '', + $this->get_wp_head(), + ); + } + + public function test_fluent_script() { + $manager = new Asset_Manager(); + $manager + ->script( 'example-fluent' ) + ->src( 'https://example.org/example-fluent.js' ) + ->async(); + + $this->assertStringContainsString( + '', + $this->get_wp_head(), + ); + } + + public function test_fluent_script_helper() { + asset() + ->script( 'example-helper' ) + ->src( 'https://example.org/example-helper.js' ) + ->async(); + + $this->assertStringContainsString( + '', + $this->get_wp_head(), + ); + } + + public function test_core_dependency() { + global $wp_scripts; + + // Prevent a failing test if this is removed in the future. + if ( ! isset( $wp_scripts->registered['swfobject'] ) ) { + $this->markTestSkipped( 'swfobject is not registered in core, should change the dependency tested against' ); + } + + $version = $wp_scripts->registered['swfobject']->ver; + + // Get the core version of the asset. + ( new Asset_Manager() ) + ->script( 'swfobject' ) + ->version( null ) + ->async(); + + $this->assertStringContainsString( + '', + $this->get_wp_head(), + ); + } +} diff --git a/tests/assets/class-test-case.php b/tests/Assets/TestCase.php similarity index 95% rename from tests/assets/class-test-case.php rename to tests/Assets/TestCase.php index 5773d3c14..0d2a73137 100644 --- a/tests/assets/class-test-case.php +++ b/tests/Assets/TestCase.php @@ -9,7 +9,7 @@ use Mantle\Testing\Framework_Test_Case; use WP_Scripts; -abstract class Test_Case extends Framework_Test_Case { +abstract class TestCase extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); @@ -48,6 +48,7 @@ function() { protected function get_wp_head(): string { ob_start(); do_action( 'wp_head' ); + // do_action( 'wp_footer' ); return ob_get_clean(); } diff --git a/tests/cache/test-cache-manager.php b/tests/Cache/CacheManagerTest.php similarity index 97% rename from tests/cache/test-cache-manager.php rename to tests/Cache/CacheManagerTest.php index aeae9f91d..6bc70c213 100644 --- a/tests/cache/test-cache-manager.php +++ b/tests/Cache/CacheManagerTest.php @@ -7,7 +7,7 @@ use Mantle\Testing\Framework_Test_Case; use Predis\Connection\ConnectionException; -class Test_Cache_Manager extends Framework_Test_Case { +class CacheManagerTest extends Framework_Test_Case { public function test_unconfigured_store() { $this->expectException( InvalidArgumentException::class ); $this->expectExceptionMessage( 'Driver not specified for [invalid-store].' ); diff --git a/tests/config/test-repository.php b/tests/Config/RepositoryTest.php similarity index 97% rename from tests/config/test-repository.php rename to tests/Config/RepositoryTest.php index 7858361fb..7f1b53cd2 100644 --- a/tests/config/test-repository.php +++ b/tests/Config/RepositoryTest.php @@ -4,7 +4,7 @@ use Mantle\Config\Repository; use PHPUnit\Framework\TestCase; -class Test_Repository extends TestCase { +class RepositoryTest extends TestCase { /** * @var Repository */ diff --git a/tests/console/test-command.php b/tests/Console/CommandTest.php similarity index 98% rename from tests/console/test-command.php rename to tests/Console/CommandTest.php index a5c15a241..ceab16256 100644 --- a/tests/console/test-command.php +++ b/tests/Console/CommandTest.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; -class Test_Command extends TestCase { +class CommandTest extends TestCase { public function test_registering_command_with_just_name() { $command = new class extends Command { diff --git a/tests/console/test-generator-command.php b/tests/Console/GeneratorCommandTest.php similarity index 98% rename from tests/console/test-generator-command.php rename to tests/Console/GeneratorCommandTest.php index 6622020bc..46b25add2 100644 --- a/tests/console/test-generator-command.php +++ b/tests/Console/GeneratorCommandTest.php @@ -13,7 +13,7 @@ use Mantle\Framework\Console\Generators\Stub_Generator_Command; use Mockery as m; -class Test_Generator_Command extends \Mockery\Adapter\Phpunit\MockeryTestCase { +class GeneratorCommandTest extends \Mockery\Adapter\Phpunit\MockeryTestCase { /** * @var Application */ diff --git a/tests/console/test-hook-usage-command.php b/tests/Console/HookUsageCommandTest.php.bak similarity index 96% rename from tests/console/test-hook-usage-command.php rename to tests/Console/HookUsageCommandTest.php.bak index 0618b1af4..06b8c35de 100644 --- a/tests/console/test-hook-usage-command.php +++ b/tests/Console/HookUsageCommandTest.php.bak @@ -12,7 +12,7 @@ use Mantle\Testing\Framework_Test_Case; // Disabling until command testing is reimplimented. -// class Test_Hook_Usage_Command extends Framework_Test_Case { +// class HookUsageCommandTest extends Framework_Test_Case { // public function test_do_action() { // $usage = $this->run_command( 'init' )->all(); diff --git a/tests/console/test-parser.php b/tests/Console/ParserTest.php similarity index 99% rename from tests/console/test-parser.php rename to tests/Console/ParserTest.php index a4d35190a..716748893 100644 --- a/tests/console/test-parser.php +++ b/tests/Console/ParserTest.php @@ -6,7 +6,7 @@ use InvalidArgumentException; use PHPUnit\Framework\TestCase; -class Test_Parser extends TestCase { +class ParserTest extends TestCase { public function testBasicParameterParsing() { $results = Parser::parse( 'command:name' ); diff --git a/tests/console/generators/test-printer.php b/tests/Console/generators/PrinterTest.php similarity index 98% rename from tests/console/generators/test-printer.php rename to tests/Console/generators/PrinterTest.php index badb2e835..4b9b8bf5e 100644 --- a/tests/console/generators/test-printer.php +++ b/tests/Console/generators/PrinterTest.php @@ -7,7 +7,7 @@ use PHP_CodeSniffer\Runner; use PHPUnit\Framework\TestCase; -class Test_Printer extends TestCase { +class PrinterTest extends TestCase { protected static $temp_dir; protected static $argv; diff --git a/tests/console/hook-usage/base-example.php b/tests/Console/hook-usage/base-example.php similarity index 100% rename from tests/console/hook-usage/base-example.php rename to tests/Console/hook-usage/base-example.php diff --git a/tests/console/hook-usage/sub/sub-example.php b/tests/Console/hook-usage/sub/sub-example.php similarity index 100% rename from tests/console/hook-usage/sub/sub-example.php rename to tests/Console/hook-usage/sub/sub-example.php diff --git a/tests/console/test.stub b/tests/Console/test.stub similarity index 100% rename from tests/console/test.stub rename to tests/Console/test.stub diff --git a/tests/container/test-container-call.php b/tests/Container/ContainerCallTest.php similarity index 99% rename from tests/container/test-container-call.php rename to tests/Container/ContainerCallTest.php index 62a143213..0b575a610 100644 --- a/tests/container/test-container-call.php +++ b/tests/Container/ContainerCallTest.php @@ -10,7 +10,7 @@ use ReflectionException; use stdClass; -class Test_Container_Call extends TestCase { +class ContainerCallTest extends TestCase { public function testCallWithAtSignBasedClassReferencesWithoutMethodThrowsException() { $this->expectException( Error::class ); @@ -188,7 +188,7 @@ public function testCallWithoutRequiredParamsThrowsException() { public function testCallWithoutRequiredParamsOnClosureThrowsException() { $this->expectException( Binding_Resolution_Exception::class ); - $this->expectExceptionMessage( 'Unable to resolve dependency [Parameter #0 [ $foo ]] in class Mantle\Tests\Container\Test_Container_Call' ); + $this->expectExceptionMessage( 'Unable to resolve dependency [Parameter #0 [ $foo ]] in class Mantle\Tests\Container\ContainerCallTest' ); $container = new Container(); $foo = $container->call( diff --git a/tests/container/test-container.php b/tests/Container/ContainerTest.php similarity index 99% rename from tests/container/test-container.php rename to tests/Container/ContainerTest.php index aab2526bc..cb3330d5c 100644 --- a/tests/container/test-container.php +++ b/tests/Container/ContainerTest.php @@ -8,7 +8,7 @@ use Psr\Container\ContainerExceptionInterface; use stdClass; -class Test_Container extends TestCase { +class ContainerTest extends TestCase { protected function tearDown(): void { Container::set_instance( null ); } @@ -443,7 +443,7 @@ function () { public function testMakeWithMethodIsAnAliasForMakeMethod() { $mock = $this->getMockBuilder( Container::class ) - ->setMethods( [ 'make' ] ) + ->onlyMethods( [ 'make' ] ) ->getMock(); $mock->expects( $this->once() ) diff --git a/tests/database/factory/test-factory.php b/tests/Database/Factory/FactoryTest.php similarity index 99% rename from tests/database/factory/test-factory.php rename to tests/Database/Factory/FactoryTest.php index 67cd6992d..08cde70c7 100644 --- a/tests/database/factory/test-factory.php +++ b/tests/Database/Factory/FactoryTest.php @@ -9,7 +9,7 @@ /** * @group factory */ -class Test_Factory extends Framework_Test_Case { +class FactoryTest extends Framework_Test_Case { public function test_create_basic_model() { $factory = Testable_Post::factory(); diff --git a/tests/database/factory/test-unit-testing-factory.php b/tests/Database/Factory/UnitTestingFactoryTest.php similarity index 99% rename from tests/database/factory/test-unit-testing-factory.php rename to tests/Database/Factory/UnitTestingFactoryTest.php index 54cf3b810..2a75c2106 100644 --- a/tests/database/factory/test-unit-testing-factory.php +++ b/tests/Database/Factory/UnitTestingFactoryTest.php @@ -17,7 +17,7 @@ * * @group factory */ -class Test_Unit_Testing_Factory extends Framework_Test_Case { +class UnitTestingFactoryTest extends Framework_Test_Case { use With_Faker; public function test_post_factory() { diff --git a/tests/database/model/test-attachment.php b/tests/Database/Model/AttachmentTest.php similarity index 93% rename from tests/database/model/test-attachment.php rename to tests/Database/Model/AttachmentTest.php index 78d479f7a..ed9d15b39 100644 --- a/tests/database/model/test-attachment.php +++ b/tests/Database/Model/AttachmentTest.php @@ -4,7 +4,7 @@ use Mantle\Database\Model\Attachment; use Mantle\Testing\Framework_Test_Case; -class Test_Attachment extends Framework_Test_Case { +class AttachmentTest extends Framework_Test_Case { /** * @var int */ diff --git a/tests/database/model/test-comment-object.php b/tests/Database/Model/CommentObjectTest.php similarity index 97% rename from tests/database/model/test-comment-object.php rename to tests/Database/Model/CommentObjectTest.php index c5161fb13..185ac08ef 100644 --- a/tests/database/model/test-comment-object.php +++ b/tests/Database/Model/CommentObjectTest.php @@ -5,7 +5,7 @@ use Mantle\Testing\Framework_Test_Case; -class Test_Comment_Object extends Framework_Test_Case { +class CommentObjectTest extends Framework_Test_Case { public function test_comment_object() { $comment = $this->factory->comment->create_and_get(); $object = Comment::find( $comment ); diff --git a/tests/database/model/test-model-scope.php b/tests/Database/Model/ModelScopeTest.php similarity index 98% rename from tests/database/model/test-model-scope.php rename to tests/Database/Model/ModelScopeTest.php index 8986932b6..06b604582 100644 --- a/tests/database/model/test-model-scope.php +++ b/tests/Database/Model/ModelScopeTest.php @@ -9,7 +9,7 @@ use Mantle\Database\Query\Post_Query_Builder; use Mantle\Testing\Framework_Test_Case; -class Test_Model_Scope extends Framework_Test_Case { +class ModelScopeTest extends Framework_Test_Case { public function test_local_scope() { $post_id = $this->get_random_post_id(); diff --git a/tests/database/model/test-model.php b/tests/Database/Model/ModelTest.php similarity index 99% rename from tests/database/model/test-model.php rename to tests/Database/Model/ModelTest.php index 1a830b35c..f0ac5b152 100644 --- a/tests/database/model/test-model.php +++ b/tests/Database/Model/ModelTest.php @@ -9,7 +9,7 @@ /** * Test non-WordPress specific logic of the model */ -class Test_Model extends Framework_Test_Case { +class ModelTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); diff --git a/tests/database/model/test-permalink-generator.php b/tests/Database/Model/PermalinkGeneratorTest.php similarity index 94% rename from tests/database/model/test-permalink-generator.php rename to tests/Database/Model/PermalinkGeneratorTest.php index 9481b04e1..92b9892cc 100644 --- a/tests/database/model/test-permalink-generator.php +++ b/tests/Database/Model/PermalinkGeneratorTest.php @@ -5,7 +5,7 @@ use Mantle\Database\Model\Post; use Mantle\Testing\Framework_Test_Case; -class Test_Permalink_Generator extends Framework_Test_Case { +class PermalinkGeneratorTest extends Framework_Test_Case { public function test_generate_permalink() { $post = static::factory()->post->create_and_get(); $model = Testable_Post_Generator::find( $post->ID ); diff --git a/tests/database/model/test-post-model-events.php b/tests/Database/Model/PostModelEventsTest.php similarity index 98% rename from tests/database/model/test-post-model-events.php rename to tests/Database/Model/PostModelEventsTest.php index f78a3eb7a..72b736745 100644 --- a/tests/database/model/test-post-model-events.php +++ b/tests/Database/Model/PostModelEventsTest.php @@ -7,7 +7,7 @@ /** * Test non-WordPress specific logic of the model */ -class Test_Post_Model_Events extends Framework_Test_Case { +class PostModelEventsTest extends Framework_Test_Case { public function setUp(): void { parent::setUp(); diff --git a/tests/database/model/test-post-object.php b/tests/Database/Model/PostObjectTest.php similarity index 99% rename from tests/database/model/test-post-object.php rename to tests/Database/Model/PostObjectTest.php index 6ecc6a014..9beccccea 100644 --- a/tests/database/model/test-post-object.php +++ b/tests/Database/Model/PostObjectTest.php @@ -10,7 +10,7 @@ use Mantle\Testing\Framework_Test_Case; use Mantle\Testing\Utils; -class Test_Post_Object extends Framework_Test_Case { +class PostObjectTest extends Framework_Test_Case { use Refresh_Database; protected function setUp(): void { diff --git a/tests/database/model/test-rest-field.php b/tests/Database/Model/RestFieldTest.php similarity index 93% rename from tests/database/model/test-rest-field.php rename to tests/Database/Model/RestFieldTest.php index 6a0aa92f3..ca8b55366 100644 --- a/tests/database/model/test-rest-field.php +++ b/tests/Database/Model/RestFieldTest.php @@ -5,7 +5,7 @@ use Mantle\Database\Model\Registration\Register_Rest_Fields; use Mantle\Testing\Framework_Test_Case; -class Test_Rest_Field extends Framework_Test_Case { +class RestFieldTest extends Framework_Test_Case { public function test_rest_field() { Testable_Model_With_Rest_Field::boot_if_not_booted(); diff --git a/tests/database/model/test-site-object.php b/tests/Database/Model/SiteObjectTest.php similarity index 94% rename from tests/database/model/test-site-object.php rename to tests/Database/Model/SiteObjectTest.php index 00537b042..e58c26d68 100644 --- a/tests/database/model/test-site-object.php +++ b/tests/Database/Model/SiteObjectTest.php @@ -6,7 +6,7 @@ use Mantle\Testing\Framework_Test_Case; -class Test_Site_Object extends Framework_Test_Case { +class SiteObjectTest extends Framework_Test_Case { use Multisite_Test; public function test_site_attributes() { diff --git a/tests/database/model/test-term-model-events.php b/tests/Database/Model/TermModelEventsTest.php similarity index 98% rename from tests/database/model/test-term-model-events.php rename to tests/Database/Model/TermModelEventsTest.php index 42b4d69e7..e54963886 100644 --- a/tests/database/model/test-term-model-events.php +++ b/tests/Database/Model/TermModelEventsTest.php @@ -7,7 +7,7 @@ /** * Test non-WordPress specific logic of the model */ -class Test_Term_Model_Events extends Framework_Test_Case { +class TermModelEventsTest extends Framework_Test_Case { public function setUp(): void { parent::setUp(); diff --git a/tests/database/model/test-term-object.php b/tests/Database/Model/TermObjectTest.php similarity index 98% rename from tests/database/model/test-term-object.php rename to tests/Database/Model/TermObjectTest.php index d8c127d14..0aac358ba 100644 --- a/tests/database/model/test-term-object.php +++ b/tests/Database/Model/TermObjectTest.php @@ -8,7 +8,7 @@ use Mantle\Testing\Framework_Test_Case; -class Test_Term_Object extends Framework_Test_Case { +class TermObjectTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); Example_Taxonomy::register_object(); diff --git a/tests/database/model/test-user-object.php b/tests/Database/Model/UserObjectTest.php similarity index 97% rename from tests/database/model/test-user-object.php rename to tests/Database/Model/UserObjectTest.php index 41935e03d..07bcfa5c1 100644 --- a/tests/database/model/test-user-object.php +++ b/tests/Database/Model/UserObjectTest.php @@ -5,7 +5,7 @@ use Mantle\Database\Model\User; use Mantle\Testing\Framework_Test_Case; -class Test_User_Object extends Framework_Test_Case { +class UserObjectTest extends Framework_Test_Case { /** * @var Factory */ diff --git a/tests/database/model/registration/test-register-meta.php b/tests/Database/Model/registration/RegisterMetaTest.php similarity index 95% rename from tests/database/model/registration/test-register-meta.php rename to tests/Database/Model/registration/RegisterMetaTest.php index 1853b4607..25a59c1da 100644 --- a/tests/database/model/registration/test-register-meta.php +++ b/tests/Database/Model/registration/RegisterMetaTest.php @@ -6,7 +6,7 @@ use Mantle\Database\Model\Registration\Register_Meta; use Mantle\Testing\Framework_Test_Case; -class Test_Register_Meta extends Framework_Test_Case { +class RegisterMetaTest extends Framework_Test_Case { public function test_register_meta() { $this->expectApplied( 'mantle_register_meta_default_args' )->once()->andReturn( [ diff --git a/tests/database/model/registration/test-register-post-type.php b/tests/Database/Model/registration/RegisterPostTypeTest.php similarity index 98% rename from tests/database/model/registration/test-register-post-type.php rename to tests/Database/Model/registration/RegisterPostTypeTest.php index 4a93f25cd..3864aa7e4 100644 --- a/tests/database/model/registration/test-register-post-type.php +++ b/tests/Database/Model/registration/RegisterPostTypeTest.php @@ -11,7 +11,7 @@ use Mantle\REST_API\Registered_REST_Field; use Mantle\Testing\Framework_Test_Case; -class Test_Register_Post_Type extends Framework_Test_Case { +class RegisterPostTypeTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); remove_all_actions( 'init' ); diff --git a/tests/database/model/registration/test-register-taxonomy.php b/tests/Database/Model/registration/RegisterTaxonomyTest.php similarity index 96% rename from tests/database/model/registration/test-register-taxonomy.php rename to tests/Database/Model/registration/RegisterTaxonomyTest.php index 29366ad6e..e053c028b 100644 --- a/tests/database/model/registration/test-register-taxonomy.php +++ b/tests/Database/Model/registration/RegisterTaxonomyTest.php @@ -6,7 +6,7 @@ use Mantle\Testing\Framework_Test_Case; use Mockery as m; -class Test_Register_Taxonomy extends Framework_Test_Case { +class RegisterTaxonomyTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); remove_all_actions( 'init' ); diff --git a/tests/database/model/relations/test-belongs-to-one-or-many.php b/tests/Database/Model/relations/BelongsToOneOrManyTest.php similarity index 98% rename from tests/database/model/relations/test-belongs-to-one-or-many.php rename to tests/Database/Model/relations/BelongsToOneOrManyTest.php index 8b96f5773..e58c866f5 100644 --- a/tests/database/model/relations/test-belongs-to-one-or-many.php +++ b/tests/Database/Model/relations/BelongsToOneOrManyTest.php @@ -11,7 +11,7 @@ use Mantle\Database\Model\Term; use Mantle\Database\Model_Service_Provider; -class Test_Belongs_To_One_Or_Many extends Framework_Test_Case { +class BelongsToOneOrManyTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); diff --git a/tests/database/model/relations/test-has-one-or-many.php b/tests/Database/Model/relations/HasOneOrManyTest.php similarity index 99% rename from tests/database/model/relations/test-has-one-or-many.php rename to tests/Database/Model/relations/HasOneOrManyTest.php index 223ad9a80..c8dd00548 100644 --- a/tests/database/model/relations/test-has-one-or-many.php +++ b/tests/Database/Model/relations/HasOneOrManyTest.php @@ -12,7 +12,7 @@ use Mantle\Testing\Framework_Test_Case; use Mantle\Testing\Utils; -class Test_Has_One_Or_Many extends Framework_Test_Case { +class HasOneOrManyTest extends Framework_Test_Case { use Refresh_Database; protected function setUp(): void { diff --git a/tests/database/query/test-eager-load-relationships.php b/tests/Database/Query/EagerLoadRelationshipsTest.php similarity index 99% rename from tests/database/query/test-eager-load-relationships.php rename to tests/Database/Query/EagerLoadRelationshipsTest.php index 52d52d8ab..9d458f566 100644 --- a/tests/database/query/test-eager-load-relationships.php +++ b/tests/Database/Query/EagerLoadRelationshipsTest.php @@ -9,7 +9,7 @@ use function Mantle\Support\Helpers\collect; -class Test_Eager_Load_Relationships extends Framework_Test_Case { +class EagerLoadRelationshipsTest extends Framework_Test_Case { use Refresh_Database; protected function setUp(): void { diff --git a/tests/database/query/test-paginator.php b/tests/Database/Query/PaginatorTest.php similarity index 99% rename from tests/database/query/test-paginator.php rename to tests/Database/Query/PaginatorTest.php index dcafc0f38..0f415c0f3 100644 --- a/tests/database/query/test-paginator.php +++ b/tests/Database/Query/PaginatorTest.php @@ -7,7 +7,7 @@ use Mantle\Testing\Framework_Test_Case; -class Test_Paginator extends Framework_Test_Case { +class PaginatorTest extends Framework_Test_Case { use Refresh_Database; public function test_simple_paginate_url_query_string() { diff --git a/tests/database/query/test-post-query-builder.php b/tests/Database/Query/PostQueryBuilderTest.php similarity index 99% rename from tests/database/query/test-post-query-builder.php rename to tests/Database/Query/PostQueryBuilderTest.php index 73c0ba32c..4e52448ca 100644 --- a/tests/database/query/test-post-query-builder.php +++ b/tests/Database/Query/PostQueryBuilderTest.php @@ -13,7 +13,7 @@ use function Mantle\Support\Helpers\collect; -class Test_Post_Query_Builder extends Framework_Test_Case { +class PostQueryBuilderTest extends Framework_Test_Case { use Refresh_Database; protected function setUp(): void { diff --git a/tests/database/query/test-post-query-relationships.php b/tests/Database/Query/PostQueryRelationshipsTest.php similarity index 97% rename from tests/database/query/test-post-query-relationships.php rename to tests/Database/Query/PostQueryRelationshipsTest.php index 6c91ed959..ffc156c44 100644 --- a/tests/database/query/test-post-query-relationships.php +++ b/tests/Database/Query/PostQueryRelationshipsTest.php @@ -9,7 +9,7 @@ use Mantle\Testing\Framework_Test_Case; use Mantle\Testing\Utils; -class Test_Post_Query_Relationships extends Framework_Test_Case { +class PostQueryRelationshipsTest extends Framework_Test_Case { protected function setUp(): void { Utils::delete_all_posts(); parent::setUp(); diff --git a/tests/database/query/test-term-query-builder.php b/tests/Database/Query/TermQueryBuilderTest.php similarity index 98% rename from tests/database/query/test-term-query-builder.php rename to tests/Database/Query/TermQueryBuilderTest.php index 5dbcf0e61..406f2df09 100644 --- a/tests/database/query/test-term-query-builder.php +++ b/tests/Database/Query/TermQueryBuilderTest.php @@ -7,7 +7,7 @@ use function Mantle\Support\Helpers\collect; -class Test_Term_Query_Builder extends Framework_Test_Case { +class TermQueryBuilderTest extends Framework_Test_Case { public function test_term_by_name() { $tag_id = $this->get_random_term_id(); $tag = \get_term( $tag_id ); diff --git a/tests/events/test-event-dispatcher.php b/tests/Events/EventDispatcherTest.php similarity index 97% rename from tests/events/test-event-dispatcher.php rename to tests/Events/EventDispatcherTest.php index 3133fd54e..de5a9077a 100644 --- a/tests/events/test-event-dispatcher.php +++ b/tests/Events/EventDispatcherTest.php @@ -8,7 +8,7 @@ /** * @group events */ -class Test_Event_Dispatcher extends \Mockery\Adapter\Phpunit\MockeryTestCase { +class EventDispatcherTest extends \Mockery\Adapter\Phpunit\MockeryTestCase { public function testBasicEventExecution() { unset( $_SERVER['__event.test'] ); $d = new Dispatcher(); diff --git a/tests/events/test-wordpress-action-dispatcher.php b/tests/Events/WordPressActionDispatcherTest.php similarity index 98% rename from tests/events/test-wordpress-action-dispatcher.php rename to tests/Events/WordPressActionDispatcherTest.php index 297e0ceaf..b23ea0709 100644 --- a/tests/events/test-wordpress-action-dispatcher.php +++ b/tests/Events/WordPressActionDispatcherTest.php @@ -12,7 +12,7 @@ /** * @group events */ -class Test_WordPress_Action_Dispatcher extends Framework_Test_Case { +class WordPressActionDispatcherTest extends Framework_Test_Case { public function test_action_handler() { $_SERVER['__action_fired'] = false; diff --git a/tests/test-faker.php b/tests/FakerTest.php similarity index 96% rename from tests/test-faker.php rename to tests/FakerTest.php index daf2cf2f8..ce37c6054 100644 --- a/tests/test-faker.php +++ b/tests/FakerTest.php @@ -4,7 +4,7 @@ use Faker\Factory; use Mantle\Faker\Faker_Provider; -class Test_Faker extends \PHPUnit\Framework\TestCase { +class FakerTest extends \PHPUnit\Framework\TestCase { /** * @var Factory */ diff --git a/tests/filesystem/test-filesystem-adapter.php b/tests/Filesystem/FilesystemAdapterTest.php similarity index 98% rename from tests/filesystem/test-filesystem-adapter.php rename to tests/Filesystem/FilesystemAdapterTest.php index 45b123379..a790fc65f 100644 --- a/tests/filesystem/test-filesystem-adapter.php +++ b/tests/Filesystem/FilesystemAdapterTest.php @@ -15,7 +15,7 @@ use Mockery as m; use Symfony\Component\HttpFoundation\StreamedResponse; -class Test_Filesystem_Adapter extends TestCase { +class FilesystemAdapterTest extends TestCase { private $temp_dir; /** @@ -137,7 +137,7 @@ public function testDelete() { file_put_contents( $this->temp_dir . '/file.txt', 'Hello World' ); $Filesystem_Adapter = new Filesystem_Adapter( $this->filesystem ); $this->assertTrue( $Filesystem_Adapter->delete( 'file.txt' ) ); - Assert::assertFileDoesNotExist( $this->temp_dir . '/file.txt' ); + $this->assertFileDoesNotExist( $this->temp_dir . '/file.txt' ); } public function testDeleteReturnsFalseWhenFileNotFound() { @@ -168,7 +168,7 @@ public function testMove() { $Filesystem_Adapter = new Filesystem_Adapter( $this->filesystem ); $Filesystem_Adapter->move( '/foo/foo.txt', '/foo/foo2.txt' ); - Assert::assertFileDoesNotExist( $this->temp_dir . '/foo/foo.txt' ); + $this->assertFileDoesNotExist( $this->temp_dir . '/foo/foo.txt' ); $this->assertFileExists( $this->temp_dir . '/foo/foo2.txt' ); $this->assertEquals( $data, file_get_contents( $this->temp_dir . '/foo/foo2.txt' ) ); diff --git a/tests/filesystem/test-filesystem-manager.php b/tests/Filesystem/FilesystemManagerTest.php similarity index 97% rename from tests/filesystem/test-filesystem-manager.php rename to tests/Filesystem/FilesystemManagerTest.php index 1ef4988f9..0eef4382f 100644 --- a/tests/filesystem/test-filesystem-manager.php +++ b/tests/Filesystem/FilesystemManagerTest.php @@ -10,7 +10,7 @@ use Mantle\Contracts\Filesystem\Filesystem as Filesystem_Contract; use function Mantle\Support\Helpers\tap; -class Test_Filesystem_Manager extends TestCase { +class FilesystemManagerTest extends TestCase { public function test_invalid_disk() { $this->expectException( InvalidArgumentException::class ); $this->expectExceptionMessage( 'Disk [unsupported] does not have a configured driver.' ); diff --git a/tests/filesystem/test-filesystem.php b/tests/Filesystem/FilesystemTest.php similarity index 67% rename from tests/filesystem/test-filesystem.php rename to tests/Filesystem/FilesystemTest.php index b97a83261..e54cb081c 100644 --- a/tests/filesystem/test-filesystem.php +++ b/tests/Filesystem/FilesystemTest.php @@ -9,7 +9,7 @@ use SplFileInfo; use League\Flysystem\FileNotFoundException; -class Test_Filesystem extends TestCase { +class FilesystemTest extends TestCase { private static $temp_dir; @@ -43,13 +43,13 @@ protected function tearDown(): void { public function testGetRetrievesFiles() { file_put_contents( static::$temp_dir . '/file.txt', 'Hello World' ); $files = new Filesystem(); - Assert::assertSame( 'Hello World', $files->get( static::$temp_dir . '/file.txt' ) ); + $this->assertSame( 'Hello World', $files->get( static::$temp_dir . '/file.txt' ) ); } public function testPutStoresFiles() { $files = new Filesystem(); $files->put( static::$temp_dir . '/file.txt', 'Hello World' ); - Assert::assertStringEqualsFile( static::$temp_dir . '/file.txt', 'Hello World' ); + $this->assertStringEqualsFile( static::$temp_dir . '/file.txt', 'Hello World' ); } public function testReplaceCreatesFile() { @@ -58,7 +58,7 @@ public function testReplaceCreatesFile() { $filesystem = new Filesystem(); $filesystem->replace( $tempFile, 'Hello World' ); - Assert::assertStringEqualsFile( $tempFile, 'Hello World' ); + $this->assertStringEqualsFile( $tempFile, 'Hello World' ); } public function testReplaceWhenUnixSymlinkExists() { @@ -80,18 +80,18 @@ public function testReplaceWhenUnixSymlinkExists() { // Test replacing non-existent file. $filesystem->replace( $tempFile, 'Hello World' ); - Assert::assertStringEqualsFile( $tempFile, 'Hello World' ); - Assert::assertEquals( $umask, 0777 - $this->get_file_permissions( $tempFile ) ); + $this->assertStringEqualsFile( $tempFile, 'Hello World' ); + $this->assertEquals( $umask, 0777 - $this->get_file_permissions( $tempFile ) ); // Test replacing existing file. $filesystem->replace( $tempFile, 'Something Else' ); - Assert::assertStringEqualsFile( $tempFile, 'Something Else' ); - Assert::assertEquals( $umask, 0777 - $this->get_file_permissions( $tempFile ) ); + $this->assertStringEqualsFile( $tempFile, 'Something Else' ); + $this->assertEquals( $umask, 0777 - $this->get_file_permissions( $tempFile ) ); // Test replacing symlinked file. $filesystem->replace( $symlink, 'Yet Something Else Again' ); - Assert::assertStringEqualsFile( $tempFile, 'Yet Something Else Again' ); - Assert::assertEquals( $umask, 0777 - $this->get_file_permissions( $tempFile ) ); + $this->assertStringEqualsFile( $tempFile, 'Yet Something Else Again' ); + $this->assertEquals( $umask, 0777 - $this->get_file_permissions( $tempFile ) ); umask( $originalUmask ); @@ -105,7 +105,7 @@ public function testSetChmod() { $files->chmod( static::$temp_dir . '/file.txt', 0755 ); $filePermission = substr( sprintf( '%o', fileperms( static::$temp_dir . '/file.txt' ) ), -4 ); $expectedPermissions = DIRECTORY_SEPARATOR == '\\' ? '0666' : '0755'; - Assert::assertEquals( $expectedPermissions, $filePermission ); + $this->assertEquals( $expectedPermissions, $filePermission ); } public function testGetChmod() { @@ -115,7 +115,7 @@ public function testGetChmod() { $files = new Filesystem(); $filePermission = $files->chmod( static::$temp_dir . '/file.txt' ); $expectedPermissions = DIRECTORY_SEPARATOR == '\\' ? '0666' : '0755'; - Assert::assertEquals( $expectedPermissions, $filePermission ); + $this->assertEquals( $expectedPermissions, $filePermission ); } public function testDeleteRemovesFiles() { @@ -125,29 +125,29 @@ public function testDeleteRemovesFiles() { $files = new Filesystem(); $files->delete( static::$temp_dir . '/file1.txt' ); - Assert::assertFileDoesNotExist( static::$temp_dir . '/file1.txt' ); + $this->assertFileDoesNotExist( static::$temp_dir . '/file1.txt' ); $files->delete( [ static::$temp_dir . '/file2.txt', static::$temp_dir . '/file3.txt' ] ); - Assert::assertFileDoesNotExist( static::$temp_dir . '/file2.txt' ); - Assert::assertFileDoesNotExist( static::$temp_dir . '/file3.txt' ); + $this->assertFileDoesNotExist( static::$temp_dir . '/file2.txt' ); + $this->assertFileDoesNotExist( static::$temp_dir . '/file3.txt' ); } public function testPrependExistingFiles() { $files = new Filesystem(); $files->put( static::$temp_dir . '/file.txt', 'World' ); $files->prepend( static::$temp_dir . '/file.txt', 'Hello ' ); - Assert::assertStringEqualsFile( static::$temp_dir . '/file.txt', 'Hello World' ); + $this->assertStringEqualsFile( static::$temp_dir . '/file.txt', 'Hello World' ); } public function testPrependNewFiles() { $files = new Filesystem(); $files->prepend( static::$temp_dir . '/file.txt', 'Hello World' ); - Assert::assertStringEqualsFile( static::$temp_dir . '/file.txt', 'Hello World' ); + $this->assertStringEqualsFile( static::$temp_dir . '/file.txt', 'Hello World' ); } public function testMissingFile() { $files = new Filesystem(); - Assert::assertTrue( $files->missing( static::$temp_dir . '/file.txt' ) ); + $this->assertTrue( $files->missing( static::$temp_dir . '/file.txt' ) ); } public function testDeleteDirectory() { @@ -155,15 +155,15 @@ public function testDeleteDirectory() { file_put_contents( static::$temp_dir . '/foo/file.txt', 'Hello World' ); $files = new Filesystem(); $files->delete_directory( static::$temp_dir . '/foo' ); - Assert::assertDirectoryDoesNotExist( static::$temp_dir . '/foo' ); - Assert::assertFileDoesNotExist( static::$temp_dir . '/foo/file.txt' ); + $this->assertDirectoryDoesNotExist( static::$temp_dir . '/foo' ); + $this->assertFileDoesNotExist( static::$temp_dir . '/foo/file.txt' ); } public function testDeleteDirectoryReturnFalseWhenNotADirectory() { mkdir( static::$temp_dir . '/bar' ); file_put_contents( static::$temp_dir . '/bar/file.txt', 'Hello World' ); $files = new Filesystem(); - Assert::assertFalse( $files->delete_directory( static::$temp_dir . '/bar/file.txt' ) ); + $this->assertFalse( $files->delete_directory( static::$temp_dir . '/bar/file.txt' ) ); } public function testCleanDirectory() { @@ -171,8 +171,8 @@ public function testCleanDirectory() { file_put_contents( static::$temp_dir . '/baz/file.txt', 'Hello World' ); $files = new Filesystem(); $files->clean_directory( static::$temp_dir . '/baz' ); - Assert::assertDirectoryExists( static::$temp_dir . '/baz' ); - Assert::assertFileDoesNotExist( static::$temp_dir . '/baz/file.txt' ); + $this->assertDirectoryExists( static::$temp_dir . '/baz' ); + $this->assertFileDoesNotExist( static::$temp_dir . '/baz/file.txt' ); } public function testMacro() { @@ -185,7 +185,7 @@ function () use ( $files, $temp_dir ) { return $files->get( $temp_dir . '/foo.txt' ); } ); - Assert::assertSame( 'Hello World', $files->getFoo() ); + $this->assertSame( 'Hello World', $files->getFoo() ); } public function testFilesMethod() { @@ -195,14 +195,14 @@ public function testFilesMethod() { mkdir( static::$temp_dir . '/views/_layouts' ); $files = new Filesystem(); $results = $files->files( static::$temp_dir . '/views' ); - Assert::assertInstanceOf( SplFileInfo::class, $results[0] ); - Assert::assertInstanceOf( SplFileInfo::class, $results[1] ); + $this->assertInstanceOf( SplFileInfo::class, $results[0] ); + $this->assertInstanceOf( SplFileInfo::class, $results[1] ); unset( $files ); } public function testCopyDirectoryReturnsFalseIfSourceIsntDirectory() { $files = new Filesystem(); - Assert::assertFalse( $files->copy_directory( static::$temp_dir . '/breeze/boom/foo/bar/baz', static::$temp_dir ) ); + $this->assertFalse( $files->copy_directory( static::$temp_dir . '/breeze/boom/foo/bar/baz', static::$temp_dir ) ); } public function testCopyDirectoryMovesEntireDirectory() { @@ -214,11 +214,11 @@ public function testCopyDirectoryMovesEntireDirectory() { $files = new Filesystem(); $files->copy_directory( static::$temp_dir . '/tmp', static::$temp_dir . '/tmp2' ); - Assert::assertDirectoryExists( static::$temp_dir . '/tmp2' ); - Assert::assertFileExists( static::$temp_dir . '/tmp2/foo.txt' ); - Assert::assertFileExists( static::$temp_dir . '/tmp2/bar.txt' ); - Assert::assertDirectoryExists( static::$temp_dir . '/tmp2/nested' ); - Assert::assertFileExists( static::$temp_dir . '/tmp2/nested/baz.txt' ); + $this->assertDirectoryExists( static::$temp_dir . '/tmp2' ); + $this->assertFileExists( static::$temp_dir . '/tmp2/foo.txt' ); + $this->assertFileExists( static::$temp_dir . '/tmp2/bar.txt' ); + $this->assertDirectoryExists( static::$temp_dir . '/tmp2/nested' ); + $this->assertFileExists( static::$temp_dir . '/tmp2/nested/baz.txt' ); } public function testMoveDirectoryMovesEntireDirectory() { @@ -230,12 +230,12 @@ public function testMoveDirectoryMovesEntireDirectory() { $files = new Filesystem(); $files->move_directory( static::$temp_dir . '/tmp2', static::$temp_dir . '/tmp3' ); - Assert::assertDirectoryExists( static::$temp_dir . '/tmp3' ); - Assert::assertFileExists( static::$temp_dir . '/tmp3/foo.txt' ); - Assert::assertFileExists( static::$temp_dir . '/tmp3/bar.txt' ); - Assert::assertDirectoryExists( static::$temp_dir . '/tmp3/nested' ); - Assert::assertFileExists( static::$temp_dir . '/tmp3/nested/baz.txt' ); - Assert::assertDirectoryDoesNotExist( static::$temp_dir . '/tmp2' ); + $this->assertDirectoryExists( static::$temp_dir . '/tmp3' ); + $this->assertFileExists( static::$temp_dir . '/tmp3/foo.txt' ); + $this->assertFileExists( static::$temp_dir . '/tmp3/bar.txt' ); + $this->assertDirectoryExists( static::$temp_dir . '/tmp3/nested' ); + $this->assertFileExists( static::$temp_dir . '/tmp3/nested/baz.txt' ); + $this->assertDirectoryDoesNotExist( static::$temp_dir . '/tmp2' ); } public function testMoveDirectoryMovesEntireDirectoryAndOverwrites() { @@ -250,14 +250,14 @@ public function testMoveDirectoryMovesEntireDirectoryAndOverwrites() { $files = new Filesystem(); $files->move_directory( static::$temp_dir . '/tmp4', static::$temp_dir . '/tmp5', true ); - Assert::assertDirectoryExists( static::$temp_dir . '/tmp5' ); - Assert::assertFileExists( static::$temp_dir . '/tmp5/foo.txt' ); - Assert::assertFileExists( static::$temp_dir . '/tmp5/bar.txt' ); - Assert::assertDirectoryExists( static::$temp_dir . '/tmp5/nested' ); - Assert::assertFileExists( static::$temp_dir . '/tmp5/nested/baz.txt' ); - Assert::assertFileDoesNotExist( static::$temp_dir . '/tmp5/foo2.txt' ); - Assert::assertFileDoesNotExist( static::$temp_dir . '/tmp5/bar2.txt' ); - Assert::assertDirectoryDoesNotExist( static::$temp_dir . '/tmp4' ); + $this->assertDirectoryExists( static::$temp_dir . '/tmp5' ); + $this->assertFileExists( static::$temp_dir . '/tmp5/foo.txt' ); + $this->assertFileExists( static::$temp_dir . '/tmp5/bar.txt' ); + $this->assertDirectoryExists( static::$temp_dir . '/tmp5/nested' ); + $this->assertFileExists( static::$temp_dir . '/tmp5/nested/baz.txt' ); + $this->assertFileDoesNotExist( static::$temp_dir . '/tmp5/foo2.txt' ); + $this->assertFileDoesNotExist( static::$temp_dir . '/tmp5/bar2.txt' ); + $this->assertDirectoryDoesNotExist( static::$temp_dir . '/tmp4' ); } public function testMoveDirectoryReturnsFalseWhileOverwritingAndUnableToDeleteDestinationDirectory() { @@ -267,7 +267,7 @@ public function testMoveDirectoryReturnsFalseWhileOverwritingAndUnableToDeleteDe $files = m::mock( Filesystem::class )->makePartial(); $files->shouldReceive( 'delete_directory' )->once()->andReturn( false ); - Assert::assertFalse( $files->move_directory( static::$temp_dir . '/tmp6', static::$temp_dir . '/tmp7', true ) ); + $this->assertFalse( $files->move_directory( static::$temp_dir . '/tmp6', static::$temp_dir . '/tmp7', true ) ); } public function testGetThrowsExceptionNonexisitingFile() { @@ -280,7 +280,7 @@ public function testGetThrowsExceptionNonexisitingFile() { public function testGetRequireReturnsProperly() { file_put_contents( static::$temp_dir . '/file.php', '' ); $files = new Filesystem(); - Assert::assertSame( 'Howdy?', $files->get_require( static::$temp_dir . '/file.php' ) ); + $this->assertSame( 'Howdy?', $files->get_require( static::$temp_dir . '/file.php' ) ); } public function testGetRequireThrowsExceptionNonExistingFile() { @@ -294,59 +294,59 @@ public function testAppendAddsDataToFile() { file_put_contents( static::$temp_dir . '/file.txt', 'foo' ); $files = new Filesystem(); $bytesWritten = $files->append( static::$temp_dir . '/file.txt', 'bar' ); - Assert::assertEquals( mb_strlen( 'bar', '8bit' ), $bytesWritten ); - Assert::assertFileExists( static::$temp_dir . '/file.txt' ); - Assert::assertStringEqualsFile( static::$temp_dir . '/file.txt', 'foobar' ); + $this->assertEquals( mb_strlen( 'bar', '8bit' ), $bytesWritten ); + $this->assertFileExists( static::$temp_dir . '/file.txt' ); + $this->assertStringEqualsFile( static::$temp_dir . '/file.txt', 'foobar' ); } public function testMoveMovesFiles() { file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); $files = new Filesystem(); $files->move( static::$temp_dir . '/foo.txt', static::$temp_dir . '/bar.txt' ); - Assert::assertFileExists( static::$temp_dir . '/bar.txt' ); - Assert::assertFileDoesNotExist( static::$temp_dir . '/foo.txt' ); + $this->assertFileExists( static::$temp_dir . '/bar.txt' ); + $this->assertFileDoesNotExist( static::$temp_dir . '/foo.txt' ); } public function testNameReturnsName() { file_put_contents( static::$temp_dir . '/foobar.txt', 'foo' ); $filesystem = new Filesystem(); - Assert::assertSame( 'foobar', $filesystem->name( static::$temp_dir . '/foobar.txt' ) ); + $this->assertSame( 'foobar', $filesystem->name( static::$temp_dir . '/foobar.txt' ) ); } public function testExtensionReturnsExtension() { file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); $files = new Filesystem(); - Assert::assertSame( 'txt', $files->extension( static::$temp_dir . '/foo.txt' ) ); + $this->assertSame( 'txt', $files->extension( static::$temp_dir . '/foo.txt' ) ); } public function testBasenameReturnsBasename() { file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); $files = new Filesystem(); - Assert::assertSame( 'foo.txt', $files->basename( static::$temp_dir . '/foo.txt' ) ); + $this->assertSame( 'foo.txt', $files->basename( static::$temp_dir . '/foo.txt' ) ); } public function testDirnameReturnsDirectory() { file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); $files = new Filesystem(); - Assert::assertEquals( static::$temp_dir, $files->dirname( static::$temp_dir . '/foo.txt' ) ); + $this->assertEquals( static::$temp_dir, $files->dirname( static::$temp_dir . '/foo.txt' ) ); } public function testTypeIdentifiesFile() { file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); $files = new Filesystem(); - Assert::assertSame( 'file', $files->type( static::$temp_dir . '/foo.txt' ) ); + $this->assertSame( 'file', $files->type( static::$temp_dir . '/foo.txt' ) ); } public function testTypeIdentifiesDirectory() { mkdir( static::$temp_dir . '/foo-dir' ); $files = new Filesystem(); - Assert::assertSame( 'dir', $files->type( static::$temp_dir . '/foo-dir' ) ); + $this->assertSame( 'dir', $files->type( static::$temp_dir . '/foo-dir' ) ); } public function testSizeOutputsSize() { $size = file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); $files = new Filesystem(); - Assert::assertEquals( $size, $files->size( static::$temp_dir . '/foo.txt' ) ); + $this->assertEquals( $size, $files->size( static::$temp_dir . '/foo.txt' ) ); } /** @@ -355,16 +355,16 @@ public function testSizeOutputsSize() { public function testMimeTypeOutputsMimeType() { file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); $files = new Filesystem(); - Assert::assertSame( 'text/plain', $files->mime_type( static::$temp_dir . '/foo.txt' ) ); + $this->assertSame( 'text/plain', $files->mime_type( static::$temp_dir . '/foo.txt' ) ); } public function testIsWritable() { file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); $files = new Filesystem(); @chmod( static::$temp_dir . '/foo.txt', 0444 ); - Assert::assertFalse( $files->is_writable( static::$temp_dir . '/foo.txt' ) ); + $this->assertFalse( $files->is_writable( static::$temp_dir . '/foo.txt' ) ); @chmod( static::$temp_dir . '/foo.txt', 0777 ); - Assert::assertTrue( $files->is_writable( static::$temp_dir . '/foo.txt' ) ); + $this->assertTrue( $files->is_writable( static::$temp_dir . '/foo.txt' ) ); } public function testIsReadable() { @@ -372,14 +372,14 @@ public function testIsReadable() { $files = new Filesystem(); // chmod is noneffective on Windows if ( DIRECTORY_SEPARATOR === '\\' ) { - Assert::assertTrue( $files->is_readable( static::$temp_dir . '/foo.txt' ) ); + $this->assertTrue( $files->is_readable( static::$temp_dir . '/foo.txt' ) ); } else { @chmod( static::$temp_dir . '/foo.txt', 0000 ); - Assert::assertFalse( $files->is_readable( static::$temp_dir . '/foo.txt' ) ); + $this->assertFalse( $files->is_readable( static::$temp_dir . '/foo.txt' ) ); @chmod( static::$temp_dir . '/foo.txt', 0777 ); - Assert::assertTrue( $files->is_readable( static::$temp_dir . '/foo.txt' ) ); + $this->assertTrue( $files->is_readable( static::$temp_dir . '/foo.txt' ) ); } - Assert::assertFalse( $files->is_readable( static::$temp_dir . '/doesnotexist.txt' ) ); + $this->assertFalse( $files->is_readable( static::$temp_dir . '/doesnotexist.txt' ) ); } public function testGlobFindsFiles() { @@ -387,8 +387,8 @@ public function testGlobFindsFiles() { file_put_contents( static::$temp_dir . '/bar.txt', 'bar' ); $files = new Filesystem(); $glob = $files->glob( static::$temp_dir . '/*.txt' ); - Assert::assertContains( static::$temp_dir . '/foo.txt', $glob ); - Assert::assertContains( static::$temp_dir . '/bar.txt', $glob ); + $this->assertContains( static::$temp_dir . '/foo.txt', $glob ); + $this->assertContains( static::$temp_dir . '/bar.txt', $glob ); } public function testAllFilesFindsFiles() { @@ -399,8 +399,8 @@ public function testAllFilesFindsFiles() { foreach ( $files->all_files( static::$temp_dir ) as $file ) { $allFiles[] = $file->getFilename(); } - Assert::assertContains( 'foo.txt', $allFiles ); - Assert::assertContains( 'bar.txt', $allFiles ); + $this->assertContains( 'foo.txt', $allFiles ); + $this->assertContains( 'bar.txt', $allFiles ); } public function testDirectoriesFindsDirectories() { @@ -408,14 +408,14 @@ public function testDirectoriesFindsDirectories() { mkdir( static::$temp_dir . '/music' ); $files = new Filesystem(); $directories = $files->directories( static::$temp_dir ); - Assert::assertContains( static::$temp_dir . DIRECTORY_SEPARATOR . 'film', $directories ); - Assert::assertContains( static::$temp_dir . DIRECTORY_SEPARATOR . 'music', $directories ); + $this->assertContains( static::$temp_dir . DIRECTORY_SEPARATOR . 'film', $directories ); + $this->assertContains( static::$temp_dir . DIRECTORY_SEPARATOR . 'music', $directories ); } public function testMakeDirectory() { $files = new Filesystem(); - Assert::assertTrue( $files->make_directory( static::$temp_dir . '/created' ) ); - Assert::assertFileExists( static::$temp_dir . '/created' ); + $this->assertTrue( $files->make_directory( static::$temp_dir . '/created' ) ); + $this->assertFileExists( static::$temp_dir . '/created' ); } public function testRequireOnceRequiresFileProperly() { @@ -425,8 +425,8 @@ public function testRequireOnceRequiresFileProperly() { $filesystem->require_once( static::$temp_dir . '/scripts/foo.php' ); file_put_contents( static::$temp_dir . '/scripts/foo.php', 'require_once( static::$temp_dir . '/scripts/foo.php' ); - Assert::assertTrue( function_exists( 'random_function_xyz' ) ); - Assert::assertFalse( function_exists( 'random_function_xyz_changed' ) ); + $this->assertTrue( function_exists( 'random_function_xyz' ) ); + $this->assertFalse( function_exists( 'random_function_xyz_changed' ) ); } public function testCopyCopiesFileProperly() { @@ -435,16 +435,16 @@ public function testCopyCopiesFileProperly() { mkdir( static::$temp_dir . '/text' ); file_put_contents( static::$temp_dir . '/text/foo.txt', $data ); $filesystem->copy( static::$temp_dir . '/text/foo.txt', static::$temp_dir . '/text/foo2.txt' ); - Assert::assertFileExists( static::$temp_dir . '/text/foo2.txt' ); - Assert::assertEquals( $data, file_get_contents( static::$temp_dir . '/text/foo2.txt' ) ); + $this->assertFileExists( static::$temp_dir . '/text/foo2.txt' ); + $this->assertEquals( $data, file_get_contents( static::$temp_dir . '/text/foo2.txt' ) ); } public function testIsFileChecksFilesProperly() { $filesystem = new Filesystem(); mkdir( static::$temp_dir . '/help' ); file_put_contents( static::$temp_dir . '/help/foo.txt', 'contents' ); - Assert::assertTrue( $filesystem->is_file( static::$temp_dir . '/help/foo.txt' ) ); - Assert::assertFalse( $filesystem->is_file( static::$temp_dir . './help' ) ); + $this->assertTrue( $filesystem->is_file( static::$temp_dir . '/help/foo.txt' ) ); + $this->assertFalse( $filesystem->is_file( static::$temp_dir . './help' ) ); } public function testFilesMethodReturnsFileInfoObjects() { @@ -453,7 +453,7 @@ public function testFilesMethodReturnsFileInfoObjects() { file_put_contents( static::$temp_dir . '/objects/2.txt', '2' ); mkdir( static::$temp_dir . '/objects/bar' ); $files = new Filesystem(); - Assert::assertContainsOnlyInstancesOf( SplFileInfo::class, $files->files( static::$temp_dir . '/objects' ) ); + $this->assertContainsOnlyInstancesOf( SplFileInfo::class, $files->files( static::$temp_dir . '/objects' ) ); unset( $files ); } @@ -461,13 +461,13 @@ public function testAllFilesReturnsFileInfoObjects() { file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); file_put_contents( static::$temp_dir . '/bar.txt', 'bar' ); $files = new Filesystem(); - Assert::assertContainsOnlyInstancesOf( SplFileInfo::class, $files->all_files( static::$temp_dir ) ); + $this->assertContainsOnlyInstancesOf( SplFileInfo::class, $files->all_files( static::$temp_dir ) ); } public function testHash() { file_put_contents( static::$temp_dir . '/foo.txt', 'foo' ); $filesystem = new Filesystem(); - Assert::assertSame( 'acbd18db4cc2f85cedef654fccc4a4d8', $filesystem->hash( static::$temp_dir . '/foo.txt' ) ); + $this->assertSame( 'acbd18db4cc2f85cedef654fccc4a4d8', $filesystem->hash( static::$temp_dir . '/foo.txt' ) ); } public function test_guess_class_name() { diff --git a/tests/framework/test-alias-loader.php b/tests/Framework/AliasLoaderTest.php similarity index 97% rename from tests/framework/test-alias-loader.php rename to tests/Framework/AliasLoaderTest.php index f2c0596a2..c108cb3c8 100644 --- a/tests/framework/test-alias-loader.php +++ b/tests/Framework/AliasLoaderTest.php @@ -5,7 +5,7 @@ use Mantle\Framework\Alias_Loader; use PHPUnit\Framework\TestCase; -class Test_Alias_Loader extends TestCase { +class AliasLoaderTest extends TestCase { protected function setUp(): void { parent::setUp(); diff --git a/tests/framework/test-application.php b/tests/Framework/ApplicationTest.php similarity index 98% rename from tests/framework/test-application.php rename to tests/Framework/ApplicationTest.php index b8f8c764b..2a2260efb 100644 --- a/tests/framework/test-application.php +++ b/tests/Framework/ApplicationTest.php @@ -7,7 +7,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -class Test_Application extends \Mockery\Adapter\Phpunit\MockeryTestCase { +class ApplicationTest extends \Mockery\Adapter\Phpunit\MockeryTestCase { protected function tearDown(): void { parent::tearDown(); diff --git a/tests/framework/test-bootloader.php b/tests/Framework/BootloaderTest.php similarity index 98% rename from tests/framework/test-bootloader.php rename to tests/Framework/BootloaderTest.php index c860405ad..7855df923 100644 --- a/tests/framework/test-bootloader.php +++ b/tests/Framework/BootloaderTest.php @@ -9,7 +9,7 @@ use Mantle\Testing\Concerns\Interacts_With_Hooks; use PHPUnit\Framework\TestCase; -class Test_Bootloader extends TestCase { +class BootloaderTest extends TestCase { use Interacts_With_Hooks; public function setUp(): void { diff --git a/tests/framework/events/test-discover-events.php b/tests/Framework/Events/DiscoverEventsTest.php similarity index 88% rename from tests/framework/events/test-discover-events.php rename to tests/Framework/Events/DiscoverEventsTest.php index 5b4779631..f98e1f1fc 100644 --- a/tests/framework/events/test-discover-events.php +++ b/tests/Framework/Events/DiscoverEventsTest.php @@ -10,13 +10,17 @@ use function Mantle\Support\Helpers\collect; -class Test_Discover_Events extends Framework_Test_Case { +class DiscoverEventsTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); // Mock a true Mantle application. $this->app['config']->set( 'app.namespace', 'Mantle\\Tests' ); $this->app->set_app_path( dirname( __DIR__, 2 ) ); + + require_once __DIR__ . '/fixtures/listeners/class-example-listener.php'; + require_once __DIR__ . '/fixtures/events/class-event-one.php'; + require_once __DIR__ . '/fixtures/events/class-event-two.php'; } protected function tearDown(): void { diff --git a/tests/framework/events/fixtures/events/class-event-one.php b/tests/Framework/Events/fixtures/events/class-event-one.php similarity index 100% rename from tests/framework/events/fixtures/events/class-event-one.php rename to tests/Framework/Events/fixtures/events/class-event-one.php diff --git a/tests/framework/events/fixtures/events/class-event-two.php b/tests/Framework/Events/fixtures/events/class-event-two.php similarity index 100% rename from tests/framework/events/fixtures/events/class-event-two.php rename to tests/Framework/Events/fixtures/events/class-event-two.php diff --git a/tests/framework/events/fixtures/listeners/class-example-listener.php b/tests/Framework/Events/fixtures/listeners/class-example-listener.php similarity index 100% rename from tests/framework/events/fixtures/listeners/class-example-listener.php rename to tests/Framework/Events/fixtures/listeners/class-example-listener.php diff --git a/tests/framework/helpers/test-nullable-comment-objects-test-case.php b/tests/Framework/Helpers/NullableCommentObjectsTestCaseTest.php similarity index 93% rename from tests/framework/helpers/test-nullable-comment-objects-test-case.php rename to tests/Framework/Helpers/NullableCommentObjectsTestCaseTest.php index df7990672..da959488b 100644 --- a/tests/framework/helpers/test-nullable-comment-objects-test-case.php +++ b/tests/Framework/Helpers/NullableCommentObjectsTestCaseTest.php @@ -14,7 +14,7 @@ /** * Unit tests for nullable comment object functions. */ -class Nullable_Comment_Objects_Test_Case extends Framework_Test_Case { +class NullableCommentObjectsTestCaseTest extends Framework_Test_Case { /** * Test that `get_comment_object()` returns a comment object. */ diff --git a/tests/framework/helpers/test-nullable-post-objects-test-case.php b/tests/Framework/Helpers/NullablePostObjectsTestCaseTest.php similarity index 95% rename from tests/framework/helpers/test-nullable-post-objects-test-case.php rename to tests/Framework/Helpers/NullablePostObjectsTestCaseTest.php index f96a70981..c8178fc77 100644 --- a/tests/framework/helpers/test-nullable-post-objects-test-case.php +++ b/tests/Framework/Helpers/NullablePostObjectsTestCaseTest.php @@ -13,7 +13,7 @@ /** * Unit tests for nullable post object functions. */ -class Nullable_Post_Objects_Test_Case extends Framework_Test_Case { +class NullablePostObjectsTestCaseTest extends Framework_Test_Case { /** * Test that `get_post_object()` returns a post object. */ diff --git a/tests/Framework/Helpers/NullableSiteObjectsTestCaseTest.php b/tests/Framework/Helpers/NullableSiteObjectsTestCaseTest.php new file mode 100644 index 000000000..ae2e52513 --- /dev/null +++ b/tests/Framework/Helpers/NullableSiteObjectsTestCaseTest.php @@ -0,0 +1,46 @@ +markTestSkipped( 'Multisite is not enabled.' ); + } + } + + /** + * Test that `get_site_object()` returns a site object. + */ + public function test_site_object_returns_site() { + $known_id = self::factory()->blog->create(); + + $found_object = get_site_object( $known_id ); + + $this->assertInstanceOf( \WP_Site::class, $found_object ); + + $this->assertSame( $known_id, (int) $found_object->blog_id ); + } + + /** + * Test that `get_site_object()` returns null when there is no site. + */ + public function test_site_object_returns_null() { + $found_object = get_site_object( -99 ); + + $this->assertNull( $found_object ); + } +} diff --git a/tests/framework/helpers/test-nullable-term-objects-test-case.php b/tests/Framework/Helpers/NullableTermObjectsTestCaseTest.php similarity index 98% rename from tests/framework/helpers/test-nullable-term-objects-test-case.php rename to tests/Framework/Helpers/NullableTermObjectsTestCaseTest.php index 1e7c0493b..f1834776a 100644 --- a/tests/framework/helpers/test-nullable-term-objects-test-case.php +++ b/tests/Framework/Helpers/NullableTermObjectsTestCaseTest.php @@ -14,7 +14,7 @@ /** * Unit tests for nullable term object functions. */ -class Nullable_Term_Objects_Test_Case extends Framework_Test_Case { +class NullableTermObjectsTestCaseTest extends Framework_Test_Case { /** * Test that `get_term_object()` returns a term object. */ diff --git a/tests/framework/helpers/test-nullable-user-objects-test-case.php b/tests/Framework/Helpers/NullableUserObjectsTestCaseTest.php similarity index 95% rename from tests/framework/helpers/test-nullable-user-objects-test-case.php rename to tests/Framework/Helpers/NullableUserObjectsTestCaseTest.php index 49447ab06..6ecaeb4b4 100644 --- a/tests/framework/helpers/test-nullable-user-objects-test-case.php +++ b/tests/Framework/Helpers/NullableUserObjectsTestCaseTest.php @@ -14,7 +14,7 @@ /** * Unit tests for nullable user object functions. */ -class Nullable_User_Objects_Test_Case extends Framework_Test_Case { +class NullableUserObjectsTestCaseTest extends Framework_Test_Case { /** * Test that `get_user_object()` returns a user object. */ diff --git a/tests/framework/test-isolated-framework.php b/tests/Framework/IsolatedFrameworkTest.php similarity index 95% rename from tests/framework/test-isolated-framework.php rename to tests/Framework/IsolatedFrameworkTest.php index ccda175aa..67347330b 100644 --- a/tests/framework/test-isolated-framework.php +++ b/tests/Framework/IsolatedFrameworkTest.php @@ -11,7 +11,7 @@ * Designed to test the application in complete isolation for use outside of a * mantle-based application. */ -class Test_Isolated_Framework extends TestCase { +class IsolatedFrameworkTest extends TestCase { public Application $app; protected function setUp(): void { diff --git a/tests/framework/test-pipeline.php b/tests/Framework/PipelineTest.php similarity index 100% rename from tests/framework/test-pipeline.php rename to tests/Framework/PipelineTest.php diff --git a/tests/helpers/test-helpers-array.php b/tests/Helpers/HelpersArrayTest.php similarity index 99% rename from tests/helpers/test-helpers-array.php rename to tests/Helpers/HelpersArrayTest.php index 9cefe50fa..ffea296c2 100644 --- a/tests/helpers/test-helpers-array.php +++ b/tests/Helpers/HelpersArrayTest.php @@ -6,7 +6,7 @@ use function Mantle\Support\Helpers\data_set; use function Mantle\Support\Helpers\value; -class SupportHelpersArrayTest extends TestCase { +class HelpersArrayTest extends TestCase { public function testValue() { $this->assertSame( 'foo', value( 'foo' ) ); $this->assertSame( 'foo', value( function () { diff --git a/tests/helpers/test-helpers-general.php b/tests/Helpers/HelpersGeneralTest.php similarity index 98% rename from tests/helpers/test-helpers-general.php rename to tests/Helpers/HelpersGeneralTest.php index 449f830b5..b010cb76d 100644 --- a/tests/helpers/test-helpers-general.php +++ b/tests/Helpers/HelpersGeneralTest.php @@ -19,7 +19,7 @@ use function Mantle\Support\Helpers\transform; use function Mantle\Support\Helpers\with; -class SupportHelpersGeneralTest extends TestCase { +class HelpersGeneralTest extends TestCase { public function testClassBasename() { $this->assertSame( 'Baz', class_basename( 'Foo\Bar\Baz' ) ); $this->assertSame( 'Baz', class_basename( 'Baz' ) ); @@ -178,7 +178,7 @@ public function testWith() { } ) ); } - public function providesPregReplaceArrayData() { + public static function providesPregReplaceArrayData() { $pointerArray = [ 'Taylor', 'Otwell' ]; next( $pointerArray ); diff --git a/tests/helpers/test-helpers.php b/tests/Helpers/HelpersTest.php similarity index 98% rename from tests/helpers/test-helpers.php rename to tests/Helpers/HelpersTest.php index 69d9dca09..72fd9e52d 100644 --- a/tests/helpers/test-helpers.php +++ b/tests/Helpers/HelpersTest.php @@ -15,7 +15,7 @@ use function Mantle\Support\Helpers\is_local_env; use function Mantle\Support\Helpers\logger; -class Test_Helpers extends TestCase { +class HelpersTest extends TestCase { protected Application $app; protected Log_Manager $instance; protected TestHandler $handler; diff --git a/tests/http/test-controller.php b/tests/Http/ControllerTest.php similarity index 97% rename from tests/http/test-controller.php rename to tests/Http/ControllerTest.php index 12b8112cb..9a48bfebf 100644 --- a/tests/http/test-controller.php +++ b/tests/Http/ControllerTest.php @@ -13,7 +13,7 @@ use Mantle\Http\Request; use Mantle\Testing\Framework_Test_Case; -class Test_Controller extends Framework_Test_Case { +class ControllerTest extends Framework_Test_Case { public function test_controller_at_method() { Route::get( '/example-controller-at-route', Example_Controller::class . '@example_method' ); diff --git a/tests/http/test-redirector.php b/tests/Http/RedirectorTest.php similarity index 98% rename from tests/http/test-redirector.php rename to tests/Http/RedirectorTest.php index 6309b8edc..cbe063e14 100644 --- a/tests/http/test-redirector.php +++ b/tests/Http/RedirectorTest.php @@ -14,7 +14,7 @@ use Symfony\Component\HttpFoundation\HeaderBag; use Symfony\Component\HttpFoundation\RedirectResponse; -class Test_Redirector extends \Mockery\Adapter\Phpunit\MockeryTestCase { +class RedirectorTest extends \Mockery\Adapter\Phpunit\MockeryTestCase { /** * @var Request diff --git a/tests/http/test-response-factory.php b/tests/Http/ResponseFactoryTest.php similarity index 93% rename from tests/http/test-response-factory.php rename to tests/Http/ResponseFactoryTest.php index b036e1e0b..7d3f73a26 100644 --- a/tests/http/test-response-factory.php +++ b/tests/Http/ResponseFactoryTest.php @@ -9,7 +9,7 @@ use Mantle\Http\Request; -class Test_Response_Factory extends \Mockery\Adapter\Phpunit\MockeryTestCase { +class ResponseFactoryTest extends \Mockery\Adapter\Phpunit\MockeryTestCase { public function setUp(): void { parent::setUp(); diff --git a/tests/http/test-router.php b/tests/Http/RouterTest.php similarity index 99% rename from tests/http/test-router.php rename to tests/Http/RouterTest.php index 54634ba5e..c7600bb39 100644 --- a/tests/http/test-router.php +++ b/tests/Http/RouterTest.php @@ -10,7 +10,7 @@ use Mantle\Http\Routing\Router; use Mantle\Testing\Framework_Test_Case; -class Test_Router extends Framework_Test_Case { +class RouterTest extends Framework_Test_Case { public function test_basic_dispatching() { $router = $this->get_router(); $router->get( diff --git a/tests/http/routing/test-post-model-routing.php b/tests/Http/Routing/PostModelRoutingTest.php similarity index 97% rename from tests/http/routing/test-post-model-routing.php rename to tests/Http/Routing/PostModelRoutingTest.php index 35cf7c2d3..01b294438 100644 --- a/tests/http/routing/test-post-model-routing.php +++ b/tests/Http/Routing/PostModelRoutingTest.php @@ -11,7 +11,7 @@ use Mantle\Http\Routing\Middleware\Wrap_Template; use Mantle\Testing\Framework_Test_Case; -class Test_Post_Model_Routing extends Framework_Test_Case { +class PostModelRoutingTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); diff --git a/tests/http/routing/test-rest-api-routing.php b/tests/Http/Routing/RestApiRoutingTest.php similarity index 98% rename from tests/http/routing/test-rest-api-routing.php rename to tests/Http/Routing/RestApiRoutingTest.php index ffcabb3ec..fcae6ab14 100644 --- a/tests/http/routing/test-rest-api-routing.php +++ b/tests/Http/Routing/RestApiRoutingTest.php @@ -9,7 +9,7 @@ use Mantle\Testing\Framework_Test_Case; use WP_REST_Request; -class Test_REST_API_Routing extends Framework_Test_Case { +class RestApiRoutingTest extends Framework_Test_Case { use Refresh_Database; public function test_generic_route() { diff --git a/tests/http/routing/test-term-model-routing.php b/tests/Http/Routing/TermModelRoutingTest.php similarity index 98% rename from tests/http/routing/test-term-model-routing.php rename to tests/Http/Routing/TermModelRoutingTest.php index 2d880034d..af327a472 100644 --- a/tests/http/routing/test-term-model-routing.php +++ b/tests/Http/Routing/TermModelRoutingTest.php @@ -14,7 +14,7 @@ use Mantle\Http\Routing\Middleware\Wrap_Template; use Mantle\Testing\Framework_Test_Case; -class Test_Term_Model_Routing extends Framework_Test_Case { +class TermModelRoutingTest extends Framework_Test_Case { public function test_category_term() { Testable_Category_Model::boot_if_not_booted(); diff --git a/tests/http/test-uploaded-file.php b/tests/Http/UploadedFileTest.php similarity index 94% rename from tests/http/test-uploaded-file.php rename to tests/Http/UploadedFileTest.php index 16659197a..07931b70e 100644 --- a/tests/http/test-uploaded-file.php +++ b/tests/Http/UploadedFileTest.php @@ -6,7 +6,7 @@ use Mantle\Http\Uploaded_File; use Mantle\Testing\Framework_Test_Case; -class Test_Uploaded_File extends Framework_Test_Case { +class UploadedFileTest extends Framework_Test_Case { public function testUploadedFileCanRetrieveContentsFromTextFile() { $file = new Uploaded_File( diff --git a/tests/http/test-url-generator.php b/tests/Http/UrlGeneratorTest.php similarity index 98% rename from tests/http/test-url-generator.php rename to tests/Http/UrlGeneratorTest.php index 3c9937005..76ede318e 100644 --- a/tests/http/test-url-generator.php +++ b/tests/Http/UrlGeneratorTest.php @@ -11,7 +11,7 @@ use Mantle\Http\Routing\Url_Generator; use Mantle\Testing\Framework_Test_Case; -class Test_Url_Generator extends Framework_Test_Case { +class UrlGeneratorTest extends Framework_Test_Case { protected Router $router; protected Url_Generator $url; diff --git a/tests/http-client/test-http-client.php b/tests/HttpClient/HttpClientTest.php similarity index 99% rename from tests/http-client/test-http-client.php rename to tests/HttpClient/HttpClientTest.php index 9a2642ce6..3a3cd9bbb 100644 --- a/tests/http-client/test-http-client.php +++ b/tests/HttpClient/HttpClientTest.php @@ -18,7 +18,7 @@ use Mantle\Testing\Framework_Test_Case; use Mantle\Testing\Mock_Http_Response; -class Test_Http_Client extends Framework_Test_Case { +class HttpClientTest extends Framework_Test_Case { protected Factory $http_factory; protected function setUp(): void { diff --git a/tests/log/test-log-manager.php b/tests/Log/LogManagerTest.php similarity index 97% rename from tests/log/test-log-manager.php rename to tests/Log/LogManagerTest.php index bad4cf3df..4d4bc4f2c 100644 --- a/tests/log/test-log-manager.php +++ b/tests/Log/LogManagerTest.php @@ -8,7 +8,7 @@ use Mantle\Log\Log_Manager; use Monolog\Handler\TestHandler; -class Test_Log_Manager extends \Mockery\Adapter\Phpunit\MockeryTestCase { +class LogManagerTest extends \Mockery\Adapter\Phpunit\MockeryTestCase { /** * @var Application diff --git a/tests/queue/test-dispatcher.php b/tests/Queue/DispatcherTest.php similarity index 96% rename from tests/queue/test-dispatcher.php rename to tests/Queue/DispatcherTest.php index 2d8d5a918..745193b2d 100644 --- a/tests/queue/test-dispatcher.php +++ b/tests/Queue/DispatcherTest.php @@ -16,7 +16,7 @@ /** * @group queue */ -class Test_Dispatcher extends \Mockery\Adapter\Phpunit\MockeryTestCase { +class DispatcherTest extends \Mockery\Adapter\Phpunit\MockeryTestCase { /** * Provider instance. * diff --git a/tests/queue/test-queue-manager.php b/tests/Queue/QueueManagerTest.php similarity index 94% rename from tests/queue/test-queue-manager.php rename to tests/Queue/QueueManagerTest.php index 9eab6995e..6975357ad 100644 --- a/tests/queue/test-queue-manager.php +++ b/tests/Queue/QueueManagerTest.php @@ -10,7 +10,7 @@ /** * @group queue */ -class Test_Queue_Manager extends \Mockery\Adapter\Phpunit\MockeryTestCase { +class QueueManagerTest extends \Mockery\Adapter\Phpunit\MockeryTestCase { public function test_default_connection() { $provider = m::mock( Provider::class ); diff --git a/tests/queue/test-worker.php b/tests/Queue/WorkerTest.php similarity index 98% rename from tests/queue/test-worker.php rename to tests/Queue/WorkerTest.php index 909c99709..1d5d426ff 100644 --- a/tests/queue/test-worker.php +++ b/tests/Queue/WorkerTest.php @@ -18,7 +18,7 @@ /** * @group queue */ -class Test_Worker extends MockeryTestCase { +class WorkerTest extends MockeryTestCase { /** * Application instance. diff --git a/tests/queue/providers/test-wordpress-cron-queue.php b/tests/Queue/providers/WordPressCronQueueTest.php similarity index 98% rename from tests/queue/providers/test-wordpress-cron-queue.php rename to tests/Queue/providers/WordPressCronQueueTest.php index 93fa00d43..9676ccf85 100644 --- a/tests/queue/providers/test-wordpress-cron-queue.php +++ b/tests/Queue/providers/WordPressCronQueueTest.php @@ -21,7 +21,7 @@ * @group queue * @group wordpress-queue */ -class Test_WordPress_Cron_Queue extends Framework_Test_Case { +class WordPressCronQueueTest extends Framework_Test_Case { use Refresh_Database; protected function setUp(): void { diff --git a/tests/scheduling/test-event.php b/tests/Scheduling/EventTest.php similarity index 97% rename from tests/scheduling/test-event.php rename to tests/Scheduling/EventTest.php index 15163e9d0..9a9490202 100644 --- a/tests/scheduling/test-event.php +++ b/tests/Scheduling/EventTest.php @@ -8,7 +8,7 @@ use Mantle\Testing\Mock_Http_Response; use Mockery as m; -class Test_Event extends Framework_Test_Case { +class EventTest extends Framework_Test_Case { protected function tearDown(): void { parent::tearDown(); diff --git a/tests/scheduling/test-frequency.php b/tests/Scheduling/FrequencyTest.php similarity index 98% rename from tests/scheduling/test-frequency.php rename to tests/Scheduling/FrequencyTest.php index 4dbc3c0a9..172adf579 100644 --- a/tests/scheduling/test-frequency.php +++ b/tests/Scheduling/FrequencyTest.php @@ -6,7 +6,7 @@ use Mantle\Testing\Framework_Test_Case; use Mockery as m; -class Test_Frequency extends Framework_Test_Case { +class FrequencyTest extends Framework_Test_Case { /* * @var Event diff --git a/tests/support/test-arr.php b/tests/Support/ArrTest.php similarity index 99% rename from tests/support/test-arr.php rename to tests/Support/ArrTest.php index 8cdd75217..b0b2b0926 100644 --- a/tests/support/test-arr.php +++ b/tests/Support/ArrTest.php @@ -10,7 +10,7 @@ use PHPUnit\Framework\TestCase; use stdClass; -class Test_Arr extends TestCase { +class ArrTest extends TestCase { public function testAccessible() { $this->assertTrue( Arr::accessible( [] ) ); diff --git a/tests/support/test-collection.php b/tests/Support/CollectionTest.php similarity index 99% rename from tests/support/test-collection.php rename to tests/Support/CollectionTest.php index 1db26c813..76079491c 100644 --- a/tests/support/test-collection.php +++ b/tests/Support/CollectionTest.php @@ -21,7 +21,7 @@ use function Mantle\Support\Helpers\collect; -class Test_Collection extends Framework_Test_Case { +class CollectionTest extends Framework_Test_Case { /** * @dataProvider collectionClassProvider */ @@ -320,7 +320,7 @@ public function testJsonSerializeCallsToArrayOrJsonSerializeOnEachItemInCollecti */ public function testToJsonEncodesTheJsonSerializeResult($collection) { - $c = $this->getMockBuilder($collection)->setMethods(['jsonSerialize'])->getMock(); + $c = $this->getMockBuilder($collection)->onlyMethods(['jsonSerialize'])->getMock(); $c->expects($this->once())->method('jsonSerialize')->willReturn('foo'); $results = $c->to_json(); $this->assertJsonStringEqualsJsonString(json_encode('foo'), $results); @@ -331,7 +331,7 @@ public function testToJsonEncodesTheJsonSerializeResult($collection) */ public function testCastingToStringJsonEncodesTheToArrayResult($collection) { - $c = $this->getMockBuilder($collection)->setMethods(['jsonSerialize'])->getMock(); + $c = $this->getMockBuilder($collection)->onlyMethods(['jsonSerialize'])->getMock(); $c->expects($this->once())->method('jsonSerialize')->willReturn('foo'); $this->assertJsonStringEqualsJsonString(json_encode('foo'), (string) $c); @@ -4336,7 +4336,7 @@ public function test_from_fallback( $collection ) { * * @return array */ - public function collectionClassProvider() + public static function collectionClassProvider() { return [ [Collection::class], diff --git a/tests/support/test-environment.php b/tests/Support/EnvironmentTest.php similarity index 94% rename from tests/support/test-environment.php rename to tests/Support/EnvironmentTest.php index 1afb034f7..043791944 100644 --- a/tests/support/test-environment.php +++ b/tests/Support/EnvironmentTest.php @@ -5,7 +5,7 @@ use Mantle\Support\Environment; use Mantle\Testing\Framework_Test_Case; -class Test_Environment extends Framework_Test_Case { +class EnvironmentTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); Environment::clear(); diff --git a/tests/support/test-forward-calls.php b/tests/Support/ForwardCallsTest.php similarity index 98% rename from tests/support/test-forward-calls.php rename to tests/Support/ForwardCallsTest.php index 8ff8d3669..ee7d60945 100644 --- a/tests/support/test-forward-calls.php +++ b/tests/Support/ForwardCallsTest.php @@ -7,7 +7,7 @@ use Mantle\Support\Forward_Calls; use PHPUnit\Framework\TestCase; -class Forward_CallsTest extends TestCase { +class ForwardCallsTest extends TestCase { public function testForward_Calls() { $results = ( new Forward_CallsOne() )->forwardedTwo( 'foo', 'bar' ); diff --git a/tests/support/test-pluralizer.php b/tests/Support/PluralizerTest.php similarity index 99% rename from tests/support/test-pluralizer.php rename to tests/Support/PluralizerTest.php index 78c6fbfa8..787bb1b00 100755 --- a/tests/support/test-pluralizer.php +++ b/tests/Support/PluralizerTest.php @@ -5,7 +5,7 @@ use Mantle\Support\Str; use PHPUnit\Framework\TestCase; -class Test_Pluralizer extends TestCase { +class PluralizerTest extends TestCase { public function testBasicSingular() { $this->assertSame( 'child', Str::singular( 'children' ) ); diff --git a/tests/support/providers/test-model-register-provider.php b/tests/Support/Providers/ModelRegisterProviderTest.php similarity index 94% rename from tests/support/providers/test-model-register-provider.php rename to tests/Support/Providers/ModelRegisterProviderTest.php index 1eb246bd1..163be9789 100644 --- a/tests/support/providers/test-model-register-provider.php +++ b/tests/Support/Providers/ModelRegisterProviderTest.php @@ -11,7 +11,7 @@ use Mockery as m; use Mockery\Adapter\Phpunit\MockeryTestCase; -class Test_Model_Service_Provider extends MockeryTestCase { +class ModelRegisterProviderTest extends MockeryTestCase { protected function setUp(): void { parent::setUp(); remove_all_actions( 'init' ); diff --git a/tests/support/test-service-provider.php b/tests/Support/ServiceProviderTest.php similarity index 99% rename from tests/support/test-service-provider.php rename to tests/Support/ServiceProviderTest.php index 8b42d9c85..9b325be62 100644 --- a/tests/support/test-service-provider.php +++ b/tests/Support/ServiceProviderTest.php @@ -9,7 +9,7 @@ use Mantle\Support\Attributes\Action; use Mockery as m; -class Test_Service_Provider extends \Mockery\Adapter\Phpunit\MockeryTestCase { +class ServiceProviderTest extends \Mockery\Adapter\Phpunit\MockeryTestCase { protected function setUp(): void { parent::setUp(); diff --git a/tests/support/test-str.php b/tests/Support/StrTest.php similarity index 99% rename from tests/support/test-str.php rename to tests/Support/StrTest.php index d0349f5bc..2fd1b1d48 100644 --- a/tests/support/test-str.php +++ b/tests/Support/StrTest.php @@ -8,7 +8,7 @@ use Ramsey\Uuid\UuidInterface; use ReflectionClass; -class Test_Str extends TestCase { +class StrTest extends TestCase { public function testStringCanBeLimitedByWords() { $this->assertSame( 'Taylor...', Str::words( 'Taylor Otwell', 1 ) ); diff --git a/tests/support/test-stringable.php b/tests/Support/StringableTest.php similarity index 99% rename from tests/support/test-stringable.php rename to tests/Support/StringableTest.php index e50565c1d..98e9c4e2d 100644 --- a/tests/support/test-stringable.php +++ b/tests/Support/StringableTest.php @@ -8,7 +8,7 @@ use Mantle\Support\Stringable; use PHPUnit\Framework\TestCase; -class Test_Stringable extends TestCase { +class StringableTest extends TestCase { /** * @param string $string diff --git a/tests/testing/concerns/test-block-assertions.php b/tests/Testing/Concerns/BlockAssertionsTest.php similarity index 95% rename from tests/testing/concerns/test-block-assertions.php rename to tests/Testing/Concerns/BlockAssertionsTest.php index 97a8805af..dbd157a31 100644 --- a/tests/testing/concerns/test-block-assertions.php +++ b/tests/Testing/Concerns/BlockAssertionsTest.php @@ -8,7 +8,7 @@ /** * @group testing */ -class Test_Block_Assertions extends Framework_Test_Case { +class BlockAssertionsTest extends Framework_Test_Case { use With_Faker; protected WP_Post $post; diff --git a/tests/testing/concerns/test-deprecations.php b/tests/Testing/Concerns/DeprecationsTest.php similarity index 96% rename from tests/testing/concerns/test-deprecations.php rename to tests/Testing/Concerns/DeprecationsTest.php index 44298b51c..fc09d8424 100644 --- a/tests/testing/concerns/test-deprecations.php +++ b/tests/Testing/Concerns/DeprecationsTest.php @@ -8,7 +8,7 @@ * * @group testing */ -class Test_Deprecations extends Framework_Test_Case { +class DeprecationsTest extends Framework_Test_Case { /** * @expectedDeprecated test_deprecation_annotation */ diff --git a/tests/testing/concerns/test-element-assertions.php b/tests/Testing/Concerns/ElementAssertionsTest.php similarity index 96% rename from tests/testing/concerns/test-element-assertions.php rename to tests/Testing/Concerns/ElementAssertionsTest.php index deda4c49e..4c55dedb5 100644 --- a/tests/testing/concerns/test-element-assertions.php +++ b/tests/Testing/Concerns/ElementAssertionsTest.php @@ -7,7 +7,7 @@ /** * @group testing */ -class Test_Element_Assertions extends Framework_Test_Case { +class ElementAssertionsTest extends Framework_Test_Case { public string $test_content = '
Example Section
diff --git a/tests/testing/concerns/test-incorrect-usage.php b/tests/Testing/Concerns/IncorrectUsageTest.php similarity index 96% rename from tests/testing/concerns/test-incorrect-usage.php rename to tests/Testing/Concerns/IncorrectUsageTest.php index 214f78217..156701de9 100644 --- a/tests/testing/concerns/test-incorrect-usage.php +++ b/tests/Testing/Concerns/IncorrectUsageTest.php @@ -8,7 +8,7 @@ * * @group testing */ -class Test_Incorrect_Usage extends Framework_Test_Case { +class IncorrectUsageTest extends Framework_Test_Case { /** * @expectedIncorrectUsage test_incorrect_usage_annotation */ diff --git a/tests/testing/concerns/test-interacts-with-console.php b/tests/Testing/Concerns/InteractsWithConsoleTest.php similarity index 93% rename from tests/testing/concerns/test-interacts-with-console.php rename to tests/Testing/Concerns/InteractsWithConsoleTest.php index f1d8061d8..d19a1796f 100644 --- a/tests/testing/concerns/test-interacts-with-console.php +++ b/tests/Testing/Concerns/InteractsWithConsoleTest.php @@ -1,5 +1,5 @@ assertHookNotApplied( 'hook_to_check' ); $this->assertHookNotApplied( 'filter_to_check' ); diff --git a/tests/testing/concerns/test-makes-http-requests.php b/tests/Testing/Concerns/MakesHttpRequestsTest.php similarity index 99% rename from tests/testing/concerns/test-makes-http-requests.php rename to tests/Testing/Concerns/MakesHttpRequestsTest.php index 1afd1fc40..5dc1b83ec 100644 --- a/tests/testing/concerns/test-makes-http-requests.php +++ b/tests/Testing/Concerns/MakesHttpRequestsTest.php @@ -17,7 +17,7 @@ /** * @group testing */ -class Test_Makes_Http_Requests extends Framework_Test_Case { +class MakesHttpRequestsTest extends Framework_Test_Case { use Refresh_Database; public function test_get_home() { diff --git a/tests/testing/concerns/test-wordpress-authentication.php b/tests/Testing/Concerns/WordPressAuthenticationTest.php similarity index 90% rename from tests/testing/concerns/test-wordpress-authentication.php rename to tests/Testing/Concerns/WordPressAuthenticationTest.php index 1db897a30..252035ec9 100644 --- a/tests/testing/concerns/test-wordpress-authentication.php +++ b/tests/Testing/Concerns/WordPressAuthenticationTest.php @@ -1,5 +1,5 @@ acting_as( 'administrator' ); diff --git a/tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot__1.yml b/tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot__1.yml similarity index 100% rename from tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot__1.yml rename to tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot__1.yml diff --git a/tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_http__1.html b/tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_http__1.html similarity index 100% rename from tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_http__1.html rename to tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_http__1.html diff --git a/tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_http_partial__1.html b/tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_http_partial__1.html similarity index 100% rename from tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_http_partial__1.html rename to tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_http_partial__1.html diff --git a/tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_rest__1.json b/tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_rest__1.json similarity index 100% rename from tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_rest__1.json rename to tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_rest__1.json diff --git a/tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_rest__2.json b/tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_rest__2.json similarity index 100% rename from tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_rest__2.json rename to tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_rest__2.json diff --git a/tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_rest__3.json b/tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_rest__3.json similarity index 100% rename from tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_match_snapshot_rest__3.json rename to tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_match_snapshot_rest__3.json diff --git a/tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_multiple_requests__1.yml b/tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_multiple_requests__1.yml similarity index 100% rename from tests/testing/concerns/__snapshots__/Test_Makes_Http_Requests__test_multiple_requests__1.yml rename to tests/Testing/Concerns/__snapshots__/MakesHttpRequestsTest__test_multiple_requests__1.yml diff --git a/tests/testing/test-core-test-shim.php b/tests/Testing/CoreTestShimTest.php similarity index 88% rename from tests/testing/test-core-test-shim.php rename to tests/Testing/CoreTestShimTest.php index d5f009504..f88ffe976 100644 --- a/tests/testing/test-core-test-shim.php +++ b/tests/Testing/CoreTestShimTest.php @@ -3,7 +3,7 @@ use WP_UnitTestCase; -class Test_Core_Test_Shim extends WP_UnitTestCase { +class CoreTestShimTest extends WP_UnitTestCase { protected $setup_called = false; public function set_up() { diff --git a/tests/testing/test-permalink-structure.php b/tests/Testing/PermalinkStructureTest.php similarity index 97% rename from tests/testing/test-permalink-structure.php rename to tests/Testing/PermalinkStructureTest.php index 0d7e114f4..713061353 100644 --- a/tests/testing/test-permalink-structure.php +++ b/tests/Testing/PermalinkStructureTest.php @@ -4,7 +4,7 @@ use Mantle\Testing\Framework_Test_Case; use Mantle\Testing\Utils; -class Test_Permalink_Structure extends Framework_Test_Case { +class PermalinkStructureTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); diff --git a/tests/testing/test-with-faker.php b/tests/Testing/WithFakerTest.php similarity index 62% rename from tests/testing/test-with-faker.php rename to tests/Testing/WithFakerTest.php index f08f97d6f..8b950906d 100644 --- a/tests/testing/test-with-faker.php +++ b/tests/Testing/WithFakerTest.php @@ -1,10 +1,11 @@ Contains the names of the methods that have been overloaded. @@ -21,7 +21,7 @@ trait Example_Overload { * This method should be run during the setUpBeforeClass method of * the Test_Case. */ - public static function example_overload_set_up_before_class(): void { + public static function exampleoverload_set_up_before_class(): void { static::$overloaded_methods[] = 'setUpBeforeClass'; } } diff --git a/tests/testkit/test-testkit-install-wordpress.php b/tests/Testkit/TestkitInstallWordPressTest.php similarity index 92% rename from tests/testkit/test-testkit-install-wordpress.php rename to tests/Testkit/TestkitInstallWordPressTest.php index 80bdf9408..0177366af 100644 --- a/tests/testkit/test-testkit-install-wordpress.php +++ b/tests/Testkit/TestkitInstallWordPressTest.php @@ -14,7 +14,7 @@ $_SERVER['__mantle_after_wordpress_install']++; } ); -class Test_Testkit_Install_WordPress extends Test_Case { +class TestkitInstallWordPressTest extends Test_Case { use Installs_WordPress; public function test_mantle_is_installed_from_trait() { diff --git a/tests/testkit/test-testkit-test-case.php b/tests/Testkit/TestkitTestCaseTest.php similarity index 87% rename from tests/testkit/test-testkit-test-case.php rename to tests/Testkit/TestkitTestCaseTest.php index 25d71d866..895181bec 100644 --- a/tests/testkit/test-testkit-test-case.php +++ b/tests/Testkit/TestkitTestCaseTest.php @@ -1,11 +1,11 @@ assertInstanceOf( \Mantle\Contracts\Application::class, $this->create_application() ); diff --git a/tests/testkit/test-with-faker.php b/tests/Testkit/WithFakerTest.php similarity index 85% rename from tests/testkit/test-with-faker.php rename to tests/Testkit/WithFakerTest.php index 12ec2efb1..05bc615eb 100644 --- a/tests/testkit/test-with-faker.php +++ b/tests/Testkit/WithFakerTest.php @@ -5,7 +5,7 @@ use Mantle\Testing\Concerns\With_Faker; use Mantle\Testkit\Test_Case; -class Test_With_Faker extends Test_Case { +class WithFakerTest extends Test_Case { use With_Faker; public function test_creates_faker() { diff --git a/tests/testkit/fixtures/global-functions.php b/tests/Testkit/fixtures/global-functions.php similarity index 100% rename from tests/testkit/fixtures/global-functions.php rename to tests/Testkit/fixtures/global-functions.php diff --git a/tests/view/test-blade-views.php b/tests/View/BladeViewsTest.php similarity index 93% rename from tests/view/test-blade-views.php rename to tests/View/BladeViewsTest.php index 7794fdca1..9334711f2 100644 --- a/tests/view/test-blade-views.php +++ b/tests/View/BladeViewsTest.php @@ -3,7 +3,7 @@ use Mantle\Testing\Framework_Test_Case; -class Test_Blade_Views extends Framework_Test_Case { +class BladeViewsTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); diff --git a/tests/view/test-file-engine.php b/tests/View/FileEngineTest.php similarity index 91% rename from tests/view/test-file-engine.php rename to tests/View/FileEngineTest.php index 1eb2b43ed..e5b023930 100644 --- a/tests/view/test-file-engine.php +++ b/tests/View/FileEngineTest.php @@ -3,7 +3,7 @@ use Mantle\Testing\Framework_Test_Case; -class Test_File_Views extends Framework_Test_Case { +class FileEngineTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); diff --git a/tests/view/test-php-views.php b/tests/View/PhpViewsTest.php similarity index 99% rename from tests/view/test-php-views.php rename to tests/View/PhpViewsTest.php index 985855e24..9ee68f046 100644 --- a/tests/view/test-php-views.php +++ b/tests/View/PhpViewsTest.php @@ -5,7 +5,7 @@ use Mantle\Facade\View; use Mantle\Http\View\Factory; -class Test_Php_Views extends Framework_Test_Case { +class PhpViewsTest extends Framework_Test_Case { protected Factory $view_factory; protected function setUp(): void { diff --git a/tests/view/test-view-finder.php b/tests/View/ViewFinderTest.php similarity index 96% rename from tests/view/test-view-finder.php rename to tests/View/ViewFinderTest.php index e9b98954a..655b0671a 100644 --- a/tests/view/test-view-finder.php +++ b/tests/View/ViewFinderTest.php @@ -4,7 +4,7 @@ use Mantle\Facade\View_Loader; use Mantle\Testing\Framework_Test_Case; -class Test_View_Finder extends Framework_Test_Case { +class ViewFinderTest extends Framework_Test_Case { protected function setUp(): void { parent::setUp(); diff --git a/tests/assets/test-asset-manager.php b/tests/assets/test-asset-manager.php deleted file mode 100644 index cd96f32fd..000000000 --- a/tests/assets/test-asset-manager.php +++ /dev/null @@ -1,108 +0,0 @@ -script( - "script-handle", - "https://example.org/script.js", - [ - "jquery", - ], - "global", - "sync", - ); - - $this->assertStringContainsString( - "", - $this->get_wp_head(), - ); - } - - public function test_register_style() { - $manager = new Asset_Manager(); - $manager - ->style( - "style-handle", - "https://example.org/style.css", - [] - ); - - $this->assertStringContainsString( - "", - $this->get_wp_head(), - ); - } - - public function test_async_script() { - $manager = new Asset_Manager(); - $manager - ->script( - "testsync-script-handle", - "https://example.org/example-script.js", - ); - - $manager->async( "testsync-script-handle" ); - - $this->assertStringContainsString( - "", - $this->get_wp_head(), - ); - } - - public function test_fluent_script() { - $manager = new Asset_Manager(); - $manager - ->script( "example-fluent" ) - ->src( "https://example.org/example-fluent.js" ) - ->async(); - - $this->assertStringContainsString( - "", - $this->get_wp_head(), - ); - } - - public function test_fluent_script_helper() { - asset() - ->script( "example-helper" ) - ->src( "https://example.org/example-helper.js" ) - ->async(); - - $this->assertStringContainsString( - "", - $this->get_wp_head(), - ); - } - - public function test_core_dependency() { - global $wp_scripts; - - // Prevent a failing test if this is removed in the future. - if ( ! isset( $wp_scripts->registered["swfobject"] ) ) { - $this->markTestSkipped( "swfobject is not registered in core, should change the dependency tested against" ); - return; - } - - $version = $wp_scripts->registered["swfobject"]->ver; - - // Get the core version of the asset. - ( new Asset_Manager() ) - ->script( "swfobject" ) - ->version( null ) - ->async(); - - $this->assertStringContainsString( - "", - $this->get_wp_head(), - ); - } -} diff --git a/tests/framework/blocks/fixtures/blocks/class-mock-block.php b/tests/framework/blocks/fixtures/blocks/class-mock-block.php deleted file mode 100644 index eaac44bec..000000000 --- a/tests/framework/blocks/fixtures/blocks/class-mock-block.php +++ /dev/null @@ -1,21 +0,0 @@ -app->set_app_path( dirname( __DIR__, 2 ) ); - - $this->app['config']->set( 'app.namespace', 'Mantle\\Tests' ); - } - - protected function tearDown(): void { - $this->app['config']->set( 'app.namespace', 'App' ); - $this->app->set_app_path( $this->app->get_base_path( 'app' ) ); - - parent::tearDown(); - } - - /** - * Verify that the Discover_Blocks::within method returns the expected - * array of block class names. - */ - public function testBlocksAreFound() { - $this->assertEquals( 'Mantle\\Tests', $this->app->get_namespace() ); - - $expected = [ - Example_Block::class, - ]; - - $found_blocks = Discover_Blocks::within( - __DIR__ . '/fixtures/dummy', - getcwd(), - ); - - $this->assertSame( $expected, $found_blocks ); - } - - /** - * Verify that the Block Service Provider locates, and registers, blocks - * as expected. - */ - public function testBlockProviderRegistersBlocks() { - $expected = 1; - - /** - * First we need to configure the test application so it will find the blocks - * inside of our fixtures folder, and load them as if this were the Mantle app. - */ - $app = m::mock( Application::class )->makePartial(); - $app->set_base_path( getcwd() ); - $app->set_app_path( __DIR__ . '/fixtures' ); - - $app['config'] = $this->app['config']; - - $this->assertEquals( 'Mantle\\Tests', $app->get_namespace() ); - - /** - * Now we need to boot our test application. - */ - $app->register( Block_Service_Provider::class ); - $app->boot(); - - $this->assertSame( $expected, Mock_Block::$registrations ); - } -} diff --git a/tests/framework/helpers/test-nullable-site-objects-test-case.php b/tests/framework/helpers/test-nullable-site-objects-test-case.php deleted file mode 100644 index 7f805d5e1..000000000 --- a/tests/framework/helpers/test-nullable-site-objects-test-case.php +++ /dev/null @@ -1,40 +0,0 @@ -blog->create(); - - $found_object = get_site_object( $known_id ); - - $this->assertInstanceOf( \WP_Site::class, $found_object ); - - $this->assertSame( $known_id, (int) $found_object->blog_id ); - } - - /** - * Test that `get_site_object()` returns null when there is no site. - */ - public function test_site_object_returns_null() { - $found_object = get_site_object( -99 ); - - $this->assertNull( $found_object ); - } - } -} From 1339b4e452eb0c6b89ae8feaeb8cc516a7beaf82 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 27 Nov 2023 16:21:44 -0500 Subject: [PATCH 2/5] Fixing versions --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e61314bec..cca535880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## v0.12.9 - 2023-11-27 +## v0.12.10 - 2023-11-27 ### Changed - Removed PHPUnit 10 support to prevent a breaking change. Moved to 1.x. -## v0.12.8 - 2023-11-21 +## v0.12.9 - 2023-11-21 ### Changed From 7c5a107eb7d7dd27d4a4aea3f9558346a66734fb Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 27 Nov 2023 17:09:02 -0500 Subject: [PATCH 3/5] Adding enum support to meta and query builder --- .../database/model/meta/trait-model-meta.php | 22 +++++++-- src/mantle/database/query/class-builder.php | 18 +++++-- tests/Database/Query/PostQueryBuilderTest.php | 49 +++++++++++++++++++ 3 files changed, 83 insertions(+), 6 deletions(-) diff --git a/src/mantle/database/model/meta/trait-model-meta.php b/src/mantle/database/model/meta/trait-model-meta.php index 59ef97ca2..9e4408efb 100644 --- a/src/mantle/database/model/meta/trait-model-meta.php +++ b/src/mantle/database/model/meta/trait-model-meta.php @@ -7,7 +7,9 @@ namespace Mantle\Database\Model\Meta; +use BackedEnum; use Mantle\Database\Model\Model_Exception; +use UnitEnum; /** * Interface for interfacing with a model's meta. @@ -47,7 +49,7 @@ public function add_meta( string $meta_key, mixed $meta_value, mixed $prev_value return; } - \add_metadata( $this->get_meta_type(), $this->id(), $meta_key, $meta_value ); + \add_metadata( $this->get_meta_type(), $this->id(), $meta_key, $this->serialize_value_for_storage( $meta_value ) ); } /** @@ -63,7 +65,7 @@ public function set_meta( string $meta_key, mixed $meta_value, mixed $prev_value return; } - \update_metadata( $this->get_meta_type(), $this->id(), $meta_key, $meta_value, $prev_value ); + \update_metadata( $this->get_meta_type(), $this->id(), $meta_key, $this->serialize_value_for_storage( $meta_value ), $prev_value ); } /** @@ -73,7 +75,7 @@ public function set_meta( string $meta_key, mixed $meta_value, mixed $prev_value * @param mixed $meta_value Previous meta value to delete. */ public function delete_meta( string $meta_key, mixed $meta_value = '' ): void { - \delete_metadata( $this->get_meta_type(), $this->id(), $meta_key, $meta_value ); + \delete_metadata( $this->get_meta_type(), $this->id(), $meta_key, $this->serialize_value_for_storage( $meta_value ) ); } /** @@ -141,4 +143,18 @@ public function store_queued_meta(): void { $this->queued_meta = []; } + + /** + * Serialize meta value for storage, converting all backed enums to their value. + * + * @param mixed $value Value to serialize. + * @return mixed + */ + protected function serialize_value_for_storage( mixed $value ): mixed { + if ( $value instanceof BackedEnum ) { + return $value->value; + } + + return $value; + } } diff --git a/src/mantle/database/query/class-builder.php b/src/mantle/database/query/class-builder.php index 969ad838f..5775ba38e 100644 --- a/src/mantle/database/query/class-builder.php +++ b/src/mantle/database/query/class-builder.php @@ -11,6 +11,7 @@ namespace Mantle\Database\Query; +use BackedEnum; use Closure; use Mantle\Container\Container; use Mantle\Contracts\Database\Scope; @@ -348,12 +349,20 @@ protected function resolve_attribute( string $attribute ): string { /** * Query by a meta field. * - * @param string $key Meta key. - * @param mixed $value Meta value. - * @param string $compare Comparison method, defaults to '='. + * @param string|\BackedEnum $key Meta key. + * @param mixed $value Meta value. + * @param string $compare Comparison method, defaults to '='. * @return static */ public function whereMeta( $key, $value, string $compare = '=' ) { + if ( $key instanceof BackedEnum ) { + $key = $key->value; + } + + if ( $value instanceof BackedEnum ) { + $value = $value->value; + } + $meta_query = [ 'compare' => $compare, 'key' => $key, @@ -366,6 +375,7 @@ public function whereMeta( $key, $value, string $compare = '=' ) { } $this->meta_query[] = $meta_query; + return $this; } @@ -379,6 +389,7 @@ public function whereMeta( $key, $value, string $compare = '=' ) { */ public function andWhereMeta( ...$args ) { $this->meta_query['relation'] = 'AND'; + return $this->whereMeta( ...$args ); } @@ -392,6 +403,7 @@ public function andWhereMeta( ...$args ) { */ public function orWhereMeta( ...$args ) { $this->meta_query['relation'] = 'OR'; + return $this->whereMeta( ...$args ); } diff --git a/tests/Database/Query/PostQueryBuilderTest.php b/tests/Database/Query/PostQueryBuilderTest.php index 34dd296a2..b4b19ef7d 100644 --- a/tests/Database/Query/PostQueryBuilderTest.php +++ b/tests/Database/Query/PostQueryBuilderTest.php @@ -673,6 +673,46 @@ protected static function get_random_post_id( $args = [] ): int { array_pop( $post_ids ); return $post_ids[ array_rand( $post_ids ) ]; } + + public function test_query_by_enum() { + // Check if enum is supported. + if ( PHP_VERSION_ID < 80100 ) { + $this->markTestSkipped( 'PHP 8.1+ is required for this test.' ); + } + + $post = static::factory()->post + ->with_meta( [ + 'example-meta' => Testable_Meta_Values::Meta_Value_A, + Testable_Meta_Values::Meta_Key_A->value => Testable_Meta_Values::Meta_Value_A, + Testable_Meta_Values::Meta_Key_B->value => Testable_Meta_Values::Meta_Value_B, + ] ) + ->as_models() + ->create_and_get(); + + $this->assertEquals( + Testable_Meta_Values::Meta_Value_A->value, + $post->get_meta( 'example-meta' ), + ); + + $this->assertEquals( + Testable_Meta_Values::Meta_Value_B->value, + $post->get_meta( Testable_Meta_Values::Meta_Key_B->value ), + ); + + $this->assertEmpty( + Testable_Post::whereMeta( Testable_Meta_Values::Meta_Key_A->value, 'unknown' )->first(), + ); + + $this->assertEquals( + $post->id(), + Testable_Post::whereMeta( 'example-meta', Testable_Meta_Values::Meta_Value_A )->first()?->id, + ); + + $this->assertEquals( + $post->id(), + Testable_Post::whereMeta( Testable_Meta_Values::Meta_Key_A->value, Testable_Meta_Values::Meta_Value_A )->first()?->id, + ); + } } class Testable_Post extends Post { @@ -686,3 +726,12 @@ class Another_Testable_Post extends Post { class Testable_Tag extends Term { public static $object_name = 'post_tag'; } + +if ( PHP_VERSION_ID >= 80100 ) { + enum Testable_Meta_Values: string { + case Meta_Key_A = 'meta-key-a'; + case Meta_Key_B = 'meta-key-b'; + case Meta_Value_A = 'meta-value-a'; + case Meta_Value_B = 'meta-value-b'; + } +} From df3c50906334a00d8c7dcface69fac6c3c0d5971 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 27 Nov 2023 17:10:28 -0500 Subject: [PATCH 4/5] Remove unused ref --- src/mantle/database/model/meta/trait-model-meta.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mantle/database/model/meta/trait-model-meta.php b/src/mantle/database/model/meta/trait-model-meta.php index 9e4408efb..774f2e0a7 100644 --- a/src/mantle/database/model/meta/trait-model-meta.php +++ b/src/mantle/database/model/meta/trait-model-meta.php @@ -9,7 +9,6 @@ use BackedEnum; use Mantle\Database\Model\Model_Exception; -use UnitEnum; /** * Interface for interfacing with a model's meta. From ccb4f98e5314982c90fdfd6d3dd0902d9fb78275 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 27 Nov 2023 17:11:52 -0500 Subject: [PATCH 5/5] Use only enum on the query builder --- src/mantle/database/model/class-post.php | 2 +- tests/Database/Query/PostQueryBuilderTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mantle/database/model/class-post.php b/src/mantle/database/model/class-post.php index f6d72c87b..6784eb50a 100644 --- a/src/mantle/database/model/class-post.php +++ b/src/mantle/database/model/class-post.php @@ -65,7 +65,7 @@ * @method static \Mantle\Database\Query\Post_Query_Builder whereTerm( array|\WP_Term|\Mantle\Database\Model\Term|int $term, ?string $taxonomy = null, string $operator = 'IN', string $field = 'term_id' ) * @method static \Mantle\Database\Query\Post_Query_Builder andWhereTerm( array|\WP_Term|\Mantle\Database\Model\Term|int $term, ?string $taxonomy = null, string $operator = 'IN', string $field = 'term_id' ) * @method static \Mantle\Database\Query\Post_Query_Builder orWhereTerm( array|\WP_Term|\Mantle\Database\Model\Term|int $term, ?string $taxonomy = null, string $operator = 'IN', string $field = 'term_id' ) - * @method static \Mantle\Database\Query\Post_Query_Builder whereMeta( string $key, mixed $value, string $operator = '=' ) + * @method static \Mantle\Database\Query\Post_Query_Builder whereMeta( string|\BackedEnum $key, mixed $value, string $operator = '=' ) * @method static \Mantle\Database\Query\Post_Query_Builder whereRaw( array|string $column, ?string $operator = null, mixed $value = null, string $boolean = 'AND' ) * @method static \Mantle\Database\Query\Post_Query_Builder where_raw( array|string $column, ?string $operator = null, mixed $value = null, string $boolean = 'AND' ) * @method static \Mantle\Database\Query\Post_Query_Builder orWhereRaw( array|string $column, ?string $operator = null, mixed $value = null, string $boolean = 'AND' ) diff --git a/tests/Database/Query/PostQueryBuilderTest.php b/tests/Database/Query/PostQueryBuilderTest.php index b4b19ef7d..759c87114 100644 --- a/tests/Database/Query/PostQueryBuilderTest.php +++ b/tests/Database/Query/PostQueryBuilderTest.php @@ -710,7 +710,7 @@ public function test_query_by_enum() { $this->assertEquals( $post->id(), - Testable_Post::whereMeta( Testable_Meta_Values::Meta_Key_A->value, Testable_Meta_Values::Meta_Value_A )->first()?->id, + Testable_Post::whereMeta( Testable_Meta_Values::Meta_Key_A, Testable_Meta_Values::Meta_Value_A )->first()?->id, ); } }