From a0c5c4ff07c44c1477c193316509af22688f50fc Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 13:37:57 +0200 Subject: [PATCH 01/18] Add dependent method as abstract From Scrutinizer: It seems like toArray() must be provided by classes using this trait. How about adding it as abstract method to this trait? --- packages/framework/src/Concerns/JsonSerializesArrayable.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/framework/src/Concerns/JsonSerializesArrayable.php b/packages/framework/src/Concerns/JsonSerializesArrayable.php index 1f3a6178bf0..fe6f47b6b02 100644 --- a/packages/framework/src/Concerns/JsonSerializesArrayable.php +++ b/packages/framework/src/Concerns/JsonSerializesArrayable.php @@ -9,4 +9,7 @@ public function jsonSerialize() { return $this->toArray(); } + + /** @inheritDoc */ + abstract public function toArray(); } From b77d77e3ab927022d454776ad6d5bf83fe9e061f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 13:43:49 +0200 Subject: [PATCH 02/18] Remove unused protected method getFacadeAccessor Since we are overriding the getFacadeRoot method this is not used anymore --- packages/framework/src/Hyde.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/framework/src/Hyde.php b/packages/framework/src/Hyde.php index 6821e7c9aab..fc4b2bdcaf6 100644 --- a/packages/framework/src/Hyde.php +++ b/packages/framework/src/Hyde.php @@ -48,12 +48,6 @@ */ class Hyde extends Facade { - /** @psalm-return HydeKernel::class */ - protected static function getFacadeAccessor(): string - { - return HydeKernel::class; - } - public static function version(): string { return HydeKernel::version(); From 611eedd4945c0f1dd6f027b5979962c75ca75012 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 13:46:13 +0200 Subject: [PATCH 03/18] Update PHPDoc --- packages/framework/src/Contracts/HydeKernelContract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Contracts/HydeKernelContract.php b/packages/framework/src/Contracts/HydeKernelContract.php index 4175d4aa80a..02c115a84dd 100644 --- a/packages/framework/src/Contracts/HydeKernelContract.php +++ b/packages/framework/src/Contracts/HydeKernelContract.php @@ -8,8 +8,8 @@ * * @see \Hyde\Framework\HydeKernel * - * It is bound into the Laravel Application Service Container, - * and can be accessed in a few ways. + * It is stored as a singleton in the HydeKernel class, and is bound into the + * Laravel Application Service Container, and can be accessed in a few ways. * * - Commonly, you'll use the Hyde facade: * @see \Hyde\Framework\Hyde (previosly this namespace contained the actual Kernel) From cdee7280dc9925d0eab9744ca3497b9ba4da28fe Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 13:47:22 +0200 Subject: [PATCH 04/18] Add kernel methods to interface contract --- packages/framework/src/Contracts/HydeKernelContract.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Contracts/HydeKernelContract.php b/packages/framework/src/Contracts/HydeKernelContract.php index 02c115a84dd..afa50cf9325 100644 --- a/packages/framework/src/Contracts/HydeKernelContract.php +++ b/packages/framework/src/Contracts/HydeKernelContract.php @@ -27,7 +27,11 @@ */ interface HydeKernelContract { - public function getBasePath(): string; + public function boot(): void; + + public static function setInstance(HydeKernelContract $instance): void; + public static function getInstance(): HydeKernelContract; + public function getBasePath(): string; public function setBasePath(string $basePath); } From f2bc7fa9d0b31d4529787aeb6519af8fcf576275 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 11 Aug 2022 11:47:52 +0000 Subject: [PATCH 05/18] Apply fixes from StyleCI --- packages/framework/src/Contracts/HydeKernelContract.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/framework/src/Contracts/HydeKernelContract.php b/packages/framework/src/Contracts/HydeKernelContract.php index afa50cf9325..43cb068bf2a 100644 --- a/packages/framework/src/Contracts/HydeKernelContract.php +++ b/packages/framework/src/Contracts/HydeKernelContract.php @@ -30,8 +30,10 @@ interface HydeKernelContract public function boot(): void; public static function setInstance(HydeKernelContract $instance): void; + public static function getInstance(): HydeKernelContract; public function getBasePath(): string; + public function setBasePath(string $basePath); } From a489588cd625f56aec189b403eb4fa30d1fee8bf Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 13:51:01 +0200 Subject: [PATCH 06/18] Merge single-use trait into parent --- .../FacadeHelpers/HydeSmartDocsFacade.php | 51 ------------------- .../framework/src/Services/HydeSmartDocs.php | 40 +++++++++++++-- .../Feature/Services/HydeSmartDocsTest.php | 1 - 3 files changed, 37 insertions(+), 55 deletions(-) delete mode 100644 packages/framework/src/Concerns/FacadeHelpers/HydeSmartDocsFacade.php diff --git a/packages/framework/src/Concerns/FacadeHelpers/HydeSmartDocsFacade.php b/packages/framework/src/Concerns/FacadeHelpers/HydeSmartDocsFacade.php deleted file mode 100644 index 932ba292faa..00000000000 --- a/packages/framework/src/Concerns/FacadeHelpers/HydeSmartDocsFacade.php +++ /dev/null @@ -1,51 +0,0 @@ -process(); - } - - /** - * Does the current document use Torchlight? - * - * @return bool - */ - public function hasTorchlight(): bool - { - return Features::hasTorchlight() && str_contains($this->html, 'Syntax highlighted by torchlight.dev'); - } - - /** - * Do we satisfy the requirements to render an edit source button in the supplied position? - * - * @param string $inPosition - * @return bool - */ - protected function canRenderSourceLink(string $inPosition): bool - { - $config = config('docs.edit_source_link_position', 'both'); - $positions = $config === 'both' ? ['header', 'footer'] : [$config]; - - return ($this->page->getOnlineSourcePath() !== false) && in_array($inPosition, $positions); - } -} diff --git a/packages/framework/src/Services/HydeSmartDocs.php b/packages/framework/src/Services/HydeSmartDocs.php index aee3d372ded..8af0455a729 100644 --- a/packages/framework/src/Services/HydeSmartDocs.php +++ b/packages/framework/src/Services/HydeSmartDocs.php @@ -2,7 +2,7 @@ namespace Hyde\Framework\Services; -use Hyde\Framework\Concerns\FacadeHelpers\HydeSmartDocsFacade; +use Hyde\Framework\Helpers\Features; use Hyde\Framework\Models\Pages\DocumentationPage; use Illuminate\Support\Str; @@ -16,8 +16,6 @@ */ class HydeSmartDocs { - use HydeSmartDocsFacade; - protected DocumentationPage $page; protected string $html; @@ -112,4 +110,40 @@ protected function renderSourceLink(): string config('docs.edit_source_link_text', 'Edit page') ); } + + /** + * Create a new HydeSmartDocs instance, process, and return it. + * + * @param \Hyde\Framework\Models\Pages\DocumentationPage $page The source page object + * @param string $html compiled HTML content + * @return static new processed instance + */ + public static function create(DocumentationPage $page, string $html): static + { + return (new self($page, $html))->process(); + } + + /** + * Does the current document use Torchlight? + * + * @return bool + */ + public function hasTorchlight(): bool + { + return Features::hasTorchlight() && str_contains($this->html, 'Syntax highlighted by torchlight.dev'); + } + + /** + * Do we satisfy the requirements to render an edit source button in the supplied position? + * + * @param string $inPosition + * @return bool + */ + protected function canRenderSourceLink(string $inPosition): bool + { + $config = config('docs.edit_source_link_position', 'both'); + $positions = $config === 'both' ? ['header', 'footer'] : [$config]; + + return ($this->page->getOnlineSourcePath() !== false) && in_array($inPosition, $positions); + } } diff --git a/packages/framework/tests/Feature/Services/HydeSmartDocsTest.php b/packages/framework/tests/Feature/Services/HydeSmartDocsTest.php index beafa7ae23e..05559a33120 100644 --- a/packages/framework/tests/Feature/Services/HydeSmartDocsTest.php +++ b/packages/framework/tests/Feature/Services/HydeSmartDocsTest.php @@ -10,7 +10,6 @@ /** * @covers \Hyde\Framework\Services\HydeSmartDocs - * @covers \Hyde\Framework\Concerns\FacadeHelpers\HydeSmartDocsFacade */ class HydeSmartDocsTest extends TestCase { From b4ca3ff0fc4058b767a55dab41fce722595b18f9 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 13:57:22 +0200 Subject: [PATCH 07/18] Create JsonSerializesArrayableTest.php --- .../Unit/JsonSerializesArrayableTest.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 packages/framework/tests/Unit/JsonSerializesArrayableTest.php diff --git a/packages/framework/tests/Unit/JsonSerializesArrayableTest.php b/packages/framework/tests/Unit/JsonSerializesArrayableTest.php new file mode 100644 index 00000000000..c569a19cf81 --- /dev/null +++ b/packages/framework/tests/Unit/JsonSerializesArrayableTest.php @@ -0,0 +1,34 @@ + 'bar']; + } + }; + + $this->assertEquals([ + 'foo' => 'bar', + ], $class->toArray()); + + $this->assertEquals([ + 'foo' => 'bar', + ], $class->jsonSerialize()); + + $this->assertEquals('{"foo":"bar"}', json_encode($class)); + } +} From 9582cc7e784f60c4ec0dcd5b6d15b47bd4d90751 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 13:57:30 +0200 Subject: [PATCH 08/18] Add class annotations --- .../framework/src/Concerns/JsonSerializesArrayable.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/framework/src/Concerns/JsonSerializesArrayable.php b/packages/framework/src/Concerns/JsonSerializesArrayable.php index fe6f47b6b02..97e42cc58b1 100644 --- a/packages/framework/src/Concerns/JsonSerializesArrayable.php +++ b/packages/framework/src/Concerns/JsonSerializesArrayable.php @@ -2,6 +2,13 @@ namespace Hyde\Framework\Concerns; +/** + * Automatically serializes an Arrayable interface when JSON is requested. + * + * @see \JsonSerializable + * @see \Illuminate\Contracts\Support\Arrayable + * @see \Hyde\Framework\Testing\Unit\JsonSerializesArrayableTest + */ trait JsonSerializesArrayable { /** @inheritDoc */ From cf241b8bc8af4dbfeaac8e9af57fdfe109436fc3 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 11 Aug 2022 13:07:58 +0000 Subject: [PATCH 09/18] Apply fixes from StyleCI --- packages/framework/tests/Unit/JsonSerializesArrayableTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/framework/tests/Unit/JsonSerializesArrayableTest.php b/packages/framework/tests/Unit/JsonSerializesArrayableTest.php index c569a19cf81..e064660e0dd 100644 --- a/packages/framework/tests/Unit/JsonSerializesArrayableTest.php +++ b/packages/framework/tests/Unit/JsonSerializesArrayableTest.php @@ -12,7 +12,8 @@ class JsonSerializesArrayableTest extends TestCase { public function testJsonSerialize() { - $class = new class implements \JsonSerializable { + $class = new class implements \JsonSerializable + { use JsonSerializesArrayable; public function toArray() From de582a971432b52945a82e67774e130cbabee9a8 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 15:12:18 +0200 Subject: [PATCH 10/18] Add tests for toArray method --- .../tests/Feature/ConfigurableFeaturesTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/framework/tests/Feature/ConfigurableFeaturesTest.php b/packages/framework/tests/Feature/ConfigurableFeaturesTest.php index 77293830b68..0c0bda99f68 100644 --- a/packages/framework/tests/Feature/ConfigurableFeaturesTest.php +++ b/packages/framework/tests/Feature/ConfigurableFeaturesTest.php @@ -57,4 +57,16 @@ public function test_can_generate_sitemap_helper_returns_false_if_sitemaps_are_d config(['site.generate_sitemap' => false]); $this->assertFalse(Features::sitemap()); } + + public function test_to_array_method_returns_method_array() + { + $array = (new Features)->toArray(); + $this->assertIsArray($array); + $this->assertNotEmpty($array); + foreach ($array as $feature => $enabled) { + $this->assertIsString($feature); + $this->assertIsBool($enabled); + $this->assertStringStartsNotWith('has', $feature); + } + } } From e6cb6a32b77a3b5f4399ec5c25a07a25ff8fce91 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 15:12:31 +0200 Subject: [PATCH 11/18] Update test method name --- packages/framework/tests/Unit/JsonSerializesArrayableTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/tests/Unit/JsonSerializesArrayableTest.php b/packages/framework/tests/Unit/JsonSerializesArrayableTest.php index c569a19cf81..15650be3b2e 100644 --- a/packages/framework/tests/Unit/JsonSerializesArrayableTest.php +++ b/packages/framework/tests/Unit/JsonSerializesArrayableTest.php @@ -10,7 +10,7 @@ */ class JsonSerializesArrayableTest extends TestCase { - public function testJsonSerialize() + public function test_json_serialize() { $class = new class implements \JsonSerializable { use JsonSerializesArrayable; From 1e8f9e2e31d92cbfcebc8907281d141fa6a25be1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 15:13:42 +0200 Subject: [PATCH 12/18] Remove Copilot comments from tests --- .../framework/tests/Feature/DataCollectionTest.php | 1 - .../framework/tests/Feature/MarkdownServiceTest.php | 2 -- .../Unit/Foundation/HyperlinksUrlPathHelpersTest.php | 10 ---------- 3 files changed, 13 deletions(-) diff --git a/packages/framework/tests/Feature/DataCollectionTest.php b/packages/framework/tests/Feature/DataCollectionTest.php index c6cb2a8cc9e..d76f325a899 100644 --- a/packages/framework/tests/Feature/DataCollectionTest.php +++ b/packages/framework/tests/Feature/DataCollectionTest.php @@ -113,7 +113,6 @@ public function test_get_markdown_files_method_does_not_include_files_with_exten File::deleteDirectory(Hyde::path('_data/foo')); } - // test get markdown files method does not remove files starting with an underscore public function test_get_markdown_files_method_does_not_remove_files_starting_with_an_underscore() { mkdir(Hyde::path('_data/foo')); diff --git a/packages/framework/tests/Feature/MarkdownServiceTest.php b/packages/framework/tests/Feature/MarkdownServiceTest.php index b30ac3896ed..918fc308011 100644 --- a/packages/framework/tests/Feature/MarkdownServiceTest.php +++ b/packages/framework/tests/Feature/MarkdownServiceTest.php @@ -80,7 +80,6 @@ public function test_bladedown_can_be_enabled() $this->assertEquals("Hello World!\n", $service->parse()); } - // test raw html tags are stripped by default public function test_raw_html_tags_are_stripped_by_default() { $markdown = '

foo

'; @@ -89,7 +88,6 @@ public function test_raw_html_tags_are_stripped_by_default() $this->assertEquals("

foo

<style>bar</style><script>hat</script>\n", $html); } - // test raw html tags are not stripped when explicitly enabled public function test_raw_html_tags_are_not_stripped_when_explicitly_enabled() { config(['markdown.allow_html' =>true]); diff --git a/packages/framework/tests/Unit/Foundation/HyperlinksUrlPathHelpersTest.php b/packages/framework/tests/Unit/Foundation/HyperlinksUrlPathHelpersTest.php index 3e02e676c70..abb19308e3b 100644 --- a/packages/framework/tests/Unit/Foundation/HyperlinksUrlPathHelpersTest.php +++ b/packages/framework/tests/Unit/Foundation/HyperlinksUrlPathHelpersTest.php @@ -35,35 +35,30 @@ public function test_has_site_url_returns_true_when_site_url_is_set() $this->assertTrue($this->class->hasSiteUrl()); } - // test that url returns the site url when no path is given public function test_qualified_url_returns_site_url_when_no_path_is_given() { config(['site.url' => 'https://example.com']); $this->assertEquals('https://example.com', $this->class->url()); } - // test that url returns the site url plus the given path public function test_qualified_url_returns_site_url_plus_given_path() { config(['site.url' => 'https://example.com']); $this->assertEquals('https://example.com/path', $this->class->url('path')); } - // test that url returns the site url plus the given path with extension public function test_qualified_url_returns_site_url_plus_given_path_with_extension() { config(['site.url' => 'https://example.com']); $this->assertEquals('https://example.com/path.html', $this->class->url('path.html')); } - // test that url returns the site url plus the given path with extension and query string public function test_qualified_url_returns_site_url_plus_given_path_with_extension_and_query_string() { config(['site.url' => 'https://example.com']); $this->assertEquals('https://example.com/path.html?query=string', $this->class->url('path.html?query=string')); } - // test that url trims trailing slashes public function test_qualified_url_trims_trailing_slashes() { config(['site.url' => 'https://example.com/']); @@ -72,14 +67,12 @@ public function test_qualified_url_trims_trailing_slashes() $this->assertEquals('https://example.com/foo', $this->class->url('/foo/')); } - // test that url accepts multiple schemes public function test_qualified_url_accepts_multiple_schemes() { config(['site.url' => 'http://example.com']); $this->assertEquals('http://example.com', $this->class->url()); } - // test that url throws an exception when no site url is set public function test_qualified_url_throws_exception_when_no_site_url_is_set() { config(['site.url' => null]); @@ -88,14 +81,12 @@ public function test_qualified_url_throws_exception_when_no_site_url_is_set() $this->class->url(); } - // test that url uses default parameter when supplied and no site url is set public function test_qualified_url_uses_default_parameter_when_no_site_url_is_set() { config(['site.url' => null]); $this->assertEquals('bar/foo', $this->class->url('foo', 'bar')); } - // test that url does not use default parameter when supplied and a site url is set public function test_qualified_url_does_not_use_default_parameter_when_site_url_is_set() { config(['site.url' => 'https://example.com']); @@ -108,7 +99,6 @@ public function test_helper_returns_expected_string_when_site_url_is_set() $this->assertEquals('https://example.com/foo/bar.html', $this->class->url('foo/bar.html')); } - // test returned url uses pretty urls when enabled public function test_helper_returns_expected_string_when_pretty_urls_are_enabled() { config(['site.url' => 'https://example.com', 'site.pretty_urls' => true]); From b60a354be088793ad050ed34d5edf6afbb6901d9 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 15:23:46 +0200 Subject: [PATCH 13/18] Test the toArray method --- .../tests/Feature/HydeKernelTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/framework/tests/Feature/HydeKernelTest.php b/packages/framework/tests/Feature/HydeKernelTest.php index 9350a91bf82..f628361f9f6 100644 --- a/packages/framework/tests/Feature/HydeKernelTest.php +++ b/packages/framework/tests/Feature/HydeKernelTest.php @@ -197,4 +197,29 @@ public function test_path_to_relative_helper_returns_relative_path_for_given_pat { $this->assertEquals('foo', Hyde::pathToRelative(Hyde::path('foo'))); } + + public function test_to_array_method() + { + $array = Hyde::toArray(); + + $this->assertTrue(is_array($array)); + $this->assertCount(4, $array); + + $this->assertArrayHasKey('basePath', $array); + $this->assertArrayHasKey('features', $array); + $this->assertArrayHasKey('pages', $array); + $this->assertArrayHasKey('routes', $array); + + $this->assertEquals(Hyde::getBasePath(), $array['basePath']); + $this->assertEquals(Hyde::features(), $array['features']); + $this->assertEquals(Hyde::pages(), $array['pages']); + $this->assertEquals(Hyde::routes(), $array['routes']); + + $this->assertEquals([ + 'basePath' => Hyde::getBasePath(), + 'features' => Hyde::features(), + 'pages' => Hyde::pages(), + 'routes' => Hyde::routes(), + ], Hyde::toArray()); + } } From e599931cfebeaf4d9197fc860922166d0fe16ad2 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 15:25:40 +0200 Subject: [PATCH 14/18] Resolve todo and add method to contract --- packages/framework/src/Contracts/RouteFacadeContract.php | 8 ++++++++ packages/framework/src/Models/Route.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Contracts/RouteFacadeContract.php b/packages/framework/src/Contracts/RouteFacadeContract.php index 4fd9a13f11d..6ecb051a96d 100644 --- a/packages/framework/src/Contracts/RouteFacadeContract.php +++ b/packages/framework/src/Contracts/RouteFacadeContract.php @@ -69,4 +69,12 @@ public static function current(): RouteContract; * Get the home route, usually the index page route. */ public static function home(): RouteContract; + + /** + * Determine if the supplied route key exists in the route index. + * + * @param string $routeKey + * @return bool + */ + public static function exists(string $routeKey): bool; } diff --git a/packages/framework/src/Models/Route.php b/packages/framework/src/Models/Route.php index 8632c7fe758..2a43c422748 100644 --- a/packages/framework/src/Models/Route.php +++ b/packages/framework/src/Models/Route.php @@ -148,7 +148,7 @@ public static function home(): RouteContract return static::getFromKey('index'); } - /** @todo add to contract */ + /** @inheritDoc */ public static function exists(string $routeKey): bool { return RoutingService::getInstance()->getRoutes()->has($routeKey); From 48e72684d35d70adbb1ed81a0ee04a607c16ebd9 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 15:26:27 +0200 Subject: [PATCH 15/18] Reorder methods --- packages/framework/src/Models/Route.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/framework/src/Models/Route.php b/packages/framework/src/Models/Route.php index 2a43c422748..b116efc128f 100644 --- a/packages/framework/src/Models/Route.php +++ b/packages/framework/src/Models/Route.php @@ -40,6 +40,12 @@ public function __construct(PageContract $sourceModel) $this->routeKey = $this->constructRouteKey(); } + /** @inheritDoc */ + public function __toString(): string + { + return $this->getLink(); + } + /** @inheritDoc */ public function toArray() { @@ -50,6 +56,12 @@ public function toArray() ]; } + /** @inheritDoc */ + public function getLink(): string + { + return Hyde::relativeLink($this->getOutputFilePath()); + } + /** @inheritDoc */ public function getPageType(): string { @@ -86,18 +98,6 @@ public function getQualifiedUrl(): string return Hyde::url($this->getOutputFilePath()); } - /** @inheritDoc */ - public function getLink(): string - { - return Hyde::relativeLink($this->getOutputFilePath()); - } - - /** @inheritDoc */ - public function __toString(): string - { - return $this->getLink(); - } - /** @deprecated Use the route key property */ protected function constructRouteKey(): string { From 966c8df10cc7d0925ea1e1898830e733f01e921a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 15:28:53 +0200 Subject: [PATCH 16/18] Test the toArray method --- packages/framework/tests/Feature/RouteTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/framework/tests/Feature/RouteTest.php b/packages/framework/tests/Feature/RouteTest.php index 0684b609655..c728638a426 100644 --- a/packages/framework/tests/Feature/RouteTest.php +++ b/packages/framework/tests/Feature/RouteTest.php @@ -216,4 +216,13 @@ public function test_home_helper_returns_index_route() { $this->assertEquals(Route::get('index'), Route::home()); } + + public function test_to_array_method() + { + $this->assertEquals([ + 'routeKey' => 'foo', + 'sourceModelPath' => '_pages/foo.md', + 'sourceModelType' => MarkdownPage::class, + ], (new MarkdownPage('foo'))->getRoute()->toArray()); + } } From 6ae2273666c1c5077cbc0f135dca2c1673313bf0 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 11 Aug 2022 13:29:17 +0000 Subject: [PATCH 17/18] Apply fixes from StyleCI --- packages/framework/src/Contracts/RouteFacadeContract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Contracts/RouteFacadeContract.php b/packages/framework/src/Contracts/RouteFacadeContract.php index 6ecb051a96d..ad5797a4e52 100644 --- a/packages/framework/src/Contracts/RouteFacadeContract.php +++ b/packages/framework/src/Contracts/RouteFacadeContract.php @@ -73,7 +73,7 @@ public static function home(): RouteContract; /** * Determine if the supplied route key exists in the route index. * - * @param string $routeKey + * @param string $routeKey * @return bool */ public static function exists(string $routeKey): bool; From e04dd0fce95bbee6f91e4af4c0b4c84e0ca0060b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 15:35:34 +0200 Subject: [PATCH 18/18] Update class comment --- packages/framework/src/Services/RoutingService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Services/RoutingService.php b/packages/framework/src/Services/RoutingService.php index cc86267fc99..f2f0796b06f 100644 --- a/packages/framework/src/Services/RoutingService.php +++ b/packages/framework/src/Services/RoutingService.php @@ -19,8 +19,8 @@ * The routes defined can then also be used to power the RealtimeCompiler without * having to reverse-engineer the source file mapping. * - * Routes cannot be added manually, instead the route index is created using the - * exact same rules as the current autodiscovery process and compiled file output. + * Routes are not intended to be added manually, instead the route index is created using + * the exact same rules as the current autodiscovery process and compiled file output. * * The route index serves as a multidimensional mapping allowing you to * determine where a source file will be compiled to, and where a compiled