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

v0.36.x - Add package auto-discovery #35

Merged
merged 7 commits into from
Jun 15, 2022
Merged
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
2 changes: 1 addition & 1 deletion app/bootstrap.php
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
|
*/

$app = new LaravelZero\Framework\Application(
$app = new Hyde\Framework\Application(
dirname(__DIR__)
);

2 changes: 1 addition & 1 deletion bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
|
*/

$app = new LaravelZero\Framework\Application(
$app = new Hyde\Framework\Application(
dirname(__DIR__)
);

2 changes: 1 addition & 1 deletion build/tools/update-composer.php
Original file line number Diff line number Diff line change
@@ -33,5 +33,5 @@

file_put_contents('composer.json', json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));

echo "Done. Finished in " . number_format((microtime(true) - $time_start) * 1000, 2) . "ms\n";
echo 'Done. Finished in '.number_format((microtime(true) - $time_start) * 1000, 2)."ms\n";
exit(0);
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -36,6 +36,11 @@
"Hyde\\Testing\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"@php hyde package:discover --ansi"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
26 changes: 26 additions & 0 deletions packages/framework/src/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Hyde\Framework;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\PackageManifest;

class Application extends \LaravelZero\Framework\Application
{
/**
* {@inheritdoc}
*/
protected function registerBaseBindings(): void
{
parent::registerBaseBindings();

/*
* Enable auto-discovery.
*/
$this->app->singleton(PackageManifest::class, function () {
return new PackageManifest(
new Filesystem, $this->basePath(), $this->basePath('storage/framework/cache/packages.php')
);
});
}
}
18 changes: 18 additions & 0 deletions packages/framework/src/Commands/HydePackageDiscoverCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Hyde\Framework\Commands;

use Hyde\Framework\Hyde;
use Illuminate\Foundation\Console\PackageDiscoverCommand as BaseCommand;
use Illuminate\Foundation\PackageManifest;

class HydePackageDiscoverCommand extends BaseCommand
{
protected $hidden = true;

public function handle(PackageManifest $manifest)
{
$manifest->manifestPath = Hyde::path('storage/framework/cache/packages.php');
parent::handle($manifest);
}
}
2 changes: 2 additions & 0 deletions packages/framework/src/HydeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -77,6 +77,8 @@ function () {
Commands\HydeInstallCommand::class,
Commands\HydeDebugCommand::class,
Commands\HydeServeCommand::class,

Commands\HydePackageDiscoverCommand::class,
]);
}

7 changes: 3 additions & 4 deletions packages/realtime-compiler/bin/server.php
Original file line number Diff line number Diff line change
@@ -14,11 +14,10 @@
\Hyde\RealtimeCompiler\Http\ExceptionHandler::handle($exception);
exit($exception->getCode());
}

} catch (\Throwable $th) {
// Auxiliary exception handler
echo '<h1>Something went really wrong!</h1>';
echo '<p>An error occurred that the core exception handler failed to process. Here\'s all we know:</p>';
echo '<h2>Initial exception:</h2><pre>' . print_r($exception, true).'</pre>';
echo '<h2>Auxiliary exception:</h2><pre>' . print_r($th, true).'</pre>';
}
echo '<h2>Initial exception:</h2><pre>'.print_r($exception, true).'</pre>';
echo '<h2>Auxiliary exception:</h2><pre>'.print_r($th, true).'</pre>';
}
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ protected function createApplication(): void

protected function bootApplication(): void
{
if (!isset($this->laravel)) {
if (! isset($this->laravel)) {
$this->createApplication();
}

1 change: 1 addition & 0 deletions projects/rocket/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ public function render($request, Throwable $exception)
$whoops->writeToOutput(false);
$whoops->pushHandler(new PrettyPageHandler());
$html = $whoops->handleException($exception);

return response()->make($html, 500);
}

6 changes: 3 additions & 3 deletions projects/rocket/app/Http/Controllers/ApiController.php
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ public function pingRealtimeCompiler()
? response()->json(['success' => true])
: response()->json([
'success' => false,
'error' => 'Could not ping Realtime Compiler on default port 8080'
'error' => 'Could not ping Realtime Compiler on default port 8080',
]);
}

@@ -24,9 +24,9 @@ public static function isRealtimeCompilerRunning()
try {
$client = new Client(['timeout' => 1]);
$client->head('http://localhost:8080');

return true;
}
catch (\Throwable) {
} catch (\Throwable) {
return false;
}
}
10 changes: 5 additions & 5 deletions projects/rocket/app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
namespace Hyde\Rocket\Http\Controllers;

use Hyde\Framework\Models\MarkdownPost;
use Hyde\Rocket\Models\Project;
use Hyde\Framework\Services\CollectionService;
use Hyde\Rocket\Models\Project;

class DashboardController extends Controller
{
@@ -31,10 +31,10 @@ public function index()
protected function getContentList(): array
{
return array_merge([
'Blade Pages' => CollectionService::getBladePageList(),
'Markdown Pages' => CollectionService::getMarkdownPageList(),
'Markdown Posts' => CollectionService::getMarkdownPostList(),
'Documentation Pages' => CollectionService::getDocumentationPageList(),
'Blade Pages' => CollectionService::getBladePageList(),
'Markdown Pages' => CollectionService::getMarkdownPageList(),
'Markdown Posts' => CollectionService::getMarkdownPostList(),
'Documentation Pages' => CollectionService::getDocumentationPageList(),
]);
}
}
4 changes: 2 additions & 2 deletions projects/rocket/app/Http/Controllers/DebugController.php
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@

namespace Hyde\Rocket\Http\Controllers;

use Hyde\Rocket\Models\Project;
use Hyde\Framework\Hyde;
use Hyde\Rocket\Models\Project;

class DebugController extends Controller
{
@@ -19,7 +19,7 @@ public function __invoke()
$information = [
'Hyde/Framework version' => Hyde::version(),
'Hyde project path' => Hyde::path(),
'PHP version' => phpversion() . ' (' . PHP_SAPI . ')',
'PHP version' => phpversion().' ('.PHP_SAPI.')',
'Lumen version' => app()->version(),
];
dump($information);
14 changes: 7 additions & 7 deletions projects/rocket/app/Http/Controllers/FilesystemController.php
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ class FilesystemController extends Controller
public function __construct()
{
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
throw new \Exception('This API is only supported on Windows. ' .
throw new \Exception('This API is only supported on Windows. '.
'Please send a PR to open up support for other systems!');
}
}
@@ -26,27 +26,27 @@ public function open(Request $request)
{
if (! $request->has('path')) {
return response()->json([
'error' => 'Missing path parameter.'
'error' => 'Missing path parameter.',
], 400);
}

$file = trim(Project::get()->path . '/' . $request->input('path'), '/');
$file = trim(Project::get()->path.'/'.$request->input('path'), '/');

if (! file_exists($file)) {
return response()->json([
'error' => 'File does not exist.'
'error' => 'File does not exist.',
], 404);
}

if (is_dir($file)) {
shell_exec('explorer.exe "' . $file . '"');
shell_exec('explorer.exe "'.$file.'"');
} else {
shell_exec('start "" "' . $file . '"');
shell_exec('start "" "'.$file.'"');
}

if ($request->expectsJson()) {
return response()->json([
'success' => true
'success' => true,
]);
}

10 changes: 5 additions & 5 deletions projects/rocket/app/Http/Controllers/PostController.php
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ class PostController extends Controller
{
public function show(string $slug, Request $request)
{
$path = Hyde::path($localPath = '_posts/' . $slug . '.md');
$path = Hyde::path($localPath = '_posts/'.$slug.'.md');

if (! file_exists($path)) {
return response('File not found.', 404);
@@ -40,7 +40,7 @@ public function store(Request $request)
$request->input('description'),
$request->input('category'),
$request->input('author')
);
);

try {
$creator->save();
@@ -50,19 +50,19 @@ public function store(Request $request)
]);
}

return redirect('/_posts/' . $creator->slug . '?saved=true');
return redirect('/_posts/'.$creator->slug.'?saved=true');
}

public function update(string $slug, Request $request)
{
$path = Hyde::path('_posts/' . $slug . '.md');
$path = Hyde::path('_posts/'.$slug.'.md');

if (! file_exists($path)) {
return response('File not found.', 404);
}

file_put_contents($path, $request->get('markdown'));

return redirect('/_posts/' . $slug . '?saved=true');
return redirect('/_posts/'.$slug.'?saved=true');
}
}
4 changes: 2 additions & 2 deletions projects/rocket/app/Http/Controllers/RealtimeCompiler.php
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ public function render(Request $request)
{
$path = $request->get('path', '');

return redirect('http://localhost:8080/' . $path);
return redirect('http://localhost:8080/'.$path);
}

public function markdown(Request $request)
@@ -32,7 +32,7 @@ public function markdown(Request $request)

return view('markdown-preview', [
'page' => basename($path),
'markdown' => Str::markdown(YamlFrontMatter::markdownCompatibleParse(file_get_contents($path))->body())
'markdown' => Str::markdown(YamlFrontMatter::markdownCompatibleParse(file_get_contents($path))->body()),
]);
}
}
4 changes: 2 additions & 2 deletions projects/rocket/app/Models/Artisan.php
Original file line number Diff line number Diff line change
@@ -19,14 +19,14 @@ public function __construct(string $absoluteProjectPath)
*/
public function run(string $command): string
{
return shell_exec('cd '.$this->path.' && php hyde ' . $command);
return shell_exec('cd '.$this->path.' && php hyde '.$command);
}

/**
* Run a command in the project's HydeCLI and stream the output.
*/
public function passthru(string $command): void
{
passthru('cd '.$this->path.' && php hyde ' . $command);
passthru('cd '.$this->path.' && php hyde '.$command);
}
}
16 changes: 8 additions & 8 deletions projects/rocket/app/Models/Project.php
Original file line number Diff line number Diff line change
@@ -26,13 +26,14 @@ protected function __construct()

protected function getPathOrFail(): string
{
$path = realpath(getcwd() . '/../../');
if (!is_dir($path)) {
throw new \Exception("Not a directory.");
$path = realpath(getcwd().'/../../');
if (! is_dir($path)) {
throw new \Exception('Not a directory.');
}
if (!is_file($path . '/hyde')) {
throw new \Exception("Not a Hyde project.");
if (! is_file($path.'/hyde')) {
throw new \Exception('Not a Hyde project.');
}

return $path;
}

@@ -52,18 +53,17 @@ public function artisan(): Artisan
*/
public static function get(?string $property = null): mixed
{
if (!isset(static::$instance)) {
if (! isset(static::$instance)) {
static::$instance = new static();
}

return isset($property)
? static::$instance->$property
: static::$instance;

}

protected function getVersion()
{
return json_decode(file_get_contents($this->path . '/composer.json'))->require->{'hyde/framework'};
return json_decode(file_get_contents($this->path.'/composer.json'))->require->{'hyde/framework'};
}
}
4 changes: 2 additions & 2 deletions projects/rocket/app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
$this->app->singleton(\Desilva\Console\Contracts\Console::class, function() {
$this->app->singleton(\Desilva\Console\Contracts\Console::class, function () {
return new \Desilva\Console\Console;
});
}

/**
/**
* Bootstrap any application services.
*
* @return void
1 change: 0 additions & 1 deletion projects/rocket/bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@

date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));


/*
|--------------------------------------------------------------------------
| Create The Application
1 change: 0 additions & 1 deletion projects/rocket/routes/web.php
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@
$router->get('/create-post', 'PostController@create');
$router->post('/create-post', 'PostController@store');


$router->post('/fileapi/open', 'FilesystemController@open');
$router->get('/open/_site', 'RealtimeCompiler@render');
$router->get('/render/markdown', 'RealtimeCompiler@markdown');
3 changes: 0 additions & 3 deletions projects/rocket/tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -2,9 +2,6 @@

namespace Tests;

use Laravel\Lumen\Testing\DatabaseMigrations;
use Laravel\Lumen\Testing\DatabaseTransactions;

class ExampleTest extends TestCase
{
/**
235 changes: 119 additions & 116 deletions projects/shelf/single-file-dashboard/dashboard.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/Feature/AuthorHelperTest.php
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@

use Hyde\Framework\Helpers\Author as AuthorHelper;
use Hyde\Framework\Models\Author as AuthorModel;
use Hyde\Testing\TestCase;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Config;
use Hyde\Testing\TestCase;

/**
* Class AuthorHelperTest.
2 changes: 1 addition & 1 deletion tests/Feature/AuthorPostsIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
use Hyde\Framework\Actions\CreatesNewMarkdownPostFile;
use Hyde\Framework\Helpers\Author;
use Hyde\Framework\Hyde;
use Illuminate\Support\Facades\Config;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;

/**
* Test that the Author feature works in
2 changes: 1 addition & 1 deletion tests/Feature/BuildOutputDirectoryCanBeChangedTest.php
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
use Hyde\Framework\Hyde;
use Hyde\Framework\Services\RebuildService;
use Hyde\Framework\StaticPageBuilder;
use Illuminate\Support\Facades\File;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\File;

/**
* Class BuildOutputDirectoryCanBeChangedTest.
2 changes: 1 addition & 1 deletion tests/Feature/Commands/HydeUpdateConfigsCommandTest.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

use Hyde\Framework\Commands\HydeUpdateConfigsCommand;
use Hyde\Framework\Hyde;
use Illuminate\Support\Facades\File;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\File;

/**
* @covers \Hyde\Framework\Commands\HydeUpdateConfigsCommand
2 changes: 1 addition & 1 deletion tests/Feature/Concerns/GeneratesPageMetadataTest.php
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
namespace Hyde\Testing\Feature\Concerns;

use Hyde\Framework\Concerns\GeneratesPageMetadata;
use Illuminate\Support\Facades\Config;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;

/**
* @covers \Hyde\Framework\Concerns\GeneratesPageMetadata
2 changes: 1 addition & 1 deletion tests/Feature/ConfigurableFeaturesTest.php
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
namespace Hyde\Testing\Feature;

use Hyde\Framework\Helpers\Features;
use Illuminate\Support\Facades\Config;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;

/**
* @covers \Hyde\Framework\Helpers\Features
2 changes: 1 addition & 1 deletion tests/Feature/DarkmodeFeatureTest.php
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
use Hyde\Framework\Helpers\Features;
use Hyde\Framework\Models\DocumentationPage;
use Hyde\Framework\Models\MarkdownPage;
use Illuminate\Support\Facades\Config;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;

/**
* @covers \Hyde\Framework\Helpers\Features::darkmode
2 changes: 1 addition & 1 deletion tests/Feature/FindsContentLengthForImageObjectTest.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@
namespace Hyde\Testing\Feature;

use Hyde\Framework\Models\Image;
use Hyde\Testing\TestCase;
use Illuminate\Http\Client\Request;
use Illuminate\Support\Facades\Http;
use Hyde\Testing\TestCase;

/**
* @covers \Hyde\Framework\Actions\FindsContentLengthForImageObject
2 changes: 1 addition & 1 deletion tests/Feature/GeneratesNavigationMenuTest.php
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@

use Hyde\Framework\Actions\GeneratesNavigationMenu;
use Hyde\Framework\Hyde;
use Hyde\Testing\TestCase;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;
use Hyde\Testing\TestCase;

class GeneratesNavigationMenuTest extends TestCase
{
2 changes: 1 addition & 1 deletion tests/Feature/MarkdownPageTest.php
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
use Hyde\Framework\Models\MarkdownPage;
use Hyde\Framework\Models\Parsers\MarkdownPageParser;
use Hyde\Framework\Services\CollectionService;
use Illuminate\Support\Facades\File;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\File;

/**
* Test the Markdown page parser.
2 changes: 1 addition & 1 deletion tests/Feature/Services/DocumentationSidebarServiceTest.php
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@
use Hyde\Framework\Models\DocumentationSidebar;
use Hyde\Framework\Models\DocumentationSidebarItem;
use Hyde\Framework\Services\DocumentationSidebarService;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Hyde\Testing\TestCase;

/**
* @covers \Hyde\Framework\Services\DocumentationSidebarService
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

use Hyde\Framework\Concerns\Markdown\HasConfigurableMarkdownFeatures;
use Hyde\Framework\Models\DocumentationPage;
use Illuminate\Support\Facades\Config;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;

/**
* @covers \Hyde\Framework\Concerns\Markdown\HasConfigurableMarkdownFeatures
2 changes: 1 addition & 1 deletion tests/Feature/Services/SitemapServiceTest.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

use Hyde\Framework\Hyde;
use Hyde\Framework\Services\SitemapService;
use Illuminate\Support\Facades\File;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\File;

/**
* @covers \Hyde\Framework\Services\SitemapService
2 changes: 1 addition & 1 deletion tests/Feature/StaticPageBuilderTest.php
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@
use Hyde\Framework\Models\MarkdownPage;
use Hyde\Framework\Models\MarkdownPost;
use Hyde\Framework\StaticPageBuilder;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Hyde\Testing\TestCase;

/**
* Feature tests for the StaticPageBuilder class.
3 changes: 1 addition & 2 deletions tests/TestListener.php
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@

class TestListener implements \PHPUnit\Framework\TestListener
{

public function addError(Test $test, Throwable $t, float $time): void
{
//
@@ -63,4 +62,4 @@ public function endTest(Test $test, float $time): void
{
//
}
}
}
2 changes: 1 addition & 1 deletion tests/Unit/BlogPostFrontMatterIsOptionalTest.php
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
namespace Hyde\Testing\Unit;

use Hyde\Framework\Hyde;
use Illuminate\Support\Facades\Artisan;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Artisan;

class BlogPostFrontMatterIsOptionalTest extends TestCase
{
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
use Hyde\Framework\Models\MarkdownPage;
use Hyde\Framework\Models\MarkdownPost;
use Hyde\Framework\Services\DiscoveryService;
use Illuminate\Support\Facades\Config;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;

/**
* Class DiscoveryServiceCanFindModelFromCustomSourceFilePathTest.
2 changes: 1 addition & 1 deletion tests/Unit/GetLatestMarkdownPostsTest.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

use Hyde\Framework\Hyde;
use Hyde\Framework\Models\MarkdownPost;
use Illuminate\Support\Collection;
use Hyde\Testing\TestCase;
use Illuminate\Support\Collection;

/**
* @see \Hyde\Framework\Models\MarkdownPost::latest()
2 changes: 1 addition & 1 deletion tests/Unit/HasMarkdownFeaturesTest.php
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
namespace Hyde\Testing\Unit;

use Hyde\Framework\Concerns\Markdown\HasMarkdownFeatures;
use Illuminate\Support\Facades\Config;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;

/**
* @covers \Hyde\Framework\Concerns\Markdown\HasMarkdownFeatures
2 changes: 1 addition & 1 deletion tests/Unit/HydeGetLatestPostsHelperTest.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

use Hyde\Framework\Hyde;
use Hyde\Framework\Models\MarkdownPost;
use Illuminate\Support\Collection;
use Hyde\Testing\TestCase;
use Illuminate\Support\Collection;

/**
* @deprecated as parent method is deprecated
21 changes: 10 additions & 11 deletions tests/Unit/HydePathHelperTest.php
Original file line number Diff line number Diff line change
@@ -22,36 +22,35 @@ public function test_string_is_returned()
$this->assertIsString(Hyde::path());
}


public function test_returned_directory_contains_content_expected_to_be_in_the_project_directory()
{
$this->assertTrue(
file_exists(Hyde::path() . DIRECTORY_SEPARATOR . 'hyde') &&
file_exists(Hyde::path() . DIRECTORY_SEPARATOR . '_pages') &&
file_exists(Hyde::path() . DIRECTORY_SEPARATOR . '_posts') &&
file_exists(Hyde::path() . DIRECTORY_SEPARATOR . '_site')
file_exists(Hyde::path().DIRECTORY_SEPARATOR.'hyde') &&
file_exists(Hyde::path().DIRECTORY_SEPARATOR.'_pages') &&
file_exists(Hyde::path().DIRECTORY_SEPARATOR.'_posts') &&
file_exists(Hyde::path().DIRECTORY_SEPARATOR.'_site')
);
}

public function test_method_returns_qualified_file_path_when_supplied_with_argument()
{
$this->assertEquals(Hyde::path('file.php'), Hyde::path() . DIRECTORY_SEPARATOR . 'file.php');
$this->assertEquals(Hyde::path('file.php'), Hyde::path().DIRECTORY_SEPARATOR.'file.php');
}

public function test_method_strips_trailing_directory_separators_from_argument()
{
$this->assertEquals(Hyde::path('\\/file.php/'), Hyde::path() . DIRECTORY_SEPARATOR . 'file.php');
$this->assertEquals(Hyde::path('\\/file.php/'), Hyde::path().DIRECTORY_SEPARATOR.'file.php');
}

public function test_method_returns_expected_value_for_nested_path_arguments()
{
$this->assertEquals(Hyde::path('directory/file.php'), Hyde::path() . DIRECTORY_SEPARATOR . 'directory/file.php');
$this->assertEquals(Hyde::path('directory/file.php'), Hyde::path().DIRECTORY_SEPARATOR.'directory/file.php');
}

public function test_method_returns_expected_value_regardless_of_trailing_directory_separators_in_argument()
{
$this->assertEquals(Hyde::path('directory/file.php/'), Hyde::path() . DIRECTORY_SEPARATOR . 'directory/file.php');
$this->assertEquals(Hyde::path('/directory/file.php/'), Hyde::path() . DIRECTORY_SEPARATOR . 'directory/file.php');
$this->assertEquals(Hyde::path('\\/directory/file.php/'), Hyde::path() . DIRECTORY_SEPARATOR . 'directory/file.php');
$this->assertEquals(Hyde::path('directory/file.php/'), Hyde::path().DIRECTORY_SEPARATOR.'directory/file.php');
$this->assertEquals(Hyde::path('/directory/file.php/'), Hyde::path().DIRECTORY_SEPARATOR.'directory/file.php');
$this->assertEquals(Hyde::path('\\/directory/file.php/'), Hyde::path().DIRECTORY_SEPARATOR.'directory/file.php');
}
}
2 changes: 1 addition & 1 deletion tests/Unit/InteractsWithDirectoriesConcernTest.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

use Hyde\Framework\Concerns\InteractsWithDirectories;
use Hyde\Framework\Hyde;
use Illuminate\Support\Facades\File;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\File;

/**
* Class InteractsWithDirectoriesConcernTest.
2 changes: 1 addition & 1 deletion tests/Unit/PageModelGetHelperTest.php
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
use Hyde\Framework\Models\DocumentationPage;
use Hyde\Framework\Models\MarkdownPage;
use Hyde\Framework\Models\MarkdownPost;
use Illuminate\Support\Collection;
use Hyde\Testing\TestCase;
use Illuminate\Support\Collection;

/**
* @see \Hyde\Framework\Concerns\AbstractPage::all()
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@
use Hyde\Framework\Models\MarkdownPost;
use Hyde\Framework\Services\DiscoveryService;
use Hyde\Framework\StaticPageBuilder;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Hyde\Testing\TestCase;

/**
* Class SourceFilesInCustomDirectoriesCanBeCompiledTest.
2 changes: 1 addition & 1 deletion tests/Unit/Views/ArticleExcerptViewTest.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

use Hyde\Framework\Hyde;
use Hyde\Framework\Models\MarkdownPost;
use Illuminate\Support\Facades\Blade;
use Hyde\Testing\TestCase;
use Illuminate\Support\Facades\Blade;

/**
* @see resources/views/components/article-excerpt.blade.php