Skip to content

Commit

Permalink
Merge pull request #84 from hydephp/80-add-more-aria-roles-to-articles
Browse files Browse the repository at this point in the history
Updates the frontend and adds the tests for hydephp/framework#102
  • Loading branch information
caendesilva authored Apr 11, 2022
2 parents 3ceac86 + 420790b commit b679e36
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 10 deletions.
14 changes: 14 additions & 0 deletions config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,21 @@
| Example: https://example.org/blog
|
*/

'site_url' => env('SITE_URL', null),

/*
|--------------------------------------------------------------------------
| Site Language
|--------------------------------------------------------------------------
|
| This value sets the language of your site and is used for the
| <html lang=""> element in the app layout. Default is 'en'.
|
*/

'language' => 'en',

/*
|--------------------------------------------------------------------------
| Global Site Meta Tags
Expand All @@ -65,6 +78,7 @@
| for a list of tags and what what they are for.
|
*/

'meta' => [
// 'author' => 'Mr. Hyde',
// 'description' => 'My Hyde Blog',
Expand Down
2 changes: 1 addition & 1 deletion resources/frontend/hyde.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/Feature/AuthorPostsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function test_create_post_with_undefined_author()

// Check that the author is rendered as is in the DOM
$this->assertStringContainsString(
'<span itemprop="name" >test_undefined_author</span>',
'<span itemprop="name" aria-label="The author\'s name" >test_undefined_author</span>',
file_get_contents(Hyde::path('_site/posts/test-2dcbb2c-post-with-undefined-author.html'))
);

Expand Down Expand Up @@ -103,7 +103,7 @@ public function test_create_post_with_defined_author_with_name()

// Check that the author is contains the set name in the DOM
$this->assertStringContainsString(
'<span itemprop="name" title=@test_named_author>Test Author</span>',
'<span itemprop="name" aria-label="The author\'s name" title=@test_named_author>Test Author</span>',
file_get_contents(Hyde::path('_site/posts/test-2dcbb2c-post-with-defined-author-with-name.html'))
);

Expand Down Expand Up @@ -147,13 +147,13 @@ public function test_create_post_with_defined_author_with_website()

// Check that the author is contains the set name in the DOM
$this->assertStringContainsString(
'<span itemprop="name" title=@test_author_with_website>Test Author</span>',
'<span itemprop="name" aria-label="The author\'s name" title=@test_author_with_website>Test Author</span>',
file_get_contents(Hyde::path('_site/posts/test-2dcbb2c-post-with-defined-author-with-name.html'))
);

// Check that the author is contains the set website in the DOM
$this->assertStringContainsString(
'<a href="https://example.org" rel="author" itemprop="url">',
'<a href="https://example.org" rel="author" itemprop="url" aria-label="The author\'s website">',
file_get_contents(Hyde::path('_site/posts/test-2dcbb2c-post-with-defined-author-with-name.html'))
);

Expand Down
8 changes: 4 additions & 4 deletions tests/Feature/Commands/StaticSiteBuilderPostModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function setUp(): void
'date' => '1865-11-18 18:52',
], "## CHAPTER I. DOWN THE RABBIT-HOLE. \n\nSo she was considering in her own mind, as well as she could, for the hot day made her feel very sleepy and stupid.", 'Test Title', 'test-post');

// Make sure no file exists which could caues unintended results.
// Make sure no file exists which could cause unintended results.
unlinkIfExists(Hyde::path('_site/posts/test-post.html'));
}

Expand Down Expand Up @@ -93,9 +93,9 @@ public function test_post_contains_expected_meta_tags()
'<meta name="description" content="All in the golden afternoon, full leisurely we glide.">',
'<meta name="author" content="Lewis Carroll">',
'<meta name="keywords" content="novels">',
'<meta property="og:type" content="article" />',
'<meta property="og:type" content="article">',
'<meta property="og:title" content="Adventures in Wonderland">',
'<meta property="og:article:published_time" content="1865-11-18 18:52">',
'<meta property="og:article:published_time" content="1865-11-18T18:52:00+00:00">',
]);
}

Expand All @@ -107,7 +107,7 @@ public function test_post_contains_expected_itemprops()
'itemprop="identifier"',
'itemprop="headline"',
'itemprop="dateCreated datePublished"',
'itemprop="author publisher"',
'itemprop="author"',
'itemprop="name"',
'itemprop="articleBody"',
]);
Expand Down
45 changes: 45 additions & 0 deletions tests/Unit/DateStringTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Tests\Unit;

use DateTime;
use Hyde\Framework\Models\DateString;
use PHPUnit\Framework\TestCase;

class DateStringTest extends TestCase
{
// Test it can parse a date string
public function test_it_can_parse_date_string()
{
$dateString = new DateString('2020-01-01');
$this->assertEquals('2020-01-01', $dateString->string);
}

// Test it can parse date string into datetime object
public function test_it_can_parse_date_string_into_datetime_object()
{
$dateString = new DateString('2020-01-01 UTC');
$this->assertInstanceOf(DateTime::class, $dateString->dateTimeObject);
}

// Test it can format date string into a machine-readable string
public function test_it_can_format_date_string_into_machine_readable_string()
{
$dateString = new DateString('2020-01-01 UTC');
$this->assertEquals('2020-01-01T00:00:00+00:00', $dateString->datetime);
}

// Test it can format date string into a human-readable string
public function test_it_can_format_date_string_into_human_readable_string()
{
$dateString = new DateString('2020-01-01 UTC');
$this->assertEquals('Wednesday Jan 1st, 2020, at 12:00am', $dateString->sentence);
}

// Test it can format date string into a short human-readable string
public function test_it_can_format_date_string_into_short_human_readable_string()
{
$dateString = new DateString('2020-01-01 UTC');
$this->assertEquals('Jan 1st, 2020', $dateString->short);
}
}
2 changes: 1 addition & 1 deletion tests/Unit/MarkdownPostParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Hyde\Framework\Hyde;
use Hyde\Framework\MarkdownPostParser;
use Hyde\Framework\Models\MarkdownPost;
use PHPUnit\Framework\TestCase;
use Tests\TestCase;

/**
* @see Tests\Feature\Commands\StaticSiteBuilderPostModuleTest for the compiler test.
Expand Down

0 comments on commit b679e36

Please sign in to comment.