diff --git a/README.md b/README.md index 04f44b90..f47f19ce 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Easily configure which routes to scan, exclude or include specific checks or eve - [Scanning routes](#scanning-routes) - [Scanning a single route](#scanning-a-single-route) - [Scanning routes in an SPA application](#scanning-routes-in-an-spa-application) + - [Throttling](#throttling) - [Scan model urls](#scan-model-urls) - [Saving scans into the database](#saving-scans-into-the-database) - [Listening to events](#listening-to-events) @@ -186,6 +187,17 @@ php artisan seo:scan-url https://vormkracht10.nl --javascript > Note: This command will use Puppeteer to render the page. Make sure that you have Puppeteer installed on your system. You can install Puppeteer by running the following command: `npm install puppeteer`. **At this moment it's only available when scanning single routes.** +### Throttling + +If you want to throttle the requests, you can set the `throttle` option to `true` in the config file. You can also set the amount of requests per minute by setting the `requests_per_minute` option in the config file. + +```php +'throttle' => [ + 'enabled' => false, + 'requests_per_minute' => 10, +], +``` + ### Scan model urls When you have an application where you have a lot of pages which are related to a model, you can save the SEO score to the model. This way you can check the SEO score of a specific page and show it in your application. diff --git a/config/seo.php b/config/seo.php index 2f2b185b..da901155 100644 --- a/config/seo.php +++ b/config/seo.php @@ -90,6 +90,11 @@ 'vapor-ui/*', ], + 'throttle' => [ + 'enabled' => false, + 'requests_per_minute' => null, + ], + /* |-------------------------------------------------------------------------- | Domains (DNS resolving) diff --git a/src/Commands/SeoScan.php b/src/Commands/SeoScan.php index 62927512..3d532abc 100644 --- a/src/Commands/SeoScan.php +++ b/src/Commands/SeoScan.php @@ -94,26 +94,52 @@ public function handle(): int private function calculateScoreForRoutes(): void { $routes = self::getRoutes(); + $throttleEnabled = config('seo.throttle.enabled'); + $maxRequests = config('seo.throttle.requests_per_minute') ?? 'N/A'; + $requestCount = 0; + $startTime = time(); + + if ($throttleEnabled) { + $this->line('Throttling enabled. Maximum requests per minute: '.$maxRequests.''); + sleep(5); + } - $routes->each(function ($path, $name) { + $routes->each(function ($path, $name) use ($throttleEnabled, $maxRequests, &$requestCount, &$startTime) { $this->progress->start(); - $seo = Seo::check(url: route($name), progress: $this->progress, useJavascript: config('seo.javascript')); - - $this->failed += count($seo->getFailedChecks()); - $this->success += count($seo->getSuccessfulChecks()); - $this->routeCount++; + if ($throttleEnabled) { - if (config('seo.database.save')) { - $this->saveScoreToDatabase(seo: $seo, url: route($name)); + if ($requestCount >= $maxRequests) { + $elapsedTime = time() - $startTime; + if ($elapsedTime < 60) { + sleep(60 - $elapsedTime); + } + $requestCount = 0; + $startTime = time(); + } + $requestCount++; } + $this->performSeoCheck($name); $this->progress->finish(); - - $this->logResultToConsole($seo, route($name)); }); } + private function performSeoCheck($name): void + { + $seo = Seo::check(url: route($name), progress: $this->progress, useJavascript: config('seo.javascript')); + + $this->failed += count($seo->getFailedChecks()); + $this->success += count($seo->getSuccessfulChecks()); + $this->routeCount++; + + if (config('seo.database.save')) { + $this->saveScoreToDatabase(seo: $seo, url: route($name)); + } + + $this->logResultToConsole($seo, route($name)); + } + private static function getRoutes(): Collection { $routes = collect(app('router')->getRoutes()->getRoutesByName()) diff --git a/tests/Checks/Configuration/NoFollowCheckTest.php b/tests/Checks/Configuration/NoFollowCheckTest.php index 01fd256b..377755c8 100644 --- a/tests/Checks/Configuration/NoFollowCheckTest.php +++ b/tests/Checks/Configuration/NoFollowCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Configuration\NoFollowCheck; it('can perform the nofollow check with robots tag', function () { - $check = new NoFollowCheck(); - $crawler = new Crawler(); + $check = new NoFollowCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200, ['X-Robots-Tag' => 'nofollow']), @@ -18,8 +18,8 @@ }); it('can perform the nofollow check with robots metatag', function () { - $check = new NoFollowCheck(); - $crawler = new Crawler(); + $check = new NoFollowCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -31,8 +31,8 @@ }); it('can perform the nofollow check with googlebot metatag', function () { - $check = new NoFollowCheck(); - $crawler = new Crawler(); + $check = new NoFollowCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Configuration/NoIndexCheckTest.php b/tests/Checks/Configuration/NoIndexCheckTest.php index cc5ae4ee..c2c6f106 100644 --- a/tests/Checks/Configuration/NoIndexCheckTest.php +++ b/tests/Checks/Configuration/NoIndexCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Configuration\NoIndexCheck; it('can perform the noindex check with robots tag', function () { - $check = new NoIndexCheck(); - $crawler = new Crawler(); + $check = new NoIndexCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200, ['X-Robots-Tag' => 'noindex']), @@ -18,8 +18,8 @@ }); it('can perform the noindex check with robots metatag', function () { - $check = new NoIndexCheck(); - $crawler = new Crawler(); + $check = new NoIndexCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -31,8 +31,8 @@ }); it('can perform the noindex check with googlebot metatag', function () { - $check = new NoIndexCheck(); - $crawler = new Crawler(); + $check = new NoIndexCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Configuration/RobotsCheckTest.php b/tests/Checks/Configuration/RobotsCheckTest.php index 421d6c23..9bf00c4b 100644 --- a/tests/Checks/Configuration/RobotsCheckTest.php +++ b/tests/Checks/Configuration/RobotsCheckTest.php @@ -5,12 +5,12 @@ use Vormkracht10\Seo\Checks\Configuration\RobotsCheck; it('can perform the robots check', function () { - $check = new RobotsCheck(); + $check = new RobotsCheck; Http::fake([ 'vormkracht10.nl/robots.txt' => Http::response('User-agent: Googlebot Disallow: /admin', 200), ]); - $this->assertTrue($check->check(Http::get('vormkracht10.nl'), new Crawler())); + $this->assertTrue($check->check(Http::get('vormkracht10.nl'), new Crawler)); }); diff --git a/tests/Checks/Content/AltTagCheckTest.php b/tests/Checks/Content/AltTagCheckTest.php index f36a5baf..47899820 100644 --- a/tests/Checks/Content/AltTagCheckTest.php +++ b/tests/Checks/Content/AltTagCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\AltTagCheck; it('can perform the alt tag check with alt', function () { - $check = new AltTagCheck(); - $crawler = new Crawler(); + $check = new AltTagCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('Vormkracht10 logo', 200), @@ -18,8 +18,8 @@ }); it('can perform the alt tag check without alt', function () { - $check = new AltTagCheck(); - $crawler = new Crawler(); + $check = new AltTagCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -31,8 +31,8 @@ }); it('can perform the alt tag check with empty alt', function () { - $check = new AltTagCheck(); - $crawler = new Crawler(); + $check = new AltTagCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Content/BrokenImageCheckTest.php b/tests/Checks/Content/BrokenImageCheckTest.php index cede01fd..8052a5c5 100644 --- a/tests/Checks/Content/BrokenImageCheckTest.php +++ b/tests/Checks/Content/BrokenImageCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\BrokenImageCheck; it('can perform the broken image check on broken images', function () { - $check = new BrokenImageCheck(); - $crawler = new Crawler(); + $check = new BrokenImageCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -18,8 +18,8 @@ }); it('can perform the broken image check on working images', function () { - $check = new BrokenImageCheck(); - $crawler = new Crawler(); + $check = new BrokenImageCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -31,8 +31,8 @@ }); it('can perform the broken image check on content where no images are used', function () { - $check = new BrokenImageCheck(); - $crawler = new Crawler(); + $check = new BrokenImageCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Content/BrokenLinkCheckTest.php b/tests/Checks/Content/BrokenLinkCheckTest.php index 1c0ba7f1..66025bc5 100644 --- a/tests/Checks/Content/BrokenLinkCheckTest.php +++ b/tests/Checks/Content/BrokenLinkCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\BrokenLinkCheck; it('can perform the broken link check on broken links', function () { - $check = new BrokenLinkCheck(); - $crawler = new Crawler(); + $check = new BrokenLinkCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('Vormkracht10', 200), @@ -18,8 +18,8 @@ }); it('can perform the broken link check on working links', function () { - $check = new BrokenLinkCheck(); - $crawler = new Crawler(); + $check = new BrokenLinkCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('Vormkracht10', 200), @@ -31,8 +31,8 @@ }); it('can perform the broken link check on content where no links are used', function () { - $check = new BrokenLinkCheck(); - $crawler = new Crawler(); + $check = new BrokenLinkCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -44,8 +44,8 @@ }); it('can run the broken link check on a relative url', function () { - $check = new BrokenLinkCheck(); - $crawler = new Crawler(); + $check = new BrokenLinkCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('Vormkracht10', 200), @@ -59,8 +59,8 @@ it('can bypass DNS layers using DNS resolving', function () { $this->markTestSkipped('This test is skipped because we cannot fake DNS resolving.'); - $check = new BrokenLinkCheck(); - $crawler = new Crawler(); + $check = new BrokenLinkCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('Vormkracht10', 200), @@ -76,8 +76,8 @@ }); it('cannot bypass DNS layers using a fake IP when DNS resolving', function () { - $check = new BrokenLinkCheck(); - $crawler = new Crawler(); + $check = new BrokenLinkCheck; + $crawler = new Crawler; config(['seo.resolve' => [ 'vormkracht10.nl' => '8.8.8.8', @@ -93,8 +93,8 @@ }); it('can check if link is broken by checking on configured status codes', function () { - $check = new BrokenLinkCheck(); - $crawler = new Crawler(); + $check = new BrokenLinkCheck; + $crawler = new Crawler; config(['seo.broken_link_check.status_codes' => ['403']]); @@ -108,8 +108,8 @@ }); it('can exclude certain paths from the broken link check', function () { - $check = new BrokenLinkCheck(); - $crawler = new Crawler(); + $check = new BrokenLinkCheck; + $crawler = new Crawler; config(['seo.broken_link_check.exclude_links' => ['https://vormkracht10.nl/excluded']]); diff --git a/tests/Checks/Content/ContentLengthCheckTest.php b/tests/Checks/Content/ContentLengthCheckTest.php index 5426ccad..0c97cb69 100644 --- a/tests/Checks/Content/ContentLengthCheckTest.php +++ b/tests/Checks/Content/ContentLengthCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\ContentLengthCheck; it('can perform the content length check on content with a length of 2100 characters', function () { - $check = new ContentLengthCheck(); - $crawler = new Crawler(); + $check = new ContentLengthCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response( @@ -26,8 +26,8 @@ }); it('can perform the content length check on content with less characters', function () { - $check = new ContentLengthCheck(); - $crawler = new Crawler(); + $check = new ContentLengthCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response( diff --git a/tests/Checks/Content/KeywordInFirstParagraphCheckTest.php b/tests/Checks/Content/KeywordInFirstParagraphCheckTest.php index 59d8de6d..e9b51e56 100644 --- a/tests/Checks/Content/KeywordInFirstParagraphCheckTest.php +++ b/tests/Checks/Content/KeywordInFirstParagraphCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\KeywordInFirstParagraphCheck; it('can perform the keyword in first paragraph check on a page with the keyword in the first paragraph', function () { - $check = new KeywordInFirstParagraphCheck(); - $crawler = new Crawler(); + $check = new KeywordInFirstParagraphCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('

vormkracht10 is a great company that specializes in SEO and Laravel packages.

', 200), @@ -18,8 +18,8 @@ }); it('can perform the keyword in first paragraph check on a page without the keyword in the first paragraph', function () { - $check = new KeywordInFirstParagraphCheck(); - $crawler = new Crawler(); + $check = new KeywordInFirstParagraphCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('

Lorem ipsum dolor sit amet.

', 200), @@ -31,8 +31,8 @@ }); it('can perform the keyword in first paragraph check on a page without keywords', function () { - $check = new KeywordInFirstParagraphCheck(); - $crawler = new Crawler(); + $check = new KeywordInFirstParagraphCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Content/KeywordInTitleCheckTest.php b/tests/Checks/Content/KeywordInTitleCheckTest.php index 3f866d12..ae2c6abb 100644 --- a/tests/Checks/Content/KeywordInTitleCheckTest.php +++ b/tests/Checks/Content/KeywordInTitleCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\KeywordInTitleCheck; it('can perform the keyword in title check on a page with the keyword in the title', function () { - $check = new KeywordInTitleCheck(); - $crawler = new Crawler(); + $check = new KeywordInTitleCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('vormkracht10', 200), @@ -18,8 +18,8 @@ }); it('can perform the keyword in title check on a page without the keyword in the title', function () { - $check = new KeywordInTitleCheck(); - $crawler = new Crawler(); + $check = new KeywordInTitleCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('vormkracht10', 200), @@ -31,8 +31,8 @@ }); it('can perform the keyword in title check on a page without keywords', function () { - $check = new KeywordInTitleCheck(); - $crawler = new Crawler(); + $check = new KeywordInTitleCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Content/MixedContentCheckTest.php b/tests/Checks/Content/MixedContentCheckTest.php index af5a2eec..e6d03411 100644 --- a/tests/Checks/Content/MixedContentCheckTest.php +++ b/tests/Checks/Content/MixedContentCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\MixedContentCheck; it('can perform the mixed content check on content where http is used', function () { - $check = new MixedContentCheck(); - $crawler = new Crawler(); + $check = new MixedContentCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('Vormkracht10', 200), @@ -18,8 +18,8 @@ }); it('can perform the mixed content check on content where https is used', function () { - $check = new MixedContentCheck(); - $crawler = new Crawler(); + $check = new MixedContentCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('Vormkracht10', 200), @@ -31,8 +31,8 @@ }); it('can perform the mixed content check on content where no links are used', function () { - $check = new MixedContentCheck(); - $crawler = new Crawler(); + $check = new MixedContentCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -44,8 +44,8 @@ }); it('can perform the mixed content check on content where https and http is used', function () { - $check = new MixedContentCheck(); - $crawler = new Crawler(); + $check = new MixedContentCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('Vormkracht10Vormkracht10', 200), diff --git a/tests/Checks/Content/MultipleHeadingCheckTest.php b/tests/Checks/Content/MultipleHeadingCheckTest.php index e58ef8df..8df0e53f 100644 --- a/tests/Checks/Content/MultipleHeadingCheckTest.php +++ b/tests/Checks/Content/MultipleHeadingCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\MultipleHeadingCheck; it('can perform the multiple heading check test on no headings', function () { - $check = new MultipleHeadingCheck(); - $crawler = new Crawler(); + $check = new MultipleHeadingCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -18,8 +18,8 @@ }); it('can perform the multiple heading check test on one heading', function () { - $check = new MultipleHeadingCheck(); - $crawler = new Crawler(); + $check = new MultipleHeadingCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('

Heading

', 200), @@ -31,8 +31,8 @@ }); it('can perform the multiple heading check test on multiple headings', function () { - $check = new MultipleHeadingCheck(); - $crawler = new Crawler(); + $check = new MultipleHeadingCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('

Heading

Heading

', 200), diff --git a/tests/Checks/Content/TooLongSentenceCheckTest.php b/tests/Checks/Content/TooLongSentenceCheckTest.php index 550ca22d..4d5f0a23 100644 --- a/tests/Checks/Content/TooLongSentenceCheckTest.php +++ b/tests/Checks/Content/TooLongSentenceCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\TooLongSentenceCheck; it('can perform the too long sentence check on page with too long sentence', function () { - $check = new TooLongSentenceCheck(); - $crawler = new Crawler(); + $check = new TooLongSentenceCheck; + $crawler = new Crawler; $body = 'One two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one.'; $body .= $body; // Needed because we need a ratio of 20% or more. @@ -29,8 +29,8 @@ }); it('can perform the too long sentence check on page with no too long sentence', function () { - $check = new TooLongSentenceCheck(); - $crawler = new Crawler(); + $check = new TooLongSentenceCheck; + $crawler = new Crawler; $body = 'One two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen'; @@ -54,8 +54,8 @@ }); it('can perform the too long sentence check on page with no body', function () { - $check = new TooLongSentenceCheck(); - $crawler = new Crawler(); + $check = new TooLongSentenceCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response( diff --git a/tests/Checks/Content/TransitionWordRatioCheckTest.php b/tests/Checks/Content/TransitionWordRatioCheckTest.php index f77ff821..df9b69f1 100644 --- a/tests/Checks/Content/TransitionWordRatioCheckTest.php +++ b/tests/Checks/Content/TransitionWordRatioCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Content\TransitionWordRatioCheck; it('can perform the transition word ratio check where sentence matches criteria', function () { - $check = new TransitionWordRatioCheck(); - $crawler = new Crawler(); + $check = new TransitionWordRatioCheck; + $crawler = new Crawler; $body = 'This is the first sentence. This is the second sentence, which contains a transition word. This is the third sentence. This is the fourth sentence, which also contains a transition word. This is the fifth sentence.'; @@ -28,8 +28,8 @@ }); it('can perform the transition word ratio check where sentence does not match criteria', function () { - $check = new TransitionWordRatioCheck(); - $crawler = new Crawler(); + $check = new TransitionWordRatioCheck; + $crawler = new Crawler; $body = 'Lorem ipsum. Dolor sit amet. This is the next sentence. Fourth sentence. Fifth sentence.'; @@ -51,8 +51,8 @@ }); it('can perform the transition word ratio check on page without content', function () { - $check = new TransitionWordRatioCheck(); - $crawler = new Crawler(); + $check = new TransitionWordRatioCheck; + $crawler = new Crawler; $body = ''; diff --git a/tests/Checks/Meta/DescriptionCheckTest.php b/tests/Checks/Meta/DescriptionCheckTest.php index 2ff12c54..2dcfbce7 100644 --- a/tests/Checks/Meta/DescriptionCheckTest.php +++ b/tests/Checks/Meta/DescriptionCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Meta\DescriptionCheck; it('can perform the description check on a page with multiple description tags', function () { - $check = new DescriptionCheck(); - $crawler = new Crawler(); + $check = new DescriptionCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -18,8 +18,8 @@ }); it('can perform the description check on a page without any description tags', function () { - $check = new DescriptionCheck(); - $crawler = new Crawler(); + $check = new DescriptionCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Meta/LangCheckTest.php b/tests/Checks/Meta/LangCheckTest.php index 2dba2dc1..4b239b32 100644 --- a/tests/Checks/Meta/LangCheckTest.php +++ b/tests/Checks/Meta/LangCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Meta\LangCheck; it('can perform the lang check on a page with a lang attribute', function () { - $check = new LangCheck(); - $crawler = new Crawler(); + $check = new LangCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -18,8 +18,8 @@ }); it('can perform the lang check on a page without a lang attribute', function () { - $check = new LangCheck(); - $crawler = new Crawler(); + $check = new LangCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Meta/OpenGraphImageCheckTest.php b/tests/Checks/Meta/OpenGraphImageCheckTest.php index d80db5d4..4a232af3 100644 --- a/tests/Checks/Meta/OpenGraphImageCheckTest.php +++ b/tests/Checks/Meta/OpenGraphImageCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Meta\OpenGraphImageCheck; it('can perform open graph image check on a page with a broken open graph image', function () { - $check = new OpenGraphImageCheck(); - $crawler = new Crawler(); + $check = new OpenGraphImageCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -18,8 +18,8 @@ }); it('can perform open graph image check on a page without an open graph image', function () { - $check = new OpenGraphImageCheck(); - $crawler = new Crawler(); + $check = new OpenGraphImageCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -32,8 +32,8 @@ it('can perform open graph image check on a page with a working open graph image', function () { $this->withoutExceptionHandling(); - $check = new OpenGraphImageCheck(); - $crawler = new Crawler(); + $check = new OpenGraphImageCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Meta/TitleLengthCheckTest.php b/tests/Checks/Meta/TitleLengthCheckTest.php index 848a3878..372000e0 100644 --- a/tests/Checks/Meta/TitleLengthCheckTest.php +++ b/tests/Checks/Meta/TitleLengthCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Meta\TitleLengthCheck; it('can perform the title length check on a page with a too long title', function () { - $check = new TitleLengthCheck(); - $crawler = new Crawler(); + $check = new TitleLengthCheck; + $crawler = new Crawler; $title = str_repeat('a', 61); @@ -20,8 +20,8 @@ }); it('can perform the title length check on a page with a short title', function () { - $check = new TitleLengthCheck(); - $crawler = new Crawler(); + $check = new TitleLengthCheck; + $crawler = new Crawler; $title = str_repeat('a', 60); @@ -35,8 +35,8 @@ }); it('can perform the title length check on a page without a title', function () { - $check = new TitleLengthCheck(); - $crawler = new Crawler(); + $check = new TitleLengthCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Performance/CSSSizeCheckTest.php b/tests/Checks/Performance/CSSSizeCheckTest.php index 679931dc..011c6de8 100644 --- a/tests/Checks/Performance/CSSSizeCheckTest.php +++ b/tests/Checks/Performance/CSSSizeCheckTest.php @@ -11,8 +11,8 @@ * we don't have access to the stylesheet in the test. */ it('can perform the CSS size check on a page with a CSS file larger than 15 KB', function () { - $check = new CssSizeCheck(); - $crawler = new Crawler(); + $check = new CssSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -28,8 +28,8 @@ }); it('can perform the CSS size check on a page with a CSS file smaller than 15 KB', function () { - $check = new CssSizeCheck(); - $crawler = new Crawler(); + $check = new CssSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -45,8 +45,8 @@ }); it('can perform the CSS size check on a page with no CSS files', function () { - $check = new CssSizeCheck(); - $crawler = new Crawler(); + $check = new CssSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Performance/CompressionCheckTest.php b/tests/Checks/Performance/CompressionCheckTest.php index c87509a6..c65417b0 100644 --- a/tests/Checks/Performance/CompressionCheckTest.php +++ b/tests/Checks/Performance/CompressionCheckTest.php @@ -5,7 +5,7 @@ use Vormkracht10\Seo\Checks\Performance\CompressionCheck; it('can perform a compression check on a compressed response', function () { - $check = new CompressionCheck(); + $check = new CompressionCheck; $contentEncodings = ['gzip', 'deflate', 'br', 'compress']; @@ -16,16 +16,16 @@ ]), ]); - $this->assertTrue($check->check(Http::get('vormkracht10.nl'), new Crawler())); + $this->assertTrue($check->check(Http::get('vormkracht10.nl'), new Crawler)); } }); it('can perform a compression check on a non-compressed response', function () { - $check = new CompressionCheck(); + $check = new CompressionCheck; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), ]); - $this->assertFalse($check->check(Http::get('vormkracht10.nl'), new Crawler())); + $this->assertFalse($check->check(Http::get('vormkracht10.nl'), new Crawler)); }); diff --git a/tests/Checks/Performance/HTMLSizeCheckTest.php b/tests/Checks/Performance/HTMLSizeCheckTest.php index 6506b7bc..a47ab8a5 100644 --- a/tests/Checks/Performance/HTMLSizeCheckTest.php +++ b/tests/Checks/Performance/HTMLSizeCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Performance\HtmlSizeCheck; it('can perform the HTML size check on HTML that is smaller than 100 KB', function () { - $check = new HtmlSizeCheck(); - $crawler = new Crawler(); + $check = new HtmlSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('abcdefghij', 200), @@ -16,8 +16,8 @@ }); it('can perform the HTML size check on HTML that is larger than 100 KB', function () { - $check = new HtmlSizeCheck(); - $crawler = new Crawler(); + $check = new HtmlSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response(''.str_repeat('abcdefghij', 10000).'', 200), diff --git a/tests/Checks/Performance/ImageSizeCheckTest.php b/tests/Checks/Performance/ImageSizeCheckTest.php index 61849efe..b02623aa 100644 --- a/tests/Checks/Performance/ImageSizeCheckTest.php +++ b/tests/Checks/Performance/ImageSizeCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Performance\ImageSizeCheck; it('can perform the image size check on broken images', function () { - $check = new ImageSizeCheck(); - $crawler = new Crawler(); + $check = new ImageSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -18,8 +18,8 @@ }); it('can perform the image size check on small images', function () { - $check = new ImageSizeCheck(); - $crawler = new Crawler(); + $check = new ImageSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -33,8 +33,8 @@ it('can perform the image size check on large images', function () { $this->markTestSkipped('This test is skipped because we need to find a way to fake the image size.'); - $check = new ImageSizeCheck(); - $crawler = new Crawler(); + $check = new ImageSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Performance/JavascriptSizeCheckTest.php b/tests/Checks/Performance/JavascriptSizeCheckTest.php index 6e2e6119..68954933 100644 --- a/tests/Checks/Performance/JavascriptSizeCheckTest.php +++ b/tests/Checks/Performance/JavascriptSizeCheckTest.php @@ -11,8 +11,8 @@ * we don't have access to the javascript file in the test. */ it('can perform the Javascript size check on a page with a Javascript file larger than 1 MB', function () { - $check = new JavascriptSizeCheck(); - $crawler = new Crawler(); + $check = new JavascriptSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -28,8 +28,8 @@ }); it('can perform the Javascript size check on a page with a Javascript file smaller than 1 MB', function () { - $check = new JavascriptSizeCheck(); - $crawler = new Crawler(); + $check = new JavascriptSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -45,8 +45,8 @@ }); it('can perform the Javascript size check on a page without Javascript files', function () { - $check = new JavascriptSizeCheck(); - $crawler = new Crawler(); + $check = new JavascriptSizeCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), diff --git a/tests/Checks/Performance/ResponeCheckTest.php b/tests/Checks/Performance/ResponeCheckTest.php index 61a4474e..43c91410 100644 --- a/tests/Checks/Performance/ResponeCheckTest.php +++ b/tests/Checks/Performance/ResponeCheckTest.php @@ -5,8 +5,8 @@ use Vormkracht10\Seo\Checks\Performance\ResponseCheck; it('can perform response check on a page with a 200 status code', function () { - $check = new ResponseCheck(); - $crawler = new Crawler(); + $check = new ResponseCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 200), @@ -18,8 +18,8 @@ }); it('can perform response check on a page with a 404 status code', function () { - $check = new ResponseCheck(); - $crawler = new Crawler(); + $check = new ResponseCheck; + $crawler = new Crawler; Http::fake([ 'vormkracht10.nl' => Http::response('', 404), diff --git a/tests/Checks/Performance/TTFBCheckTest.php b/tests/Checks/Performance/TTFBCheckTest.php index 066b9919..079b9af1 100644 --- a/tests/Checks/Performance/TTFBCheckTest.php +++ b/tests/Checks/Performance/TTFBCheckTest.php @@ -7,7 +7,7 @@ it('can perform the ttfb check', function () { $this->markTestSkipped('We can\'t fully rely on this test as we can\'t manually set the ttfb value.'); - $check = new TtfbCheck(); + $check = new TtfbCheck; Http::fake([ 'vormkracht10.nl/robots.txt' => Http::response('', 200), @@ -19,9 +19,9 @@ * is higher than the expected value. If it is, we'll check if the check returns * false. If it doesn't, we'll check if the check returns true. */ - if ($check->check(Http::get('vormkracht10.nl'), new Crawler()) && $check->actualValue > $check->expectedValue) { - $this->assertFalse($check->check(Http::get('vormkracht10.nl'), new Crawler())); + if ($check->check(Http::get('vormkracht10.nl'), new Crawler) && $check->actualValue > $check->expectedValue) { + $this->assertFalse($check->check(Http::get('vormkracht10.nl'), new Crawler)); } else { - $this->assertTrue($check->check(Http::get('vormkracht10.nl'), new Crawler())); + $this->assertTrue($check->check(Http::get('vormkracht10.nl'), new Crawler)); } });