Skip to content

Commit

Permalink
update testbench, use laravel pint
Browse files Browse the repository at this point in the history
  • Loading branch information
heidkaemper committed Apr 28, 2024
1 parent b1a163c commit 35364af
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 77 deletions.
43 changes: 0 additions & 43 deletions .php-cs-fixer.php

This file was deleted.

10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"mck89/peast": "^1.16"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.54",
"orchestra/testbench": "^8.21",
"pestphp/pest": "^2.33"
"orchestra/testbench": "^9.0",
"pestphp/pest": "^2.34",
"laravel/pint": "^1.15"
},
"autoload": {
"psr-4": {
Expand All @@ -23,8 +23,8 @@
}
},
"scripts": {
"phpcs": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --allow-risky=yes --dry-run --verbose --diff",
"phpcs:fix": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --allow-risky=yes",
"phpcs": "vendor/bin/pint -v --test",
"phpcs:fix": "vendor/bin/pint",
"test": "vendor/bin/pest"
},
"extra": {
Expand Down
8 changes: 8 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"preset": "laravel",
"rules": {
"concat_space": {
"spacing": "one"
}
}
}
4 changes: 2 additions & 2 deletions src/Breakpoints/Parser/BootstrapParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class BootstrapParser
'xxl' => 'min-width: 1400px',
];

protected array|null $screens = null;
protected ?array $screens = null;

public function __construct(
protected array $files,
) {
}

public function parse(): array|null
public function parse(): ?array
{
if (! $this->guessWetherBootstrapIsUsed()) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Breakpoints/Parser/PicoParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PicoParser
'xl' => 'min-width: 1200px',
];

public function parse(): array|null
public function parse(): ?array
{
if (! $this->guessWetherPicoIsUsed()) {
return null;
Expand Down
8 changes: 4 additions & 4 deletions src/Breakpoints/Parser/TailwindParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class TailwindParser
'2xl' => 'min-width: 1536px',
];

protected array|null $screens = null;
protected ?array $screens = null;

public function __construct(
protected array $files,
) {
}

public function parse(): array|null
public function parse(): ?array
{
if (! $this->guessWetherTailwindIsUsed()) {
return null;
Expand Down Expand Up @@ -97,12 +97,12 @@ private function parseConfigFile($filename): void
$this->sortByMinWidth();
}

private function getRawKeyName($key): string|null
private function getRawKeyName($key): ?string
{
return $key instanceof StringLiteral ? $key?->getValue() : $key?->getRawName();
}

private function getBreakpointMedia($media): string|null
private function getBreakpointMedia($media): ?string
{
if ($media instanceof StringLiteral) {
$value = $media->getValue();
Expand Down
8 changes: 4 additions & 4 deletions src/Controllers/ToolbarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function trimSiteFromPath(string $path, string $site): string
return Str::ensureLeft($path, '/');
}

protected function getBreakpoints(): array|null
protected function getBreakpoints(): ?array
{
if (! config('statamic.toolbar.components.breakpoint', true)) {
return null;
Expand All @@ -68,7 +68,7 @@ protected function getBreakpoints(): array|null
return (new Breakpoints())->toArray();
}

protected function getSite(): string|null
protected function getSite(): ?string
{
if (! config('statamic.toolbar.components.site', true)) {
return null;
Expand All @@ -77,7 +77,7 @@ protected function getSite(): string|null
return $this->entry?->site()->handle;
}

protected function getTemplate(): string|null
protected function getTemplate(): ?string
{
if (! config('statamic.toolbar.components.template', true)) {
return null;
Expand All @@ -92,7 +92,7 @@ protected function getTemplate(): string|null
return $route->parameters()['view'] ?? null;
}

protected function getCpLink(): string|null
protected function getCpLink(): ?string
{
if (! config('statamic.toolbar.components.cp_link', true) || ! auth()->check()) {
return null;
Expand Down
19 changes: 1 addition & 18 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,17 @@ protected function getPackageProviders($app): array
{
return [
\Statamic\Providers\StatamicServiceProvider::class,
\Wilderborn\Partyline\ServiceProvider::class,
\Heidkaemper\Toolbar\ServiceProvider::class,
];
}

protected function getPackageAliases($app)
{
return [
'Statamic' => Statamic::class,
];
}

protected function resolveApplicationConfiguration($app)
{
parent::resolveApplicationConfiguration($app);

$configs = [
'assets', 'cp', 'forms', 'routes', 'static_caching',
'sites', 'stache', 'system', 'users',
];

foreach ($configs as $config) {
$app['config']->set("statamic.{$config}", require(__DIR__ . "/../vendor/statamic/cms/config/{$config}.php"));
}

$app['config']->set('statamic.users.repository', 'file');

$app['config']->set("statamic.toolbar", require(__DIR__ . '/../config/toolbar.php'));
$app['config']->set('statamic.toolbar', require (__DIR__ . '/../config/toolbar.php'));
}

protected function setUpTestEntry(): void
Expand Down

0 comments on commit 35364af

Please sign in to comment.