diff --git a/app/Http/Resources/Views/Public/Formatters/CopyrightFormatterResource.php b/app/Http/Resources/Formatters/CopyrightFormatterResource.php similarity index 85% rename from app/Http/Resources/Views/Public/Formatters/CopyrightFormatterResource.php rename to app/Http/Resources/Formatters/CopyrightFormatterResource.php index 86cf6b93..1919cbb1 100644 --- a/app/Http/Resources/Views/Public/Formatters/CopyrightFormatterResource.php +++ b/app/Http/Resources/Formatters/CopyrightFormatterResource.php @@ -1,6 +1,6 @@ getValue(); + + $php_version = (new PhpVersionFormatterResource)->getValue(); $php_delimiter_position = strrpos(PHP_VERSION, '.'); $php_version = $php_delimiter_position @@ -58,7 +58,7 @@ public function getItem(): array 'html' => implode('', [ '

Stack

For PHP v' . $php_version . '

', + '

Running on PHP v' . $php_version . '

', ]), ]; } diff --git a/app/Http/Resources/Views/MetadataViewResource.php b/app/Http/Resources/Views/MetadataViewResource.php index fd4d9095..ce4ad404 100644 --- a/app/Http/Resources/Views/MetadataViewResource.php +++ b/app/Http/Resources/Views/MetadataViewResource.php @@ -4,7 +4,7 @@ use App\Http\Resources\Views\Navbars\DesktopNavbarResource; use App\Http\Resources\Views\Navbars\MobileNavbarResource; -use App\Http\Resources\Views\Public\Formatters\CopyrightFormatterResource; +use App\Http\Resources\Formatters\CopyrightFormatterResource; use App\Interfaces\Resources\Items\ArrayToItemInterface; use Illuminate\Support\Facades\Route; diff --git a/tests/Datasets/Blocks.php b/tests/Datasets/Blocks.php index 2c931f2f..f2503515 100644 --- a/tests/Datasets/Blocks.php +++ b/tests/Datasets/Blocks.php @@ -1,19 +1,18 @@ getValue(); +$php_version = (new PhpVersionFormatterResource)->getValue(); $stack_html = '

Stack

For PHP v8.2.x

'; + . '

Running on PHP v' . $php_version . '

'; $tabs = ['tabs' => ['Tab One', 'Tab Two']]; diff --git a/tests/Unit/App/Http/HttpArchitectureTest.php b/tests/Unit/App/Http/HttpArchitectureTest.php index 302f47ad..7f2ecf5b 100644 --- a/tests/Unit/App/Http/HttpArchitectureTest.php +++ b/tests/Unit/App/Http/HttpArchitectureTest.php @@ -34,6 +34,12 @@ ->expect('App\Http\Resources\Files') ->toHaveSuffix('FileResource'); +arch('app/Http/Resources/Views/Public/Formatters has valid architecture') + ->expect('App\Http\Resources\Formatters') + ->toHaveSuffix('FormatterResource') + ->toBeUsedIn('App\Http') + ->tohaveMethod('getValue'); + arch('app/Http/Resources/Models has valid architecture') ->expect('App\Http\Resources\Models') ->toHaveSuffix('ModelResource') @@ -62,12 +68,6 @@ ->toBeUsedIn('App\Http') ->tohaveMethod('getItem'); -arch('app/Http/Resources/Views/Public/Formatters has valid architecture') - ->expect('App\Http\Resources\Views\Public\Formatters') - ->toHaveSuffix('FormatterResource') - ->toBeUsedIn('App\Http') - ->tohaveMethod('getValue'); - arch('app/Http/Resources/Views/Public/Metadata has valid architecture') ->expect('App\Http\Resources\Views\Public\Metadata') ->toHaveSuffix('MetadataResource') diff --git a/tests/Unit/App/Http/Resources/Views/Public/Formatters/CopyrightFormatterResourceTest.php b/tests/Unit/App/Http/Resources/Formatters/CopyrightFormatterResourceTest.php similarity index 85% rename from tests/Unit/App/Http/Resources/Views/Public/Formatters/CopyrightFormatterResourceTest.php rename to tests/Unit/App/Http/Resources/Formatters/CopyrightFormatterResourceTest.php index 2ebed7a0..fdc3b2cf 100644 --- a/tests/Unit/App/Http/Resources/Views/Public/Formatters/CopyrightFormatterResourceTest.php +++ b/tests/Unit/App/Http/Resources/Formatters/CopyrightFormatterResourceTest.php @@ -1,6 +1,6 @@ expect(LaravelVersionFormatterResource::class) + ->toImplement(ConstantStringFormatterInterface::class); + +test('getValue returns ok with valid inputs', function () { + $actual = (new LaravelVersionFormatterResource())->getValue(); + + expect($actual) + ->toBeString() + ->toEqual(substr(Application::VERSION, 0, strpos(Application::VERSION, '.') ?: null) . '.x'); +}); diff --git a/tests/Unit/App/Http/Resources/Formatters/PhpVersionFormatterResourceTest.php b/tests/Unit/App/Http/Resources/Formatters/PhpVersionFormatterResourceTest.php new file mode 100644 index 00000000..16a0fda9 --- /dev/null +++ b/tests/Unit/App/Http/Resources/Formatters/PhpVersionFormatterResourceTest.php @@ -0,0 +1,16 @@ +expect(PhpVersionFormatterResource::class) + ->toImplement(ConstantStringFormatterInterface::class); + +test('getValue returns ok with valid inputs', function () { + $actual = (new PhpVersionFormatterResource())->getValue(); + + expect($actual) + ->toBeString() + ->toEqual(substr(PHP_VERSION, 0, strrpos(PHP_VERSION, '.') ?: null) . '.x'); +});