Skip to content

Commit

Permalink
Merge pull request #1582 from hydephp/remove-global-function-imports-…
Browse files Browse the repository at this point in the history
…from-tests

Remove global function imports from tests
  • Loading branch information
caendesilva authored Feb 22, 2024
2 parents a6bcd95 + a97f942 commit f68daaf
Show file tree
Hide file tree
Showing 24 changed files with 7 additions and 93 deletions.
7 changes: 7 additions & 0 deletions monorepo/scripts/FileFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ protected function run(): void

/** Normalization */

// Remove global function imports from tests
if (str_ends_with($filename, 'Test.php')) {
if (str_starts_with($line, 'use function') && ! str_contains($line, '\\')) {
continue;
}
}

// Remove multiple empty lines
if (in_array(Settings::TrimMultipleEmptyLines, $this->settings)) {
if (trim($line) == '' && trim($last_line) == '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\File;

use function is_dir;

/**
* @covers \Hyde\Console\Commands\PublishViewsCommand
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@

namespace Hyde\Framework\Testing\Feature;

use function app;
use function config;
use function file_put_contents;

use Hyde\Framework\HydeServiceProvider;
use Hyde\Hyde;
use Hyde\Pages\MarkdownPage;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\File;

use function mkdir;

/**
* Test the overall functionality of the configurable source roots feature.
*
Expand Down
2 changes: 0 additions & 2 deletions packages/framework/tests/Feature/HydeExtensionFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
use InvalidArgumentException;
use stdClass;

use function app;

/**
* Tests the Extensions API Feature on a higher level to ensure the components work together.
*
Expand Down
9 changes: 0 additions & 9 deletions packages/framework/tests/Feature/HydeServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

namespace Hyde\Framework\Testing\Feature;

use function app;
use function array_map;
use function basename;
use function config;
use function get_class;
use function glob;

use Hyde\Console\ConsoleServiceProvider;
use Hyde\Framework\HydeServiceProvider;
use Hyde\Framework\Services\AssetService;
Expand All @@ -25,8 +18,6 @@
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Artisan;

use function method_exists;

/**
* @covers \Hyde\Framework\HydeServiceProvider
* @covers \Hyde\Framework\Concerns\RegistersFileLocations
Expand Down
4 changes: 0 additions & 4 deletions packages/framework/tests/Feature/NavigationMenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

use BadMethodCallException;
use Hyde\Support\Models\Route;

use function collect;
use function config;

use Hyde\Foundation\Facades\Routes;
use Hyde\Framework\Features\Navigation\DropdownNavItem;
use Hyde\Framework\Features\Navigation\NavigationMenu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@

namespace Hyde\Framework\Testing\Feature\Services;

use function app;
use function config;

use Hyde\Framework\Features\Documentation\SemanticDocumentationArticle;
use Hyde\Pages\DocumentationPage;
use Hyde\Testing\TestCase;
use Illuminate\Support\HtmlString;

use function str_replace;
use function view;

/**
* @covers \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle
*/
Expand Down
6 changes: 0 additions & 6 deletions packages/framework/tests/Feature/SidebarViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
use Illuminate\Contracts\View\View;
use Throwable;

use function config;
use function file_put_contents;
use function realpath;
use function view;
use function e;

/**
* Very high level test of the sidebar views and their combinations of layouts.
*
Expand Down
2 changes: 0 additions & 2 deletions packages/framework/tests/Feature/TypedConfigFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use TypeError;
use stdClass;

use function config;

/**
* @covers \Hyde\Facades\Config
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
use Hyde\Foundation\Facades\Routes;
use Hyde\Framework\Actions\StaticPageBuilder;
use Hyde\Framework\Actions\CreatesNewMarkdownPostFile;

use function config;

use Hyde\Framework\Concerns\InteractsWithDirectories;
use Hyde\Hyde;
use Hyde\Testing\TestCase;
Expand Down
11 changes: 0 additions & 11 deletions packages/framework/tests/Unit/SchemaContractsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@
use Hyde\Testing\UnitTestCase;
use Illuminate\Support\Str;

use function array_filter;
use function array_map;
use function array_merge;
use function array_values;
use function basename;
use function defined;
use function file_get_contents;
use function glob;
use function is_subclass_of;
use function substr_count;

/**
* A state test to ensure the schemas can't be changed without breaking the tests.
* This requires contributors to consider the impact of their changes as schema changes are rarely backwards compatible.
Expand Down
7 changes: 0 additions & 7 deletions packages/framework/tests/Unit/Views/FeaturedImageViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@

namespace Hyde\Framework\Testing\Unit\Views;

use function array_merge;

use Hyde\Framework\Factories\FeaturedImageFactory;
use Hyde\Framework\Features\Blogging\Models\FeaturedImage;
use Hyde\Markdown\Models\FrontMatter;
use Hyde\Pages\MarkdownPost;
use Hyde\Testing\TestCase;

use function str_replace;
use function strip_tags;
use function trim;
use function view;

/**
* @see resources/views/components/post/image.blade.php
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
namespace Hyde\Framework\Testing\Unit\Views;

use Hyde\Facades\Filesystem;

use function config;

use Hyde\Facades\Asset;
use Hyde\Hyde;
use Hyde\Support\Facades\Render;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use Hyde\Publications\Concerns\PublicationFieldTypes;
use Hyde\Publications\Actions\CreatesNewPublicationPage;

use function file_get_contents;

/**
* @covers \Hyde\Publications\Actions\CreatesNewPublicationPage
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Hyde\Publications\Testing\Feature;

use function file_get_contents;

use Hyde\Facades\Filesystem;
use Hyde\Hyde;
use Hyde\Publications\Actions\CreatesNewPublicationType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@

namespace Hyde\Publications\Testing\Feature;

use function array_merge;
use function file_get_contents;
use function file_put_contents;

use Hyde\Facades\Filesystem;
use Hyde\Hyde;
use Hyde\Publications\Commands\Helpers\InputStreamHandler;
use Hyde\Testing\TestCase;
use Illuminate\Support\Carbon;

use function json_encode;

/**
* @covers \Hyde\Publications\Commands\MakePublicationCommand
* @covers \Hyde\Publications\Actions\CreatesNewPublicationPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
use Hyde\Support\Facades\Render;
use Hyde\Testing\TestCase;

use function file_get_contents;
use function file_put_contents;
use function json_decode;
use function json_encode;

/**
* @covers \Hyde\Publications\Actions\PublicationPageCompiler
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/publications/tests/Feature/PublicationPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Hyde\Support\Models\Route;
use Hyde\Testing\TestCase;

use function file_put_contents;

/**
* @covers \Hyde\Publications\Pages\PublicationPage
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use Hyde\Testing\TestCase;
use Illuminate\Support\Collection;

use function file_put_contents;

/**
* @covers \Hyde\Publications\Publications
* @covers \Hyde\Publications\PublicationsExtension
Expand Down
3 changes: 0 additions & 3 deletions packages/publications/tests/Feature/PublicationTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
use Illuminate\Support\ItemNotFoundException;
use RuntimeException;

use function array_merge;
use function array_reverse;

/**
* @covers \Hyde\Publications\Models\PublicationType
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Hyde\Publications\Testing\Feature;

use function glob;

use Hyde\Hyde;
use Hyde\Publications\Models\PublicationType;
use Hyde\Testing\TestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
use Hyde\Publications\Concerns\PublicationFieldTypes;
use Hyde\Publications\Actions\CreatesNewPublicationType;

use function range;
use function collect;

/**
* Tests that publication pages are compiled properly when building the static site.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Hyde\Publications\Testing\Feature;

use function file_put_contents;

use Hyde\Hyde;
use Hyde\Publications\Models\PublicationType;
use Hyde\Testing\TestCase;
Expand Down
3 changes: 0 additions & 3 deletions packages/publications/tests/Feature/ValidatingCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
use Mockery;
use PHPUnit\Framework\ExpectationFailedException;
use RuntimeException;

use function str_starts_with;

use Symfony\Component\Console\Question\ChoiceQuestion;

/**
Expand Down

0 comments on commit f68daaf

Please sign in to comment.