Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #590

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Console/Commands/PublishHomepageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class PublishHomepageCommand extends Command

/** @var array<string, array{name: string, description: string, group: string}> */
protected array $options = [
'welcome'=> [
'welcome' => [
'name' => 'Welcome',
'description' => 'The default welcome page.',
'group' => 'hyde-welcome-page',
],
'posts'=> [
'posts' => [
'name' => 'Posts Feed',
'description' => 'A feed of your latest posts. Perfect for a blog site!',
'group' => 'hyde-posts-page',
],
'blank'=> [
'blank' => [
'name' => 'Blank Starter',
'description' => 'A blank Blade template with just the base layout.',
'group' => 'hyde-blank-page',
Expand Down
12 changes: 6 additions & 6 deletions src/Markdown/Contracts/FrontMatter/BlogPostSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
interface BlogPostSchema extends PageSchema
{
public const BLOG_POST_SCHEMA = [
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
];
}
6 changes: 3 additions & 3 deletions src/Markdown/Contracts/FrontMatter/PageSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
interface PageSchema extends FrontMatterSchema
{
public const PAGE_SCHEMA = [
'title' => 'string',
'canonicalUrl' => 'string', // While not present in the page data, it is supported as a front matter key for the accessor data source.
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
'title' => 'string',
'canonicalUrl' => 'string', // While not present in the page data, it is supported as a front matter key for the accessor data source.
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
interface AuthorSchema extends BlogPostSchema
{
public const AUTHOR_SCHEMA = [
'name' => 'string',
'username' => 'string',
'website' => 'string',
'name' => 'string',
'username' => 'string',
'website' => 'string',
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
interface FeaturedImageSchema extends BlogPostSchema
{
public const FEATURED_IMAGE_SCHEMA = [
'source' => 'string', // Name of a file in _media/ or a remote URL (required)
'altText' => 'string', // The alt text (important for accessibility) // todo: Support alt, description
'titleText' => 'string', // The title text (hover tooltip & metadata) // todo: Support title, caption
'licenseName' => 'string', // The name of the license (e.g. "CC BY 4.0")
'licenseUrl' => 'string', // The URL of the license (e.g. "https://creativecommons.org/licenses/by/4.0/")
'authorName' => 'string', // The name of the author/photographer of the image (e.g. "John Doe", Wikimedia Commons)
'authorUrl' => 'string', // The URL of the author/photographer of the image (e.g. "https://commons.wikimedia.org/wiki/User:John_Doe", Wikimedia Commons)
'copyright' => 'string', // The copyright text (e.g. "© 2023 John Doe")
'source' => 'string', // Name of a file in _media/ or a remote URL (required)
'altText' => 'string', // The alt text (important for accessibility) // todo: Support alt, description
'titleText' => 'string', // The title text (hover tooltip & metadata) // todo: Support title, caption
'licenseName' => 'string', // The name of the license (e.g. "CC BY 4.0")
'licenseUrl' => 'string', // The URL of the license (e.g. "https://creativecommons.org/licenses/by/4.0/")
'authorName' => 'string', // The name of the author/photographer of the image (e.g. "John Doe", Wikimedia Commons)
'authorUrl' => 'string', // The URL of the author/photographer of the image (e.g. "https://commons.wikimedia.org/wiki/User:John_Doe", Wikimedia Commons)
'copyright' => 'string', // The copyright text (e.g. "© 2023 John Doe")
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
interface NavigationSchema extends PageSchema
{
public const NAVIGATION_SCHEMA = [
'label' => 'string', // The text to display
'priority' => 'int', // Order is also supported
'hidden' => 'bool', // Visible is also supported (but obviously invert the value)
'group' => 'string', // Category is also supported
'label' => 'string', // The text to display
'priority' => 'int', // Order is also supported
'hidden' => 'bool', // Visible is also supported (but obviously invert the value)
'group' => 'string', // Category is also supported
];
}
18 changes: 9 additions & 9 deletions src/Support/Filesystem/MediaFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ public function getMimeType(): string
// See if we can find a mime type for the extension instead of
// having to rely on a PHP extension and filesystem lookups.
$lookup = [
'txt' => 'text/plain',
'md' => 'text/markdown',
'txt' => 'text/plain',
'md' => 'text/markdown',
'html' => 'text/html',
'css' => 'text/css',
'svg' => 'image/svg+xml',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'css' => 'text/css',
'svg' => 'image/svg+xml',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
'gif' => 'image/gif',
'json' => 'application/json',
'js' => 'application/javascript',
'xml' => 'application/xml',
'js' => 'application/javascript',
'xml' => 'application/xml',
];

if (isset($lookup[$extension])) {
Expand Down
4 changes: 2 additions & 2 deletions src/Support/Models/RouteListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public function __construct(Route $route)
public function toArray(): array
{
return [
'page_type' => $this->stylePageType($this->route->getPageClass()),
'page_type' => $this->stylePageType($this->route->getPageClass()),
'source_file' => $this->styleSourcePath($this->route->getSourcePath()),
'output_file' => $this->styleOutputPath($this->route->getOutputPath()),
'route_key' => $this->styleRouteKey($this->route->getRouteKey()),
'route_key' => $this->styleRouteKey($this->route->getRouteKey()),
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/MarkdownServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function test_raw_html_tags_are_stripped_by_default()

public function test_raw_html_tags_are_not_stripped_when_explicitly_enabled()
{
config(['markdown.allow_html' =>true]);
config(['markdown.allow_html' => true]);
$markdown = '<p>foo</p><style>bar</style><script>hat</script>';
$service = new MarkdownService($markdown);
$html = $service->parse();
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Support/MediaFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public function test_to_array_returns_array_of_file_properties()
$this->file('foo.txt', 'foo bar');

$this->assertSame([
'name' => 'foo.txt',
'path' => 'foo.txt',
'name' => 'foo.txt',
'path' => 'foo.txt',
'length' => 7,
'mimeType' => 'text/plain',
], MediaFile::make('foo.txt')->toArray());
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Support/ProjectFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function test_to_array_returns_array_of_file_properties()
$this->file('foo.txt', 'foo bar');

$this->assertSame([
'name' => 'foo.txt',
'path' => 'foo.txt',
'name' => 'foo.txt',
'path' => 'foo.txt',
], ProjectFileTestClass::make('foo.txt')->toArray());
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Support/SourceFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public function test_to_array_returns_array_of_file_properties()
$this->file('foo.txt', 'foo bar');

$this->assertSame([
'name' => 'foo.txt',
'path' => 'foo.txt',
'name' => 'foo.txt',
'path' => 'foo.txt',
'pageClass' => HydePage::class,
], SourceFile::make('foo.txt')->toArray());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/BreadcrumbsComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testCanRender()
$view = Mockery::mock(\Illuminate\View\View::class);
$mock = Mockery::mock(Factory::class);
$mock->shouldReceive('make')->once()->with('hyde::components.breadcrumbs')->andReturn($view);
app()->singleton('view', fn () =>$mock);
app()->singleton('view', fn () => $mock);
View::swap($mock);

$this->assertSame($view, (new BreadcrumbsComponent())->render());
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Pages/BaseHydePageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ protected function setUp(): void
]),
'share' => null,
]));
app()->bind(\Illuminate\Contracts\View\Factory::class, fn () =>$mock);
app()->bind('view', fn () =>$mock);
app()->bind(\Illuminate\Contracts\View\Factory::class, fn () => $mock);
app()->bind('view', fn () => $mock);

Render::swap(new RenderData());
}
Expand Down
48 changes: 24 additions & 24 deletions tests/Unit/SchemaContractsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,42 @@ class SchemaContractsTest extends UnitTestCase
public function testSchemasAreNotAccidentallyChanged()
{
$this->assertSame([
'title' => 'string',
'canonicalUrl' => 'string',
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
'title' => 'string',
'canonicalUrl' => 'string',
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
], PageSchema::PAGE_SCHEMA);

$this->assertSame([
'label' => 'string',
'priority' => 'int',
'hidden' => 'bool',
'group' => 'string',
'label' => 'string',
'priority' => 'int',
'hidden' => 'bool',
'group' => 'string',
], NavigationSchema::NAVIGATION_SCHEMA);

$this->assertSame([
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
], BlogPostSchema::BLOG_POST_SCHEMA);

$this->assertSame([
'name' => 'string',
'username' => 'string',
'website' => 'string',
'name' => 'string',
'username' => 'string',
'website' => 'string',
], AuthorSchema::AUTHOR_SCHEMA);

$this->assertSame([
'source' => 'string',
'altText' => 'string',
'titleText' => 'string',
'licenseName' => 'string',
'licenseUrl' => 'string',
'authorName' => 'string',
'authorUrl' => 'string',
'copyright' => 'string',
'source' => 'string',
'altText' => 'string',
'titleText' => 'string',
'licenseName' => 'string',
'licenseUrl' => 'string',
'authorName' => 'string',
'authorUrl' => 'string',
'copyright' => 'string',
], FeaturedImageSchema::FEATURED_IMAGE_SCHEMA);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Views/FeaturedImageViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ protected function stripWhitespace(string $string): string
return str_replace([' ', "\r", "\n"], '', $string);
}

protected function renderComponent(FeaturedImage|array $data = ['image.source'=>'foo']): string
protected function renderComponent(FeaturedImage|array $data = ['image.source' => 'foo']): string
{
$image = $data instanceof FeaturedImage ? $data : $this->make($data);

Expand Down
Loading