diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index bd3eeae..2d31025 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -12,9 +12,14 @@ jobs: matrix: os: [ubuntu-latest] php: [8.1, 8.0] - laravel: [9.*, 8.*] + laravel: [10.*, 9.*, 8.*] stability: [prefer-stable] + exclude: + - laravel: 10.* + php: 8.0 include: + - laravel: 10.* + testbench: 8.* - laravel: 9.* testbench: 7.* - laravel: 8.* diff --git a/composer.json b/composer.json index c6ce647..0f6bab9 100644 --- a/composer.json +++ b/composer.json @@ -42,14 +42,14 @@ "require-dev": { "gajus/dindent": "^2.0", "phpunit/phpunit": "^9.5", - "orchestra/testbench": "^6.0|^7.0", - "nunomaduro/collision": "^5.10|^6.1", + "orchestra/testbench": "^6.0|^7.0|^8.0", + "nunomaduro/collision": "^5.10|^6.1|^7.0", "roave/security-advisories": "dev-latest", "nunomaduro/larastan": "^1.0|^2.0" }, "require": { "php": "^8.0.2", - "illuminate/support": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0|^10.0", "guzzlehttp/guzzle": "~6.0|~7.0" } } diff --git a/phpstan.neon b/phpstan.neon index 69526d4..6414c24 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,8 +9,6 @@ parameters: # The level 8 is the highest level level: 8 ignoreErrors: - - '#Call to an undefined method Illuminate\\View\\ViewFinderInterface::getPaths\(\).#' - - '#Parameter \#1 $view of function view expects view-string|null, string given.#' # - '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist.#' # - '#Unsafe usage of new static#' excludePaths: diff --git a/tests/BladeTest.php b/tests/BladeTest.php deleted file mode 100644 index 139327c..0000000 --- a/tests/BladeTest.php +++ /dev/null @@ -1,182 +0,0 @@ - 'CDBUGS']); - config(['fathom.environments' => ['testing']]); - } - - /** @test - * @throws RuntimeException - */ - public function the_component_can_be_rendered(): void - { - $expected = <<<'HTML' - -HTML; - $this->assertComponentRenders($expected, ''); - } - - /** @test - * @throws RuntimeException - */ - public function the_component_is_not_rendered_without_site_id(): void - { - config(['fathom.site_id' => null]); - - $this->assertComponentRenders('', ''); - } - - /** @test - * @throws RuntimeException - */ - public function the_component_is_not_rendered_within_wrong_environment(): void - { - config(['fathom.environments' => ['local']]); - - $this->assertComponentRenders('', ''); - } - - /** @test - * @throws RuntimeException - */ - public function the_component_is_not_rendered_if_user_agent_matches(): void - { - config(['fathom.excluded_user_agents' => ['Symfony']]); - - $this->assertComponentRenders('', ''); - } - - /** @test - * @throws RuntimeException - */ - public function the_component_is_not_rendered_if_ip_address_matches(): void - { - config(['fathom.excluded_ip_addresses' => ['127.0.0.1']]); - - $this->assertComponentRenders('', ''); - } - - /** @test - * @throws RuntimeException - */ - public function we_can_specify_domain(): void - { - config(['fathom.domain' => 'lion.phpunit.com']); - - $expected = <<<'HTML' - -HTML; - $this->assertComponentRenders($expected, ''); - } - - /** @test - * @throws RuntimeException - */ - public function we_can_honor_dnt(): void - { - config(['fathom.honor_dnt' => true]); - - $expected = <<<'HTML' - -HTML; - $this->assertComponentRenders($expected, ''); - } - - /** @test - * @throws RuntimeException - */ - public function we_can_disable_auto_tracking(): void - { - config(['fathom.disable_auto_tracking' => true]); - - $expected = <<<'HTML' - -HTML; - $this->assertComponentRenders($expected, ''); - } - - /** @test - * @throws RuntimeException - */ - public function we_can_disable_canonicals(): void - { - config(['fathom.ignore_canonicals' => true]); - - $expected = <<<'HTML' - -HTML; - $this->assertComponentRenders($expected, ''); - } - - /** @test - * @throws RuntimeException - */ - public function we_can_specify_excluded_domains(): void - { - config(['fathom.excluded_domains' => 'localhost']); - - $expected = <<<'HTML' - -HTML; - $this->assertComponentRenders($expected, ''); - } - - /** @test - * @throws RuntimeException - */ - public function we_can_specify_included_domains(): void - { - config(['fathom.included_domains' => 'localhost']); - - $expected = <<<'HTML' - -HTML; - $this->assertComponentRenders($expected, ''); - } - - /** @test - * @throws RuntimeException - */ - public function we_can_set_spa_mode(): void - { - config(['fathom.spa_mode' => 'auto']); - - $expected = <<<'HTML' - -HTML; - $this->assertComponentRenders($expected, ''); - } -} diff --git a/tests/ComponentTestCase.php b/tests/ComponentTestCase.php deleted file mode 100644 index 99c8d26..0000000 --- a/tests/ComponentTestCase.php +++ /dev/null @@ -1,42 +0,0 @@ -artisan('view:clear'); - } - - protected function getPackageProviders($app): array - { - return [LaravelFathomServiceProvider::class]; - } - - /** - * @throws RuntimeException - */ - public function assertComponentRenders(string $expected, string $template, array $data = []): void - { - $indenter = new Indenter(); - $blade = (string) $this->blade($template, $data); - $indented = $indenter->indent($blade); - $cleaned = str_replace( - [' >', "\n/>", ' ', '> ', "\n>"], - ['>', '/>', "\n", ">\n ", '>'], - $indented, - ); - - $this->assertSame($expected, $cleaned); - } -} diff --git a/tests/InteractsWithViews.php b/tests/InteractsWithViews.php deleted file mode 100644 index 5027cd2..0000000 --- a/tests/InteractsWithViews.php +++ /dev/null @@ -1,66 +0,0 @@ -getPaths(), true)) { - ViewFacade::addLocation(sys_get_temp_dir()); - } - - $tempFile = tempnam($tempDirectory, 'laravel-blade').'.blade.php'; - - file_put_contents($tempFile, $template); - - return new TestView(view(Str::before(basename($tempFile), '.blade.php'), $data)); - } - - /** - * Render the given view component. - * - * @param string $componentClass - * @param array $data - * - * @return TestView - */ - protected function component(string $componentClass, array $data = []): TestView - { - $component = $this->app->make($componentClass, $data); - - $view = $component->resolveView(); - - return $view instanceof View - ? new TestView($view->with($component->data())) - : new TestView(view($view, $component->data())); - } - - /** - * Populate the shared view error bag with the given errors. - * - * @param array $errors - * @param string $key - * @return void - */ - protected function withViewErrors(array $errors, $key = 'default') - { - ViewFacade::share('errors', (new ViewErrorBag())->put($key, new MessageBag($errors))); - } -} diff --git a/tests/TestView.php b/tests/TestView.php deleted file mode 100644 index d3cd443..0000000 --- a/tests/TestView.php +++ /dev/null @@ -1,47 +0,0 @@ -view = $view; - $this->rendered = $view->render(); - } - - /** - * Get the string contents of the rendered view. - * - * @return string - */ - public function __toString() - { - return $this->rendered; - } -}