@@ -11,17 +11,17 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | define('BASE_PATH', realpath(__DIR__.'/../../../')); |
| 13 | 13 | |
| 14 | -if (BASE_PATH === false || ! file_exists(BASE_PATH.'/hyde')) { |
|
| 14 | +if (BASE_PATH === false || !file_exists(BASE_PATH.'/hyde')) { |
|
| 15 | 15 | throw new InvalidArgumentException('This test suite must be run from the root of the hydephp/develop monorepo.'); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | ob_start(); |
| 19 | 19 | |
| 20 | -beforeEach(function () { |
|
| 20 | +beforeEach(function() { |
|
| 21 | 21 | putenv('SERVER_LIVE_EDIT=false'); |
| 22 | 22 | }); |
| 23 | 23 | |
| 24 | -it('handles routes index page', function () { |
|
| 24 | +it('handles routes index page', function() { |
|
| 25 | 25 | putenv('SERVER_DASHBOARD=false'); |
| 26 | 26 | mockRoute(''); |
| 27 | 27 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | Filesystem::unlink('_site/index.html'); |
| 41 | 41 | }); |
| 42 | 42 | |
| 43 | -it('handles routes custom pages', function () { |
|
| 43 | +it('handles routes custom pages', function() { |
|
| 44 | 44 | mockRoute('foo'); |
| 45 | 45 | |
| 46 | 46 | Filesystem::put('_pages/foo.md', '# Hello World!'); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | Filesystem::unlink('_site/foo.html'); |
| 59 | 59 | }); |
| 60 | 60 | |
| 61 | -it('handles routes pages with .html extension', function () { |
|
| 61 | +it('handles routes pages with .html extension', function() { |
|
| 62 | 62 | mockRoute('foo.html'); |
| 63 | 63 | |
| 64 | 64 | Filesystem::put('_pages/foo.md', '# Hello World!'); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | Filesystem::unlink('_site/foo.html'); |
| 77 | 77 | }); |
| 78 | 78 | |
| 79 | -it('handles routes static assets', function () { |
|
| 79 | +it('handles routes static assets', function() { |
|
| 80 | 80 | mockRoute('media/app.css'); |
| 81 | 81 | |
| 82 | 82 | $kernel = new HttpKernel(); |
@@ -89,14 +89,14 @@ discard block |
||
| 89 | 89 | expect($response->body)->toBe(file_get_contents(\Hyde\Hyde::path('_media/app.css'))); |
| 90 | 90 | }); |
| 91 | 91 | |
| 92 | -it('handles throws route not found exception for missing route', function () { |
|
| 92 | +it('handles throws route not found exception for missing route', function() { |
|
| 93 | 93 | mockRoute('missing'); |
| 94 | 94 | |
| 95 | 95 | $kernel = new HttpKernel(); |
| 96 | 96 | $kernel->handle(new Request()); |
| 97 | 97 | })->throws(RouteNotFoundException::class, 'Route [missing] not found'); |
| 98 | 98 | |
| 99 | -it('handles sends 404 error response for missing asset', function () { |
|
| 99 | +it('handles sends 404 error response for missing asset', function() { |
|
| 100 | 100 | mockRoute('missing.css'); |
| 101 | 101 | |
| 102 | 102 | $kernel = new HttpKernel(); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | // Filesystem::unlink('_site/foo.html'); |
| 128 | 128 | //})->skip('Underlying framework does not buffer headers (yet)'); |
| 129 | 129 | |
| 130 | -test('trailing slashes are normalized from route', function () { |
|
| 130 | +test('trailing slashes are normalized from route', function() { |
|
| 131 | 131 | mockRoute('foo/'); |
| 132 | 132 | |
| 133 | 133 | Filesystem::put('_pages/foo.md', '# Hello World!'); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | Filesystem::unlink('_site/foo.html'); |
| 146 | 146 | }); |
| 147 | 147 | |
| 148 | -test('docs uri path is rerouted to docs/index', function () { |
|
| 148 | +test('docs uri path is rerouted to docs/index', function() { |
|
| 149 | 149 | mockRoute('docs'); |
| 150 | 150 | |
| 151 | 151 | Filesystem::put('_docs/index.md', '# Hello World!'); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | Filesystem::unlink('_site/docs/index.html'); |
| 164 | 164 | }); |
| 165 | 165 | |
| 166 | -test('docs/search renders search page', function () { |
|
| 166 | +test('docs/search renders search page', function() { |
|
| 167 | 167 | mockRoute('docs/search'); |
| 168 | 168 | |
| 169 | 169 | $kernel = new HttpKernel(); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | Filesystem::unlink('_site/docs/search.html'); |
| 179 | 179 | }); |
| 180 | 180 | |
| 181 | -test('ping route returns ping response', function () { |
|
| 181 | +test('ping route returns ping response', function() { |
|
| 182 | 182 | mockRoute('ping'); |
| 183 | 183 | |
| 184 | 184 | $kernel = new HttpKernel(); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | ->and($response->statusMessage)->toBe('OK'); |
| 190 | 190 | }); |
| 191 | 191 | |
| 192 | -test('exception handling', function () { |
|
| 192 | +test('exception handling', function() { |
|
| 193 | 193 | $exception = new Exception('foo'); |
| 194 | 194 | $response = ExceptionHandler::handle($exception); |
| 195 | 195 | |
@@ -98,6 +98,6 @@ |
||
| 98 | 98 | |
| 99 | 99 | protected function isPageDiscoverable(): bool |
| 100 | 100 | { |
| 101 | - return filled($this->route->getSourcePath()) && ! $this->route->getPage() instanceof InMemoryPage; |
|
| 101 | + return filled($this->route->getSourcePath()) && !$this->route->getPage() instanceof InMemoryPage; |
|
| 102 | 102 | } |
| 103 | 103 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | protected function getEnvironmentVariables(): array |
| 83 | 83 | { |
| 84 | 84 | return Arr::whereNotNull([ |
| 85 | - 'HYDE_SERVER_REQUEST_OUTPUT' => ! $this->option('no-ansi'), |
|
| 85 | + 'HYDE_SERVER_REQUEST_OUTPUT' => !$this->option('no-ansi'), |
|
| 86 | 86 | 'HYDE_SERVER_SAVE_PREVIEW' => $this->parseEnvironmentOption('save-preview'), |
| 87 | 87 | 'HYDE_SERVER_DASHBOARD' => $this->parseEnvironmentOption('dashboard'), |
| 88 | 88 | 'HYDE_PRETTY_URLS' => $this->parseEnvironmentOption('pretty-urls'), |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | protected function configureOutput(): void |
| 94 | 94 | { |
| 95 | - if (! $this->useBasicOutput()) { |
|
| 95 | + if (!$this->useBasicOutput()) { |
|
| 96 | 96 | $this->console = new ConsoleOutput($this->output->isVerbose()); |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | protected function getOutputHandler(): Closure |
| 108 | 108 | { |
| 109 | - return $this->useBasicOutput() ? function (string $type, string $line): void { |
|
| 109 | + return $this->useBasicOutput() ? function(string $type, string $line): void { |
|
| 110 | 110 | $this->output->write($line); |
| 111 | 111 | } : $this->console->getFormatter(); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | protected function useBasicOutput(): bool |
| 115 | 115 | { |
| 116 | - return $this->option('no-ansi') || ! class_exists(ConsoleOutput::class); |
|
| 116 | + return $this->option('no-ansi') || !class_exists(ConsoleOutput::class); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | protected function parseEnvironmentOption(string $name): ?string |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $process = $binary ? Process::command($command)->run() : null; |
| 159 | 159 | |
| 160 | - if (! $process || $process->failed()) { |
|
| 160 | + if (!$process || $process->failed()) { |
|
| 161 | 161 | $this->warn('Unable to open the site preview in the browser on your system:'); |
| 162 | 162 | $this->line(sprintf(' %s', str_replace("\n", "\n ", $process ? $process->errorOutput() : "Missing suitable 'open' binary."))); |
| 163 | 163 | $this->newLine(); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function vendorPath(string $path = '', string $package = 'framework'): string |
| 138 | 138 | { |
| 139 | - if (PharSupport::running() && ! PharSupport::hasVendorDirectory()) { |
|
| 139 | + if (PharSupport::running() && !PharSupport::hasVendorDirectory()) { |
|
| 140 | 140 | return PharSupport::vendorPath($path, $package); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function touch(string|array $path): bool |
| 152 | 152 | { |
| 153 | - return collect($path)->map(function (string $path): bool { |
|
| 153 | + return collect($path)->map(function(string $path): bool { |
|
| 154 | 154 | return touch($this->path($path)); |
| 155 | 155 | })->contains(false) === false; |
| 156 | 156 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function unlink(string|array $path): bool |
| 164 | 164 | { |
| 165 | - return collect($path)->map(function (string $path): bool { |
|
| 165 | + return collect($path)->map(function(string $path): bool { |
|
| 166 | 166 | return unlink($this->path($path)); |
| 167 | 167 | })->contains(false) === false; |
| 168 | 168 | } |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | /** @return array<string, DropdownNavItem> */ |
| 31 | 31 | public function getDropdowns(): array |
| 32 | 32 | { |
| 33 | - if (! $this->dropdownsEnabled()) { |
|
| 33 | + if (!$this->dropdownsEnabled()) { |
|
| 34 | 34 | throw new BadMethodCallException('Dropdowns are not enabled. Enable it by setting `hyde.navigation.subdirectories` to `dropdown`.'); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - return $this->items->filter(function (NavItem $item): bool { |
|
| 37 | + return $this->items->filter(function(NavItem $item): bool { |
|
| 38 | 38 | return $item instanceof DropdownNavItem; |
| 39 | 39 | })->values()->all(); |
| 40 | 40 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | protected function canAddRoute(Route $route): bool |
| 63 | 63 | { |
| 64 | - return parent::canAddRoute($route) && (! $route->getPage() instanceof DocumentationPage || $route->is(DocumentationPage::homeRouteName())); |
|
| 64 | + return parent::canAddRoute($route) && (!$route->getPage() instanceof DocumentationPage || $route->is(DocumentationPage::homeRouteName())); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected function canAddItemToDropdown(NavItem $item): bool |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | private function hasGroupExplicitlySetInFrontMatter(): bool |
| 78 | 78 | { |
| 79 | - return $this->hasDropdowns ??= $this->items->contains(function (NavItem $item): bool { |
|
| 79 | + return $this->hasDropdowns ??= $this->items->contains(function(NavItem $item): bool { |
|
| 80 | 80 | return ($item->getGroup() !== null) && ($item->destination !== (string) DocumentationPage::home()); |
| 81 | 81 | }); |
| 82 | 82 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | protected function file(string $path, ?string $contents = null): void |
| 24 | 24 | { |
| 25 | - if (! is_dir(dirname($path))) { |
|
| 25 | + if (!is_dir(dirname($path))) { |
|
| 26 | 26 | $this->directory(dirname($path)); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | if (sizeof($this->fileMemory) > 0) { |
| 64 | 64 | foreach ($this->fileMemory as $file) { |
| 65 | 65 | if (Filesystem::isDirectory($file)) { |
| 66 | - if (! in_array($file, ['_site', '_media', '_pages', '_posts', '_docs', 'app', 'config', 'storage', 'vendor', 'node_modules'])) { |
|
| 66 | + if (!in_array($file, ['_site', '_media', '_pages', '_posts', '_docs', 'app', 'config', 'storage', 'vendor', 'node_modules'])) { |
|
| 67 | 67 | Filesystem::deleteDirectory($file); |
| 68 | 68 | } |
| 69 | 69 | } else { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | static::needsDirectory(static::$sourceDirectory); |
| 53 | 53 | |
| 54 | - return new static(static::findFiles($name, 'md')->mapWithKeys(function (string $file): array { |
|
| 54 | + return new static(static::findFiles($name, 'md')->mapWithKeys(function(string $file): array { |
|
| 55 | 55 | return [static::makeIdentifier($file) => MarkdownFileParser::parse($file)]; |
| 56 | 56 | })); |
| 57 | 57 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | static::needsDirectory(static::$sourceDirectory); |
| 69 | 69 | |
| 70 | - return new static(static::findFiles($name, ['yaml', 'yml'])->mapWithKeys(function (string $file): array { |
|
| 70 | + return new static(static::findFiles($name, ['yaml', 'yml'])->mapWithKeys(function(string $file): array { |
|
| 71 | 71 | return [static::makeIdentifier($file) => MarkdownFileParser::parse($file)->matter()]; |
| 72 | 72 | })); |
| 73 | 73 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | static::needsDirectory(static::$sourceDirectory); |
| 85 | 85 | |
| 86 | - return new static(static::findFiles($name, 'json')->mapWithKeys(function (string $file) use ($asArray): array { |
|
| 86 | + return new static(static::findFiles($name, 'json')->mapWithKeys(function(string $file) use ($asArray): array { |
|
| 87 | 87 | return [static::makeIdentifier($file) => json_decode(Filesystem::get($file), $asArray)]; |
| 88 | 88 | })); |
| 89 | 89 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | return match ($this->option('format')) { |
| 32 | 32 | 'txt' => $this->table($this->makeHeader($routes), $routes) ?? Command::SUCCESS, |
| 33 | - 'json' => $this->writeRaw(json_encode($routes, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)) ?? Command::SUCCESS, |
|
| 33 | + 'json' => $this->writeRaw(json_encode($routes, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)) ?? Command::SUCCESS, |
|
| 34 | 34 | default => $this->error("Invalid format provided. Only 'txt' and 'json' are supported.") ?? Command::FAILURE, |
| 35 | 35 | }; |
| 36 | 36 | } |