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 #344

Merged
merged 1 commit into from
May 15, 2022
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
3 changes: 1 addition & 2 deletions src/Actions/CreatesDefaultDirectories.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
* @deprecated as Hyde is bringing support for changing the default directories.
* The directories needed will be created (if needed) when the filesystem
* needs to access them. The default directories may be created in the TestCase.
*
*
* To prevent any issues with file generations, this action
* is automatically whenever the application is booted.
*
* This behavior is handled in the Service Provider.
*
* @see \Hyde\Framework\HydeServiceProvider
*/
class CreatesDefaultDirectories
Expand Down
4 changes: 2 additions & 2 deletions src/Services/BuildService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

/**
* Static service helpers for building static pages.
*
* @deprecated may be renamed to DiscoveryService
*
* @package HydeAutoDiscovery
*/
class BuildService
{
Expand Down Expand Up @@ -53,6 +52,7 @@ public static function getFilePathForModelClassFiles(string $model): string

/**
* Determine the Page Model to use for a given file path.
*
* @see \Tests\Unit\BuildServiceCanFindModelFromCustomSourceFilePathTest
*
* @return string The model class constant, or false if none was found.
Expand Down
11 changes: 5 additions & 6 deletions src/Services/CollectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
* Contains service methods to return helpful collections of arrays and lists.
*
* @see \Tests\Feature\Services\CollectionServiceTest
*
* @todo refactor to use the source directories instead of hard-coded paths
*
* @package HydeAutoDiscovery
*/
class CollectionService
{
Expand Down Expand Up @@ -56,7 +55,7 @@ public static function getBladePageList(): array
{
$array = [];

foreach (glob(Hyde::path(BladePage::$sourceDirectory . '/*.blade.php')) as $filepath) {
foreach (glob(Hyde::path(BladePage::$sourceDirectory.'/*.blade.php')) as $filepath) {
if (! str_starts_with(basename($filepath), '_')) {
$array[] = basename($filepath, '.blade.php');
}
Expand All @@ -74,7 +73,7 @@ public static function getMarkdownPageList(): array
{
$array = [];

foreach (glob(Hyde::path(MarkdownPage::$sourceDirectory . '/*.md')) as $filepath) {
foreach (glob(Hyde::path(MarkdownPage::$sourceDirectory.'/*.md')) as $filepath) {
if (! str_starts_with(basename($filepath), '_')) {
$array[] = basename($filepath, '.md');
}
Expand All @@ -92,7 +91,7 @@ public static function getMarkdownPostList(): array
{
$array = [];

foreach (glob(Hyde::path(MarkdownPost::$sourceDirectory . '/*.md')) as $filepath) {
foreach (glob(Hyde::path(MarkdownPost::$sourceDirectory.'/*.md')) as $filepath) {
if (! str_starts_with(basename($filepath), '_')) {
$array[] = basename($filepath, '.md');
}
Expand All @@ -110,7 +109,7 @@ public static function getDocumentationPageList(): array
{
$array = [];

foreach (glob(Hyde::path(DocumentationPage::$sourceDirectory. '/*.md')) as $filepath) {
foreach (glob(Hyde::path(DocumentationPage::$sourceDirectory.'/*.md')) as $filepath) {
if (! str_starts_with(basename($filepath), '_')) {
$array[] = basename($filepath, '.md');
}
Expand Down
2 changes: 1 addition & 1 deletion src/StaticPageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Converts a Page Model into a static HTML page.
*
*
* @todo Create the required directories if they don't exist.
* Can be done using a trait where an array of the required directories is passed.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/HydeBasePathCanBeChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class HydeBasePathCanBeChanged extends TestCase
{
public function test_example()
{
// TODO: Implement class
// TODO: Implement class
}
}
23 changes: 11 additions & 12 deletions tests/Feature/SourceDirectoriesCanBeChangedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function test_autodiscovery_discovers_posts_in_changed_directory()
// Using a subdirectory in a directory we know exists, to make cleanup easier.
mkdir(Hyde::path('_posts/test'));
touch(Hyde::path('_posts/test/test.md'));

MarkdownPost::$sourceDirectory = '_posts/test';

$this->assertEquals(
Expand All @@ -70,12 +70,12 @@ public function test_autodiscovery_discovers_posts_in_changed_directory()
unlink(Hyde::path('_posts/test/test.md'));
rmdir(Hyde::path('_posts/test'));
}

public function test_markdown_posts_in_changed_directory_can_be_compiled()
{
mkdir(Hyde::path('testSourceDir/blog'));
touch(Hyde::path('testSourceDir/blog/test.md'));

MarkdownPost::$sourceDirectory = 'testSourceDir/blog';

// Uses the same logic as the BuildActionRunner for an accurate test.
Expand All @@ -85,17 +85,17 @@ public function test_markdown_posts_in_changed_directory_can_be_compiled()
'test'
)->get(),
true
);
);

$this->assertFileExists(Hyde::path('_site/posts/test.html'));
unlink(Hyde::path('_site/posts/test.html'));
}

public function test_markdown_pages_in_changed_directory_can_be_compiled()
{
mkdir(Hyde::path('testSourceDir/pages'));
touch(Hyde::path('testSourceDir/pages/test.md'));

MarkdownPage::$sourceDirectory = 'testSourceDir/pages';

// Uses the same logic as the BuildActionRunner for an accurate test.
Expand All @@ -105,7 +105,7 @@ public function test_markdown_pages_in_changed_directory_can_be_compiled()
'test'
)->get(),
true
);
);

$this->assertFileExists(Hyde::path('_site/test.html'));
unlink(Hyde::path('_site/test.html'));
Expand All @@ -115,7 +115,7 @@ public function test_documentation_pages_in_changed_directory_can_be_compiled()
{
mkdir(Hyde::path('testSourceDir/documentation'));
touch(Hyde::path('testSourceDir/documentation/test.md'));

DocumentationPage::$sourceDirectory = 'testSourceDir/documentation';

// Uses the same logic as the BuildActionRunner for an accurate test.
Expand All @@ -125,18 +125,17 @@ public function test_documentation_pages_in_changed_directory_can_be_compiled()
'test'
)->get(),
true
);
);

$this->assertFileExists(Hyde::path('_site/docs/test.html'));
unlink(Hyde::path('_site/docs/test.html'));
}


public function test_blade_pages_in_changed_directory_can_be_compiled()
{
mkdir(Hyde::path('testSourceDir/blade'));
touch(Hyde::path('testSourceDir/blade/test.blade.php'));

BladePage::$sourceDirectory = 'testSourceDir/blade';
Config::set('view.paths', ['testSourceDir/blade']);

Expand All @@ -147,7 +146,7 @@ public function test_blade_pages_in_changed_directory_can_be_compiled()
'test'
)->get(),
true
);
);

$this->assertFileExists(Hyde::path('_site/test.html'));
unlink(Hyde::path('_site/test.html'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

namespace Tests\Unit;

use Hyde\Framework\Hyde;
use Hyde\Framework\Models\BladePage;
use Hyde\Framework\Models\DocumentationPage;
use Hyde\Framework\Models\MarkdownPage;
use Hyde\Framework\Models\MarkdownPost;
use Hyde\Framework\Services\BuildService;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Tests\TestCase;

/**
Expand Down