From 5a29e17554c1e41300b26e561148b565723f1d5b Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Sun, 2 Feb 2020 16:38:17 +0100 Subject: [PATCH 1/2] Using GitHub Actions for testing --- .github/workflows/run-tests.yml | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..10b997e --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,46 @@ +name: run-tests + +on: [push] + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + php: [7.2, 7.3, 7.4] + laravel: [6.*] + dependency-version: [prefer-lowest, prefer-stable] + + name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php }} + extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv + coverage: xdebug + + - name: Install dependencies + run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: | + mkdir -p build/logs + vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + + - name: Scrutinizer CI + run: | + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover coverage.clover From 0788e2b0d7f0bf02ac22cd56c00e404a6eadeaef Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Sun, 2 Feb 2020 17:23:05 +0100 Subject: [PATCH 2/2] Updating the package --- .gitattributes | 1 - .travis.yml | 23 ------- README.md | 5 +- composer.json | 2 +- src/Bases/MetaCollection.php | 24 ++++--- src/Contracts/Entities/Analytics.php | 7 +- src/Contracts/Entities/Description.php | 14 ++-- src/Contracts/Entities/Keywords.php | 18 +++-- src/Contracts/Entities/MetaCollection.php | 15 +++-- src/Contracts/Entities/MiscTags.php | 18 +++-- src/Contracts/Entities/OpenGraph.php | 25 ++++--- src/Contracts/Entities/Title.php | 30 +++++---- src/Contracts/Entities/TwitterCard.php | 25 ++++--- src/Contracts/Entities/Webmasters.php | 12 ++-- src/Contracts/Helpers/Meta.php | 14 ++-- src/Contracts/Renderable.php | 6 +- src/Contracts/SeoHelper.php | 32 +++++---- src/Contracts/SeoMeta.php | 62 ++++++++++-------- src/Contracts/SeoOpenGraph.php | 30 +++++---- src/Contracts/SeoTwitter.php | 30 +++++---- src/Entities/Analytics.php | 8 ++- src/Entities/Description.php | 12 ++-- src/Entities/Keywords.php | 22 ++++--- src/Entities/MetaCollection.php | 8 ++- src/Entities/MiscTags.php | 22 ++++--- src/Entities/OpenGraph/Graph.php | 28 ++++---- src/Entities/OpenGraph/MetaCollection.php | 6 +- src/Entities/Title.php | 28 ++++---- src/Entities/Twitter/Card.php | 58 +++++++++-------- src/Entities/Twitter/MetaCollection.php | 6 +- src/Entities/Webmasters.php | 6 +- src/Exceptions/InvalidArgumentException.php | 6 +- .../InvalidTwitterCardException.php | 6 +- src/Exceptions/SeoHelperException.php | 6 +- src/Helpers/Meta.php | 13 ++-- src/SeoHelper.php | 44 +++++++------ src/SeoHelperServiceProvider.php | 6 +- src/SeoMeta.php | 28 ++++---- src/SeoOpenGraph.php | 34 +++++----- src/SeoTwitter.php | 56 ++++++++-------- src/Traits/Seoable.php | 6 +- tests/Asserts/AssertsHtmlStrings.php | 18 +++-- tests/Entities/AnalyticsTest.php | 12 ++-- tests/Entities/DescriptionTest.php | 32 +++++---- tests/Entities/KeywordsTest.php | 22 ++++--- tests/Entities/MetaCollectionTest.php | 14 ++-- tests/Entities/MiscTagsTest.php | 23 ++++--- tests/Entities/OpenGraph/GraphTest.php | 30 +++++---- tests/Entities/TitleTest.php | 65 ++++++++++--------- tests/Entities/Twitter/CardTest.php | 35 +++++----- tests/Entities/WebmastersTest.php | 16 +++-- tests/Helpers/MetaTest.php | 31 +++++---- tests/SeoHelperServiceProviderTest.php | 10 ++- tests/SeoHelperTest.php | 38 ++++++----- tests/SeoMetaTest.php | 28 ++++---- tests/SeoOpenGraphTest.php | 34 +++++----- tests/SeoTwitterTest.php | 28 ++++---- tests/Stubs/Dummy.php | 6 +- tests/TestCase.php | 26 +++----- tests/Traits/SeoableTest.php | 20 +++--- 60 files changed, 746 insertions(+), 544 deletions(-) delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index 7ccb1f3..22f739a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,6 +7,5 @@ .gitattributes export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore -.travis.yml export-ignore phpunit.xml.dist export-ignore CONTRIBUTING.md export-ignore diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3d5c231..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - - nightly - -matrix: - allow_failures: - - php: nightly - -before_script: - - travis_retry composer self-update - - travis_retry composer install --prefer-source --no-interaction --dev - -script: - - composer validate - - mkdir -p build/logs - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/README.md b/README.md index ca49ec5..d62cc39 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SEO Helper [![Packagist License][badge_license]](LICENSE.md) [![For PHP][badge_php]][link-github-repo] -[![Travis Status][badge_build]][link-travis] +[![Github Workflow Status][badge_build]][link-github-status] [![Coverage Status][badge_coverage]][link-scrutinizer] [![Scrutinizer Code Quality][badge_quality]][link-scrutinizer] [![SensioLabs Insight][badge_insight]][link-insight] @@ -51,7 +51,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. [badge_php]: https://img.shields.io/badge/PHP-Framework%20agnostic-4F5B93.svg?style=flat-square [badge_license]: https://img.shields.io/packagist/l/arcanedev/seo-helper.svg?style=flat-square -[badge_build]: https://img.shields.io/travis/ARCANEDEV/SEO-Helper.svg?style=flat-square +[badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/SEO-Helper/run-tests?style=flat-square [badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/SEO-Helper.svg?style=flat-square [badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/SEO-Helper.svg?style=flat-square [badge_insight]: https://img.shields.io/sensiolabs/i/73e1a779-7ca7-4a75-b6d3-452d7852187e.svg?style=flat-square @@ -62,6 +62,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. [link-author]: https://github.com/arcanedev-maroc [link-github-repo]: https://github.com/ARCANEDEV/SEO-Helper +[link-github-status]: https://github.com/ARCANEDEV/SEO-Helper/actions [link-github-issues]: https://github.com/ARCANEDEV/SEO-Helper/issues [link-contributors]: https://github.com/ARCANEDEV/SEO-Helper/graphs/contributors [link-packagist]: https://packagist.org/packages/arcanedev/seo-helper diff --git a/composer.json b/composer.json index cc0a36d..596b8ee 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": ">=7.2.0", "arcanedev/php-html": "^3.0", - "arcanedev/support": "^5.0" + "arcanedev/support": "^5.1" }, "require-dev": { "ext-dom": "*", diff --git a/src/Bases/MetaCollection.php b/src/Bases/MetaCollection.php index b557437..a033001 100644 --- a/src/Bases/MetaCollection.php +++ b/src/Bases/MetaCollection.php @@ -1,4 +1,8 @@ -content = array_map(function ($keyword) { return $this->clean($keyword); - }, $content); + }, (array) $content); return $this; } @@ -111,7 +113,7 @@ public function set($content) * * @param array|string $keywords * - * @return self + * @return $this */ public static function make($keywords) { @@ -123,7 +125,7 @@ public static function make($keywords) * * @param string $keyword * - * @return self + * @return $this */ public function add($keyword) { @@ -137,7 +139,7 @@ public function add($keyword) * * @param array $keywords * - * @return self + * @return $this */ public function addMany(array $keywords) { diff --git a/src/Entities/MetaCollection.php b/src/Entities/MetaCollection.php index e706938..b3afb4c 100644 --- a/src/Entities/MetaCollection.php +++ b/src/Entities/MetaCollection.php @@ -1,4 +1,8 @@ -images) == 1) { - $this->addMeta('image', $this->images[0]); - - return; - } - - foreach ($this->images as $number => $url) { - $this->addMeta("image{$number}", $url); - } - } - /** * Reset the card. * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ public function reset() { @@ -319,6 +307,22 @@ private function checkSite(string &$site): void | ----------------------------------------------------------------- */ + /** + * Render card images. + */ + private function loadImages(): void + { + if (count($this->images) == 1) { + $this->addMeta('image', $this->images[0]); + + return; + } + + foreach ($this->images as $number => $url) { + $this->addMeta("image{$number}", $url); + } + } + /** * Prepare username. * diff --git a/src/Entities/Twitter/MetaCollection.php b/src/Entities/Twitter/MetaCollection.php index b9632b9..b1a42d3 100644 --- a/src/Entities/Twitter/MetaCollection.php +++ b/src/Entities/Twitter/MetaCollection.php @@ -1,4 +1,8 @@ -setSeoMeta($seoMeta); $this->setSeoOpenGraph($seoOpenGraph); @@ -82,7 +86,7 @@ public function meta() * * @param \Arcanedev\SeoHelper\Contracts\SeoMeta $seoMeta * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setSeoMeta(SeoMetaContract $seoMeta) { @@ -118,7 +122,7 @@ public function og() * * @param \Arcanedev\SeoHelper\Contracts\SeoOpenGraph $seoOpenGraph * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setSeoOpenGraph(SeoOpenGraphContract $seoOpenGraph) { @@ -142,7 +146,7 @@ public function twitter() * * @param \Arcanedev\SeoHelper\Contracts\SeoTwitter $seoTwitter * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setSeoTwitter(SeoTwitterContract $seoTwitter) { @@ -158,7 +162,7 @@ public function setSeoTwitter(SeoTwitterContract $seoTwitter) * @param string|null $siteName * @param string|null $separator * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setTitle($title, $siteName = null, $separator = null) { @@ -229,7 +233,7 @@ public function setDescription($description) * * @param array|string $keywords * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setKeywords($keywords) { @@ -243,7 +247,7 @@ public function setKeywords($keywords) * * @param string $imageUrl * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setImage($imageUrl) { @@ -255,10 +259,10 @@ public function setImage($imageUrl) /** * Set the current URL. - * + * * @param string $url * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setUrl($url) { @@ -312,7 +316,7 @@ public function __toString() /** * Enable the OpenGraph. * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function enableOpenGraph() { @@ -324,7 +328,7 @@ public function enableOpenGraph() /** * Disable the OpenGraph. * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function disableOpenGraph() { @@ -336,7 +340,7 @@ public function disableOpenGraph() /** * Enable the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function enableTwitter() { @@ -348,7 +352,7 @@ public function enableTwitter() /** * Disable the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function disableTwitter() { diff --git a/src/SeoHelperServiceProvider.php b/src/SeoHelperServiceProvider.php index 0083d4d..eb7cdc3 100644 --- a/src/SeoHelperServiceProvider.php +++ b/src/SeoHelperServiceProvider.php @@ -1,4 +1,8 @@ -title( new Entities\Title($this->getConfig('title', [])) @@ -289,7 +295,7 @@ public function setTitle($title, $siteName = null, $separator = null) * * @param string $siteName * - * @return self + * @return $this */ public function setSiteName($siteName) { @@ -313,7 +319,7 @@ public function hideSiteName() /** * Show site name. * - * @return self + * @return $this */ public function showSiteName() { diff --git a/src/SeoOpenGraph.php b/src/SeoOpenGraph.php index 5fadb71..7059444 100644 --- a/src/SeoOpenGraph.php +++ b/src/SeoOpenGraph.php @@ -1,4 +1,8 @@ -enabled = $enabled; - - return $this; - } - /** * Set the Open Graph instance. * @@ -246,6 +236,20 @@ public function addProperty($property, $content) return $this; } + /** + * Set the enabled status for the OpenGraph. + * + * @param bool $enabled + * + * @return \Arcanedev\SeoHelper\SeoOpenGraph + */ + private function setEnabled(bool $enabled) + { + $this->enabled = $enabled; + + return $this; + } + /* ----------------------------------------------------------------- | Main Methods | ----------------------------------------------------------------- diff --git a/src/SeoTwitter.php b/src/SeoTwitter.php index 3140074..4d3482c 100644 --- a/src/SeoTwitter.php +++ b/src/SeoTwitter.php @@ -1,4 +1,8 @@ -enabled = (bool) $enabled; - - return $this; - } - /** * Set the Twitter Card instance. * * @param \Arcanedev\SeoHelper\Contracts\Entities\TwitterCard $card * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setCard(CardContract $card) { @@ -98,7 +88,7 @@ public function setCard(CardContract $card) * * @param string $type * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setType($type) { @@ -112,7 +102,7 @@ public function setType($type) * * @param string $site * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setSite($site) { @@ -126,7 +116,7 @@ public function setSite($site) * * @param string $title * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setTitle($title) { @@ -140,7 +130,7 @@ public function setTitle($title) * * @param string $description * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setDescription($description) { @@ -154,7 +144,7 @@ public function setDescription($description) * * @param string $url * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function addImage($url) { @@ -168,7 +158,7 @@ public function addImage($url) * * @param array $metas * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function addMetas(array $metas) { @@ -183,7 +173,7 @@ public function addMetas(array $metas) * @param string $name * @param string $content * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function addMeta($name, $content) { @@ -192,6 +182,20 @@ public function addMeta($name, $content) return $this; } + /** + * Set the enabled status for the Twitter Card. + * + * @param bool $enabled + * + * @return $this + */ + private function setEnabled(bool $enabled) + { + $this->enabled = $enabled; + + return $this; + } + /* ----------------------------------------------------------------- | Main Methods | ----------------------------------------------------------------- @@ -200,7 +204,7 @@ public function addMeta($name, $content) /** * Reset the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function reset() { @@ -232,7 +236,7 @@ public function __toString() /** * Enable the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function enable() { @@ -242,7 +246,7 @@ public function enable() /** * Disable the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function disable() { diff --git a/src/Traits/Seoable.php b/src/Traits/Seoable.php index a4d54fb..a86d6df 100644 --- a/src/Traits/Seoable.php +++ b/src/Traits/Seoable.php @@ -1,4 +1,8 @@ -loadHTML(preg_replace('/>\s+<', $html)); diff --git a/tests/Entities/AnalyticsTest.php b/tests/Entities/AnalyticsTest.php index f79eed8..a214dd6 100644 --- a/tests/Entities/AnalyticsTest.php +++ b/tests/Entities/AnalyticsTest.php @@ -1,4 +1,8 @@ -analytics = new Analytics; @@ -67,7 +71,7 @@ public function it_must_render_empty_on_init() } /** @test */ - public function it_can_render() + public function it_can_render(): void { $expectations = [ ''; @@ -121,7 +126,7 @@ public function it_can_clean_and_render() } /** @test */ - public function it_can_make_meta_with_custom_name_property() + public function it_can_make_meta_with_custom_name_property(): void { $meta = Meta::make('title', 'Hello World', 'property', 'og:'); @@ -132,7 +137,7 @@ public function it_can_make_meta_with_custom_name_property() } /** @test */ - public function it_can_set_name_property() + public function it_can_set_name_property(): void { $meta = Meta::make('title', 'Hello World'); @@ -146,25 +151,25 @@ public function it_can_set_name_property() } /** @test */ - public function it_must_throw_an_invalid_argument_exception_on_invalid_type() + public function it_must_throw_an_invalid_argument_exception_on_invalid_type(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The meta name property is must be a string value, NULL is given.'); Meta::make('title', 'Hello World')->setNameProperty(null); } /** @test */ - public function it_must_throw_an_invalid_argument_exception_on_not_allowed_name() + public function it_must_throw_an_invalid_argument_exception_on_not_allowed_name(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The meta name property [foo] is not supported, the allowed name properties are ['charset', 'http-equiv', 'itemprop', 'name', 'property']."); Meta::make('title', 'Hello World')->setNameProperty('foo'); } /** @test */ - public function it_can_render_array_content() + public function it_can_render_array_content(): void { $meta = Meta::make('locale:alternate', ['fr_FR', 'es_ES', 'en_GB']); diff --git a/tests/SeoHelperServiceProviderTest.php b/tests/SeoHelperServiceProviderTest.php index 0f340af..5f6fec7 100644 --- a/tests/SeoHelperServiceProviderTest.php +++ b/tests/SeoHelperServiceProviderTest.php @@ -1,4 +1,8 @@ -seoHelper = seo_helper(); $expectations = [ @@ -72,7 +76,7 @@ public function it_can_be_instantiated_with_helper() } /** @test */ - public function it_can_get_seo_meta() + public function it_can_get_seo_meta(): void { $seoMeta = $this->seoHelper->meta(); @@ -88,7 +92,7 @@ public function it_can_get_seo_meta() } /** @test */ - public function it_can_get_seo_open_graph() + public function it_can_get_seo_open_graph(): void { $ogs = [ $this->seoHelper->openGraph(), @@ -109,7 +113,7 @@ public function it_can_get_seo_open_graph() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $title = 'Hello World'; $siteName = 'ARCANEDEV'; @@ -130,7 +134,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_site_name() + public function it_can_set_and_render_site_name(): void { $title = 'My Application'; $siteName = 'ARCANEDEV'; @@ -151,7 +155,7 @@ public function it_can_set_and_render_site_name() } /** @test */ - public function it_can_toggle_site_name_visibility() + public function it_can_toggle_site_name_visibility(): void { $title = 'My Application'; $siteName = 'ARCANEDEV'; @@ -179,7 +183,7 @@ public function it_can_toggle_site_name_visibility() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $description = 'ARCANEDEV super description'; $expectations = [ @@ -197,7 +201,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_set_and_render_keywords() + public function it_can_set_and_render_keywords(): void { $keywords = $this->getSeoHelperConfig('keywords.default'); $expected = ''; @@ -214,7 +218,7 @@ public function it_can_set_and_render_keywords() } /** @test */ - public function it_can_set_and_render_image() + public function it_can_set_and_render_image(): void { $this->seoHelper->setImage($imageUrl = 'http://localhost/assets/img/logo.png'); @@ -229,9 +233,9 @@ public function it_can_set_and_render_image() static::assertStringContainsString($expected, $rendered); } } - + /** @test */ - public function it_can_set_and_render_url() + public function it_can_set_and_render_url(): void { $this->seoHelper->setUrl($url = 'http://localhost/path'); @@ -248,7 +252,7 @@ public function it_can_set_and_render_url() } /** @test */ - public function it_can_render_all() + public function it_can_render_all(): void { $output = $this->seoHelper->render(); @@ -256,7 +260,7 @@ public function it_can_render_all() } /** @test */ - public function it_can_render_all_with_html_string_object() + public function it_can_render_all_with_html_string_object(): void { $output = $this->seoHelper->renderHtml(); @@ -265,7 +269,7 @@ public function it_can_render_all_with_html_string_object() } /** @test */ - public function it_can_enable_and_disable_open_graph() + public function it_can_enable_and_disable_open_graph(): void { $needle = 'seoMeta = $this->app[SeoMetaContract::class]; @@ -73,7 +77,7 @@ public function it_can_be_instantiated_by_container() } /** @test */ - public function it_can_set_and_get_and_render_title() + public function it_can_set_and_get_and_render_title(): void { $title = 'Awesome Title'; $siteName = $this->getSeoHelperConfig('title.site-name'); @@ -118,7 +122,7 @@ public function it_can_set_and_get_and_render_title() } /** @test */ - public function it_can_set_and_get_and_render_description() + public function it_can_set_and_get_and_render_description(): void { $description = 'Awesome Description'; $this->seoMeta->setDescription($description); @@ -143,7 +147,7 @@ public function it_can_set_and_get_and_render_description() } /** @test */ - public function it_can_set_and_get_and_render_keywords() + public function it_can_set_and_get_and_render_keywords(): void { $keywords = ['keyword-1', 'keyword-2', 'keyword-3', 'keyword-4', 'keyword-5']; @@ -183,7 +187,7 @@ public function it_can_set_and_get_and_render_keywords() } /** @test */ - public function it_can_add_one_keyword() + public function it_can_add_one_keyword(): void { $keywords = ['keyword-1', 'keyword-2', 'keyword-3', 'keyword-4', 'keyword-5']; $this->seoMeta->setKeywords($keywords); @@ -203,7 +207,7 @@ public function it_can_add_one_keyword() } /** @test */ - public function it_can_add_many_keywords() + public function it_can_add_many_keywords(): void { $keywords = ['keyword-1', 'keyword-2', 'keyword-3', 'keyword-4', 'keyword-5']; $expected = ''; @@ -223,7 +227,7 @@ public function it_can_add_many_keywords() } /** @test */ - public function it_can_add_remove_reset_and_render_a_misc_tag() + public function it_can_add_remove_reset_and_render_a_misc_tag(): void { $expectations = [ '', @@ -306,7 +310,7 @@ public function it_can_add_remove_reset_and_render_a_misc_tag() } /** @test */ - public function it_can_render_add_reset_webmasters() + public function it_can_render_add_reset_webmasters(): void { $expectations = [ '', @@ -350,7 +354,7 @@ public function it_can_render_add_reset_webmasters() } /** @test */ - public function it_can_set_and_render_google_analytics() + public function it_can_set_and_render_google_analytics(): void { static::assertStringContainsString( "ga('create', 'UA-12345678-9', 'auto');", @@ -386,7 +390,7 @@ public function it_can_set_and_render_google_analytics() * * @param \Arcanedev\SeoHelper\Contracts\Entities\MetaCollection $metas */ - protected static function assertMetaCollection($metas) + protected static function assertMetaCollection($metas): void { $expectations = [ \Arcanedev\SeoHelper\Contracts\Entities\MetaCollection::class, diff --git a/tests/SeoOpenGraphTest.php b/tests/SeoOpenGraphTest.php index 7dcdd8d..6d9dfb1 100644 --- a/tests/SeoOpenGraphTest.php +++ b/tests/SeoOpenGraphTest.php @@ -1,4 +1,8 @@ -', @@ -73,7 +77,7 @@ public function it_can_render_defaults() } /** @test */ - public function it_can_set_and_render_prefix() + public function it_can_set_and_render_prefix(): void { $this->seoOpenGraph->setPrefix('open-graph:'); @@ -90,7 +94,7 @@ public function it_can_set_and_render_prefix() } /** @test */ - public function it_can_set_and_render_type() + public function it_can_set_and_render_type(): void { $types = [ 'article', @@ -110,7 +114,7 @@ public function it_can_set_and_render_type() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $title = 'Hello World'; @@ -123,7 +127,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $description = 'Hello World detailed description.'; @@ -136,7 +140,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_set_and_render_url() + public function it_can_set_and_render_url(): void { $url = 'http://www.imdb.com/title/tt0080339/'; @@ -149,7 +153,7 @@ public function it_can_set_and_render_url() } /** @test */ - public function it_can_set_and_render_image() + public function it_can_set_and_render_image(): void { $image = 'http://ia.media-imdb.com/images/M/MV5BNDU2MjE4MTcwNl5BMl5BanBnXkFtZTgwNDExOTMxMDE@._V1_UY1200_CR90,0,630,1200_AL_.jpg'; @@ -162,7 +166,7 @@ public function it_can_set_and_render_image() } /** @test */ - public function it_can_set_and_render_site_name() + public function it_can_set_and_render_site_name(): void { $siteName = 'My site name'; @@ -175,7 +179,7 @@ public function it_can_set_and_render_site_name() } /** @test */ - public function it_can_add_and_render_property() + public function it_can_add_and_render_property(): void { $locales = [ 'ar', 'en', 'en_US', 'es', 'fr', 'fr_FR', @@ -192,7 +196,7 @@ public function it_can_add_and_render_property() } /** @test */ - public function it_can_add_render_properties() + public function it_can_add_render_properties(): void { $properties = [ 'locale' => 'en_GB', @@ -214,7 +218,7 @@ public function it_can_add_render_properties() } /** @test */ - public function it_can_enable_and_disable() + public function it_can_enable_and_disable(): void { static::assertTrue($this->seoOpenGraph->isEnabled()); static::assertFalse($this->seoOpenGraph->isDisabled()); @@ -234,7 +238,7 @@ public function it_can_enable_and_disable() } /** @test */ - public function it_can_set_and_render_locale_property() + public function it_can_set_and_render_locale_property(): void { $locales = ['fr_FR', 'en_GB', 'es_ES']; @@ -247,7 +251,7 @@ public function it_can_set_and_render_locale_property() } /** @test */ - public function it_can_set_and_render_alternative_properties() + public function it_can_set_and_render_alternative_properties(): void { $this->seoOpenGraph->setAlternativeLocales(['fr_FR', 'en_GB', 'es_ES']); diff --git a/tests/SeoTwitterTest.php b/tests/SeoTwitterTest.php index df61316..ba67e81 100644 --- a/tests/SeoTwitterTest.php +++ b/tests/SeoTwitterTest.php @@ -1,4 +1,8 @@ -seoTwitter->render(); @@ -74,7 +78,7 @@ public function it_can_render_defaults() } /** @test */ - public function it_can_set_and_render_type() + public function it_can_set_and_render_type(): void { $this->seoTwitter->setType('app'); @@ -85,7 +89,7 @@ public function it_can_set_and_render_type() } /** @test */ - public function it_can_set_and_render_site() + public function it_can_set_and_render_site(): void { $this->seoTwitter->setSite('Arcanedev'); @@ -96,7 +100,7 @@ public function it_can_set_and_render_site() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $this->seoTwitter->setTitle('ARCANEDEV super title'); @@ -107,7 +111,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $this->seoTwitter->setDescription('ARCANEDEV super description'); @@ -118,7 +122,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_add_and_render_image() + public function it_can_add_and_render_image(): void { $this->seoTwitter->addImage('http://example.com/img/avatar.png'); @@ -129,7 +133,7 @@ public function it_can_add_and_render_image() } /** @test */ - public function it_can_reset_card() + public function it_can_reset_card(): void { $expected = $this->seoTwitter->render(); @@ -146,7 +150,7 @@ public function it_can_reset_card() } /** @test */ - public function it_can_add_and_render_a_meta() + public function it_can_add_and_render_a_meta(): void { $this->seoTwitter->addMeta('creator', '@Arcanedev'); @@ -157,7 +161,7 @@ public function it_can_add_and_render_a_meta() } /** @test */ - public function it_can_add_and_render_many_metas() + public function it_can_add_and_render_many_metas(): void { $metas = [ 'creator' => '@Arcanedev', @@ -179,7 +183,7 @@ public function it_can_add_and_render_many_metas() } /** @test */ - public function it_can_enable_and_disable() + public function it_can_enable_and_disable(): void { static::assertTrue($this->seoTwitter->isEnabled()); static::assertFalse($this->seoTwitter->isDisabled()); diff --git a/tests/Stubs/Dummy.php b/tests/Stubs/Dummy.php index aa7fde0..fd6c50b 100644 --- a/tests/Stubs/Dummy.php +++ b/tests/Stubs/Dummy.php @@ -1,4 +1,8 @@ -set('seo-helper.keywords', [ @@ -94,7 +84,7 @@ protected function getEnvironmentSetUp($app) /** * Get Config instance. * - * @return \Illuminate\Config\Repository + * @return \Illuminate\Contracts\Config\Repository */ protected function config() { diff --git a/tests/Traits/SeoableTest.php b/tests/Traits/SeoableTest.php index 7e112ef..d37cd9f 100644 --- a/tests/Traits/SeoableTest.php +++ b/tests/Traits/SeoableTest.php @@ -1,4 +1,8 @@ -dummy->seo(); @@ -60,7 +64,7 @@ public function it_can_get_main_helper() } /** @test */ - public function it_can_get_meta_helper() + public function it_can_get_meta_helper(): void { $seoMeta = $this->dummy->seoMeta(); @@ -76,7 +80,7 @@ public function it_can_get_meta_helper() } /** @test */ - public function it_can_get_open_graph_helper() + public function it_can_get_open_graph_helper(): void { $seoOpenGraph = $this->dummy->seoGraph(); @@ -92,7 +96,7 @@ public function it_can_get_open_graph_helper() } /** @test */ - public function it_can_get_twitter_card_helper() + public function it_can_get_twitter_card_helper(): void { $seoTwitter = $this->dummy->seoCard(); $expectations = [ @@ -107,7 +111,7 @@ public function it_can_get_twitter_card_helper() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $title = 'Hello World'; $siteName = 'ARCANEDEV'; @@ -130,7 +134,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $description = 'ARCANEDEV super description'; $expectations = [ @@ -151,7 +155,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_set_and_render_keywords() + public function it_can_set_and_render_keywords(): void { $keywords = $this->getSeoHelperConfig('keywords.default'); $expected = '';