From 4dac4c3a7f7260352abe1fa44954d29deb71b46f Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Thu, 3 Oct 2019 16:43:55 +0100 Subject: [PATCH] Updating the package * Allow to install laravel 6 minor releases * Updating the service provider + defer * Cleaning the code --- .travis.yml | 2 - README.md | 2 +- _docs/0-Home.md | 2 +- _docs/1-Installation-and-Setup.md | 22 ++-- _docs/2-Configuration.md | 114 +++++++++++++++++- composer.json | 10 +- helpers.php | 3 +- src/Entities/Description.php | 8 +- src/Entities/Keywords.php | 4 +- src/Entities/MiscTags.php | 10 +- src/Entities/Title.php | 12 +- src/Entities/Twitter/Card.php | 6 +- src/Entities/Webmasters.php | 4 +- src/Facades/SeoHelper.php | 20 --- src/Facades/SeoMeta.php | 20 --- src/Facades/SeoOpenGraph.php | 20 --- src/Facades/SeoTwitter.php | 20 --- src/Helpers/Meta.php | 16 ++- src/Providers/UtilityServiceProvider.php | 105 ---------------- src/SeoHelperServiceProvider.php | 72 ++++++++--- .../Providers/UtilityServiceProviderTest.php | 71 ----------- tests/SeoHelperServiceProviderTest.php | 8 +- 22 files changed, 223 insertions(+), 328 deletions(-) delete mode 100644 src/Facades/SeoHelper.php delete mode 100644 src/Facades/SeoMeta.php delete mode 100644 src/Facades/SeoOpenGraph.php delete mode 100644 src/Facades/SeoTwitter.php delete mode 100644 src/Providers/UtilityServiceProvider.php delete mode 100644 tests/Providers/UtilityServiceProviderTest.php diff --git a/.travis.yml b/.travis.yml index ed88626..3d5c231 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: php -sudo: false - php: - 7.2 - 7.3 diff --git a/README.md b/README.md index 8438dac..ca49ec5 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/SEO-Helper/re * Easy setup & configuration. * Well documented & IDE Friendly. * Well tested with maximum code quality. - * Laravel `5.0` to `6.0` are supported. + * Laravel `5.x | 6.x` are supported. * Made with :heart: & :coffee:. ## Table of contents diff --git a/_docs/0-Home.md b/_docs/0-Home.md index 9b0e09b..640f932 100644 --- a/_docs/0-Home.md +++ b/_docs/0-Home.md @@ -11,7 +11,7 @@ SEO Helper is a package that provides tools and helpers for SEO (Search Engine O * Easy setup & configuration. * Well documented & IDE Friendly. * Well tested with maximum code quality. - * Laravel `5.0` to `6.0` are supported. + * Laravel `5.x | 6.x` are supported. * Made with :heart: & :coffee:. ## Table of contents diff --git a/_docs/1-Installation-and-Setup.md b/_docs/1-Installation-and-Setup.md index 589c272..85e1d1a 100644 --- a/_docs/1-Installation-and-Setup.md +++ b/_docs/1-Installation-and-Setup.md @@ -19,7 +19,7 @@ | ![SEO-Helper v1.5.x][seo_helper_1_5_x] | ![Laravel v5.6][laravel_5_6] | | ![SEO-Helper v1.6.x][seo_helper_1_6_x] | ![Laravel v5.7][laravel_5_7] | | ![SEO-Helper v1.7.x][seo_helper_1_7_x] | ![Laravel v5.8][laravel_5_8] | -| ![SEO-Helper v2.0.x][seo_helper_2_0_x] | ![Laravel v6.0][laravel_6_0] | +| ![SEO-Helper v2.x][seo_helper_2_x] | ![Laravel v6.x][laravel_6_x] | [laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0" [laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1" @@ -30,16 +30,16 @@ [laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6" [laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7" [laravel_5_8]: https://img.shields.io/badge/v5.8-supported-brightgreen.svg?style=flat-square "Laravel v5.8" -[laravel_6_0]: https://img.shields.io/badge/v6.0-supported-brightgreen.svg?style=flat-square "Laravel v6.0" - -[seo_helper_1_1_x]: https://img.shields.io/badge/version-1.1.*-blue.svg?style=flat-square "SEO-Helper v1.1.*" -[seo_helper_1_2_x]: https://img.shields.io/badge/version-1.2.*-blue.svg?style=flat-square "SEO-Helper v1.2.*" -[seo_helper_1_3_x]: https://img.shields.io/badge/version-1.3.*-blue.svg?style=flat-square "SEO-Helper v1.3.*" -[seo_helper_1_4_x]: https://img.shields.io/badge/version-1.4.*-blue.svg?style=flat-square "SEO-Helper v1.4.*" -[seo_helper_1_5_x]: https://img.shields.io/badge/version-1.5.*-blue.svg?style=flat-square "SEO-Helper v1.5.*" -[seo_helper_1_6_x]: https://img.shields.io/badge/version-1.6.*-blue.svg?style=flat-square "SEO-Helper v1.6.*" -[seo_helper_1_7_x]: https://img.shields.io/badge/version-1.7.*-blue.svg?style=flat-square "SEO-Helper v1.7.*" -[seo_helper_2_0_x]: https://img.shields.io/badge/version-2.0.*-blue.svg?style=flat-square "SEO-Helper v2.0.*" +[laravel_6_x]: https://img.shields.io/badge/v6.x-supported-brightgreen.svg?style=flat-square "Laravel v6.x" + +[seo_helper_1_1_x]: https://img.shields.io/badge/version-1.1.x-blue.svg?style=flat-square "SEO-Helper v1.1.x" +[seo_helper_1_2_x]: https://img.shields.io/badge/version-1.2.x-blue.svg?style=flat-square "SEO-Helper v1.2.x" +[seo_helper_1_3_x]: https://img.shields.io/badge/version-1.3.x-blue.svg?style=flat-square "SEO-Helper v1.3.x" +[seo_helper_1_4_x]: https://img.shields.io/badge/version-1.4.x-blue.svg?style=flat-square "SEO-Helper v1.4.x" +[seo_helper_1_5_x]: https://img.shields.io/badge/version-1.5.x-blue.svg?style=flat-square "SEO-Helper v1.5.x" +[seo_helper_1_6_x]: https://img.shields.io/badge/version-1.6.x-blue.svg?style=flat-square "SEO-Helper v1.6.x" +[seo_helper_1_7_x]: https://img.shields.io/badge/version-1.7.x-blue.svg?style=flat-square "SEO-Helper v1.7.x" +[seo_helper_2_x]: https://img.shields.io/badge/version-2.x-blue.svg?style=flat-square "SEO-Helper v2.x" ## Composer diff --git a/_docs/2-Configuration.md b/_docs/2-Configuration.md index 8e9f4ea..108b8f7 100644 --- a/_docs/2-Configuration.md +++ b/_docs/2-Configuration.md @@ -8,4 +8,116 @@ 4. [API](4-API.md) 5. [Extras](5-Extras.md) -> Coming Soon ... + +```php + [ + 'default' => 'Default Title', + 'site-name' => config('app.name', 'My Application'), + 'separator' => '-', + 'first' => true, + 'max' => 55, + ], + + /* ----------------------------------------------------------------- + | Description + | ----------------------------------------------------------------- + */ + + 'description' => [ + 'default' => 'Default description', + 'max' => 155, + ], + + /* ----------------------------------------------------------------- + | Keywords + | ----------------------------------------------------------------- + */ + + 'keywords' => [ + 'default' => [ + // + ], + ], + + /* ----------------------------------------------------------------- + | Miscellaneous + | ----------------------------------------------------------------- + */ + + 'misc' => [ + 'canonical' => true, + 'robots' => config('app.env') !== 'production', // Tell robots not to index the content if it's not on production + 'default' => [ + 'viewport' => 'width=device-width, initial-scale=1', // Responsive design thing + 'author' => '', // https://plus.google.com/[YOUR PERSONAL G+ PROFILE HERE] + 'publisher' => '', // https://plus.google.com/[YOUR PERSONAL G+ PROFILE HERE] + ], + ], + + /* ----------------------------------------------------------------- + | Webmaster Tools + | ----------------------------------------------------------------- + */ + + 'webmasters' => [ + 'google' => '', + 'bing' => '', + 'alexa' => '', + 'pinterest' => '', + 'yandex' => '', + ], + + /* ----------------------------------------------------------------- + | Open Graph + | ----------------------------------------------------------------- + */ + + 'open-graph' => [ + 'enabled' => true, + 'prefix' => 'og:', + 'type' => 'website', + 'title' => 'Default Open Graph title', + 'description' => 'Default Open Graph description', + 'site-name' => '', + 'properties' => [ + // + ], + ], + + /* ----------------------------------------------------------------- + | Twitter + | ----------------------------------------------------------------- + | Supported card types : 'app', 'gallery', 'photo', 'player', 'product', 'summary', 'summary_large_image'. + */ + + 'twitter' => [ + 'enabled' => true, + 'prefix' => 'twitter:', + 'card' => 'summary', + 'site' => 'Username', + 'title' => 'Default Twitter Card title', + 'metas' => [ + // + ], + ], + + /* ----------------------------------------------------------------- + | Analytics + | ----------------------------------------------------------------- + */ + + 'analytics' => [ + 'google' => '', // UA-XXXXXXXX-X + ], + +]; +``` diff --git a/composer.json b/composer.json index 373e353..cc0a36d 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,14 @@ "license": "MIT", "require": { "php": ">=7.2.0", - "arcanedev/php-html": "~3.0", - "arcanedev/support": "~5.0.0" + "arcanedev/php-html": "^3.0", + "arcanedev/support": "^5.0" }, "require-dev": { "ext-dom": "*", - "orchestra/testbench": "~4.0.0", - "phpunit/phpcov": "~6.0", - "phpunit/phpunit": "~8.0" + "orchestra/testbench": "^4.0", + "phpunit/phpcov": "^6.0", + "phpunit/phpunit": "^8.0" }, "autoload": { "psr-4": { diff --git a/helpers.php b/helpers.php index edd35be..f1f5999 100644 --- a/helpers.php +++ b/helpers.php @@ -8,7 +8,8 @@ * * @return \Arcanedev\SeoHelper\Contracts\SeoHelper */ - function seo_helper() { + function seo_helper(): SeoHelper + { return app(SeoHelper::class); } } diff --git a/src/Entities/Description.php b/src/Entities/Description.php index 95a238a..809f837 100644 --- a/src/Entities/Description.php +++ b/src/Entities/Description.php @@ -31,7 +31,7 @@ class Description implements DescriptionContract * * @var string */ - protected $name = 'description'; + protected $name = 'description'; /** * The meta content. @@ -45,7 +45,7 @@ class Description implements DescriptionContract * * @var int */ - protected $max = 155; + protected $max = 155; /* ----------------------------------------------------------------- | Constructor @@ -182,7 +182,7 @@ public function __toString() * * @return bool */ - private function hasContent() + private function hasContent(): bool { return ! empty($this->get()); } @@ -194,7 +194,7 @@ private function hasContent() * * @throws \Arcanedev\SeoHelper\Exceptions\InvalidArgumentException */ - private function checkMax($max) + private function checkMax($max): void { if ( ! is_int($max)) { throw new InvalidArgumentException( diff --git a/src/Entities/Keywords.php b/src/Entities/Keywords.php index 5578cb8..040cb2c 100644 --- a/src/Entities/Keywords.php +++ b/src/Entities/Keywords.php @@ -183,7 +183,7 @@ public function __toString() * * @return bool */ - private function hasContent() + private function hasContent(): bool { return ! empty($this->getContent()); } @@ -200,7 +200,7 @@ private function hasContent() * * @return string */ - private function clean($value) + private function clean(string $value): string { return trim(strip_tags($value)); } diff --git a/src/Entities/MiscTags.php b/src/Entities/MiscTags.php index 79e9370..1d76b40 100644 --- a/src/Entities/MiscTags.php +++ b/src/Entities/MiscTags.php @@ -207,7 +207,7 @@ public function __toString() * * @return bool */ - private function hasUrl() + private function hasUrl(): bool { return ! empty($this->getUrl()); } @@ -217,7 +217,7 @@ private function hasUrl() * * @return bool */ - private function isCanonicalEnabled() + private function isCanonicalEnabled(): bool { return (bool) $this->getConfig('canonical', false); } @@ -227,7 +227,7 @@ private function isCanonicalEnabled() * * @return bool */ - private function isRobotsEnabled() + private function isRobotsEnabled(): bool { return (bool) $this->getConfig('robots', false); } @@ -242,7 +242,7 @@ private function isRobotsEnabled() * * @return \Arcanedev\SeoHelper\Entities\MiscTags */ - private function addRobotsMeta() + private function addRobotsMeta(): self { if ($this->isRobotsEnabled()) $this->add('robots', 'noindex, nofollow'); @@ -255,7 +255,7 @@ private function addRobotsMeta() * * @return \Arcanedev\SeoHelper\Entities\MiscTags */ - private function addCanonical() + private function addCanonical(): self { if ($this->isCanonicalEnabled() && $this->hasUrl()) $this->add('canonical', $this->currentUrl); diff --git a/src/Entities/Title.php b/src/Entities/Title.php index 2ad3c18..fb84d01 100644 --- a/src/Entities/Title.php +++ b/src/Entities/Title.php @@ -353,7 +353,7 @@ public function __toString() * * @return bool */ - private function hasSiteName() + private function hasSiteName(): bool { return ! empty($this->getSiteName()) && $this->siteNameVisibility; } @@ -365,7 +365,7 @@ private function hasSiteName() * * @throws \Arcanedev\SeoHelper\Exceptions\InvalidArgumentException */ - private function checkTitle(&$title) + private function checkTitle(&$title): void { if ( ! is_string($title)) { $type = gettype($title); @@ -387,7 +387,7 @@ private function checkTitle(&$title) * * @throws \Arcanedev\SeoHelper\Exceptions\InvalidArgumentException */ - private function checkMax($max) + private function checkMax($max): void { if ( ! is_int($max)) { throw new InvalidArgumentException('The title maximum length must be integer.'); @@ -410,7 +410,7 @@ private function checkMax($max) * * @return string */ - private function renderTitleFirst($separator) + private function renderTitleFirst(string $separator): string { $output = []; $output[] = $this->getTitleOnly(); @@ -430,7 +430,7 @@ private function renderTitleFirst($separator) * * @return string */ - private function renderTitleLast($separator) + private function renderTitleLast(string $separator): string { $output = []; @@ -451,7 +451,7 @@ private function renderTitleLast($separator) * * @return string */ - private function prepareTitleOutput($output) + private function prepareTitleOutput(string $output): string { return htmlspecialchars( Str::limit(strip_tags($output), $this->getMax()), ENT_QUOTES, 'UTF-8', false diff --git a/src/Entities/Twitter/Card.php b/src/Entities/Twitter/Card.php index 73870bf..c8535a9 100644 --- a/src/Entities/Twitter/Card.php +++ b/src/Entities/Twitter/Card.php @@ -289,7 +289,7 @@ public function __toString() * * @throws \Arcanedev\SeoHelper\Exceptions\InvalidTwitterCardException */ - private function checkType(&$type) + private function checkType(&$type): void { if ( ! is_string($type)) { throw new InvalidTwitterCardException( @@ -309,7 +309,7 @@ private function checkType(&$type) * * @param string $site */ - private function checkSite(&$site) + private function checkSite(string &$site): void { $site = $this->prepareUsername($site); } @@ -326,7 +326,7 @@ private function checkSite(&$site) * * @return string */ - private function prepareUsername($username) + private function prepareUsername(string $username): string { return Str::startsWith($username, '@') ? $username : diff --git a/src/Entities/Webmasters.php b/src/Entities/Webmasters.php index cf8d5bd..2479161 100644 --- a/src/Entities/Webmasters.php +++ b/src/Entities/Webmasters.php @@ -81,7 +81,7 @@ private function init() * * @param string $webmaster * - * @return string + * @return string|null */ private function getWebmasterName($webmaster) { @@ -177,7 +177,7 @@ public function __toString() * * @return bool */ - private function isSupported($webmaster) + private function isSupported(string $webmaster): bool { return array_key_exists($webmaster, $this->supported); } diff --git a/src/Facades/SeoHelper.php b/src/Facades/SeoHelper.php deleted file mode 100644 index b5a4dfb..0000000 --- a/src/Facades/SeoHelper.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -class SeoHelper extends Facade -{ - /** - * Get the registered name of the component. - * - * @return string - */ - protected static function getFacadeAccessor() { return SeoHelperContract::class; } -} diff --git a/src/Facades/SeoMeta.php b/src/Facades/SeoMeta.php deleted file mode 100644 index 8dbaea8..0000000 --- a/src/Facades/SeoMeta.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -class SeoMeta extends Facade -{ - /** - * Get the registered name of the component. - * - * @return string - */ - protected static function getFacadeAccessor() { return SeoMetaContract::class; } -} diff --git a/src/Facades/SeoOpenGraph.php b/src/Facades/SeoOpenGraph.php deleted file mode 100644 index 1f1d313..0000000 --- a/src/Facades/SeoOpenGraph.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -class SeoOpenGraph extends Facade -{ - /** - * Get the registered name of the component. - * - * @return string - */ - protected static function getFacadeAccessor() { return SeoOpenGraphContract::class; } -} diff --git a/src/Facades/SeoTwitter.php b/src/Facades/SeoTwitter.php deleted file mode 100644 index e5324c8..0000000 --- a/src/Facades/SeoTwitter.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -class SeoTwitter extends Facade -{ - /** - * Get the registered name of the component. - * - * @return string - */ - protected static function getFacadeAccessor() { return SeoTwitterContract::class; } -} diff --git a/src/Helpers/Meta.php b/src/Helpers/Meta.php index 34fd45e..acb6b74 100644 --- a/src/Helpers/Meta.php +++ b/src/Helpers/Meta.php @@ -207,14 +207,12 @@ public function render() * * @return string */ - private function renderLink() + private function renderLink(): string { - return Element::withTag('link') - ->attributes([ - 'rel' => $this->getName(false), - 'href' => $this->getContent(), - ]) - ->toHtml(); + return Element::withTag('link')->attributes([ + 'rel' => $this->getName(false), + 'href' => $this->getContent(), + ])->toHtml(); } /** @@ -222,7 +220,7 @@ private function renderLink() * * @return string */ - private function renderMeta() + private function renderMeta(): string { $content = Arr::wrap($this->getContent()); @@ -279,7 +277,7 @@ public function isValid() * * @throws InvalidArgumentException */ - private function checkNameProperty(&$nameProperty) + private function checkNameProperty(&$nameProperty): void { if ( ! is_string($nameProperty)) { throw new InvalidArgumentException( diff --git a/src/Providers/UtilityServiceProvider.php b/src/Providers/UtilityServiceProvider.php deleted file mode 100644 index 47b21e5..0000000 --- a/src/Providers/UtilityServiceProvider.php +++ /dev/null @@ -1,105 +0,0 @@ - - */ -class UtilityServiceProvider extends ServiceProvider -{ - /* ----------------------------------------------------------------- - | Properties - | ----------------------------------------------------------------- - */ - - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = true; - - /* ----------------------------------------------------------------- - | Main Methods - | ----------------------------------------------------------------- - */ - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - parent::register(); - - $this->registerSeoMetaService(); - $this->registerSeoOpenGraphService(); - $this->registerSeoTwitterService(); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return [ - Contracts\SeoMeta::class, - Contracts\SeoOpenGraph::class, - Contracts\SeoTwitter::class, - ]; - } - - /* ----------------------------------------------------------------- - | Utilities - | ----------------------------------------------------------------- - */ - - /** - * Register SeoMeta service. - */ - private function registerSeoMetaService() - { - $this->singleton(Contracts\SeoMeta::class, function ($app) { - /** @var \Illuminate\Contracts\Config\Repository $config */ - $config = $app['config']; - - return new SeoMeta($config->get('seo-helper')); - }); - } - - /** - * Register SeoOpenGraph service. - */ - private function registerSeoOpenGraphService() - { - $this->singleton(Contracts\SeoOpenGraph::class, function ($app) { - /** @var \Illuminate\Contracts\Config\Repository $config */ - $config = $app['config']; - - return new SeoOpenGraph($config->get('seo-helper')); - }); - } - - /** - * Register SeoTwitter service. - */ - private function registerSeoTwitterService() - { - $this->singleton(Contracts\SeoTwitter::class, function ($app) { - /** @var \Illuminate\Contracts\Config\Repository $config */ - $config = $app['config']; - - return new SeoTwitter($config->get('seo-helper')); - }); - } -} diff --git a/src/SeoHelperServiceProvider.php b/src/SeoHelperServiceProvider.php index fb6dd89..0083d4d 100644 --- a/src/SeoHelperServiceProvider.php +++ b/src/SeoHelperServiceProvider.php @@ -1,6 +1,7 @@ */ -class SeoHelperServiceProvider extends ServiceProvider +class SeoHelperServiceProvider extends ServiceProvider implements DeferrableProvider { /* ----------------------------------------------------------------- | Properties @@ -22,13 +23,6 @@ class SeoHelperServiceProvider extends ServiceProvider */ protected $package = 'seo-helper'; - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = true; - /* ----------------------------------------------------------------- | Main Methods | ----------------------------------------------------------------- @@ -37,24 +31,23 @@ class SeoHelperServiceProvider extends ServiceProvider /** * Register the service provider. */ - public function register() + public function register(): void { parent::register(); $this->registerConfig(); - $this->registerProvider(Providers\UtilityServiceProvider::class); - - $this->singleton(Contracts\SeoHelper::class, SeoHelper::class); + $this->registerSeoHelperService(); + $this->registerSeoMetaService(); + $this->registerSeoOpenGraphService(); + $this->registerSeoTwitterService(); } /** * Boot the service provider. */ - public function boot() + public function boot(): void { - parent::boot(); - $this->publishConfig(); } @@ -63,10 +56,55 @@ public function boot() * * @return array */ - public function provides() + public function provides(): array { return [ Contracts\SeoHelper::class, + Contracts\SeoMeta::class, + Contracts\SeoOpenGraph::class, + Contracts\SeoTwitter::class, ]; } + + /* ----------------------------------------------------------------- + | Other Methods + | ----------------------------------------------------------------- + */ + /** + * Register SeoHelper service. + */ + private function registerSeoHelperService(): void + { + $this->singleton(Contracts\SeoHelper::class, SeoHelper::class); + } + + /** + * Register SeoMeta service. + */ + private function registerSeoMetaService(): void + { + $this->singleton(Contracts\SeoMeta::class, function ($app) { + return new SeoMeta($app['config']->get('seo-helper')); + }); + } + + /** + * Register SeoOpenGraph service. + */ + private function registerSeoOpenGraphService(): void + { + $this->singleton(Contracts\SeoOpenGraph::class, function ($app) { + return new SeoOpenGraph($app['config']->get('seo-helper')); + }); + } + + /** + * Register SeoTwitter service. + */ + private function registerSeoTwitterService(): void + { + $this->singleton(Contracts\SeoTwitter::class, function ($app) { + return new SeoTwitter($app['config']->get('seo-helper')); + }); + } } diff --git a/tests/Providers/UtilityServiceProviderTest.php b/tests/Providers/UtilityServiceProviderTest.php deleted file mode 100644 index 0fe33b0..0000000 --- a/tests/Providers/UtilityServiceProviderTest.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -class UtilityServiceProviderTest extends TestCase -{ - /* ----------------------------------------------------------------- - | Properties - | ----------------------------------------------------------------- - */ - - /** @var \Arcanedev\SeoHelper\Providers\UtilityServiceProvider */ - private $provider; - - /* ----------------------------------------------------------------- - | Main Methods - | ----------------------------------------------------------------- - */ - - public function setUp(): void - { - parent::setUp(); - - $this->provider = $this->app->getProvider(UtilityServiceProvider::class); - } - - public function tearDown(): void - { - unset($this->provider); - - parent::tearDown(); - } - - /* ----------------------------------------------------------------- - | Tests - | ----------------------------------------------------------------- - */ - - /** @test */ - public function it_can_be_instantiated() - { - $expectations = [ - \Illuminate\Support\ServiceProvider::class, - \Arcanedev\Support\ServiceProvider::class, - \Arcanedev\SeoHelper\Providers\UtilityServiceProvider::class, - ]; - - foreach ($expectations as $expected) { - static::assertInstanceOf($expected, $this->provider); - } - } - - /** @test */ - public function it_can_provides() - { - $expected = [ - \Arcanedev\SeoHelper\Contracts\SeoMeta::class, - \Arcanedev\SeoHelper\Contracts\SeoOpenGraph::class, - \Arcanedev\SeoHelper\Contracts\SeoTwitter::class, - ]; - - static::assertSame($expected, $this->provider->provides()); - } -} diff --git a/tests/SeoHelperServiceProviderTest.php b/tests/SeoHelperServiceProviderTest.php index d06fbd8..0f340af 100644 --- a/tests/SeoHelperServiceProviderTest.php +++ b/tests/SeoHelperServiceProviderTest.php @@ -47,8 +47,9 @@ public function it_can_get_service_provider() { $expectations = [ \Illuminate\Support\ServiceProvider::class, - \Arcanedev\Support\ServiceProvider::class, - \Arcanedev\Support\PackageServiceProvider::class, + \Illuminate\Contracts\Support\DeferrableProvider::class, + \Arcanedev\Support\Providers\ServiceProvider::class, + \Arcanedev\Support\Providers\PackageServiceProvider::class, \Arcanedev\SeoHelper\SeoHelperServiceProvider::class, ]; @@ -62,6 +63,9 @@ public function it_can_provides() { $expected = [ \Arcanedev\SeoHelper\Contracts\SeoHelper::class, + \Arcanedev\SeoHelper\Contracts\SeoMeta::class, + \Arcanedev\SeoHelper\Contracts\SeoOpenGraph::class, + \Arcanedev\SeoHelper\Contracts\SeoTwitter::class, ]; static::assertSame($expected, $this->provider->provides());