Skip to content

Commit

Permalink
Merge pull request #53 from spatie/v2
Browse files Browse the repository at this point in the history
[v2] use Laravel 8 and Livewire 2
  • Loading branch information
freekmurze authored Sep 9, 2020
2 parents 340f88f + 0d6fe17 commit 690cc5a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ jobs:
matrix:
os: [ubuntu-latest]
php: [7.4]
laravel: [8.*, 7.*]
laravel: [8.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 7.*
testbench: 5.*
- laravel: 8.*
testbench: 6.*

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
],
"require": {
"php": "^7.4",
"illuminate/database": "^7.5|^8.0",
"illuminate/view": "^7.5|^8.0",
"livewire/livewire": "^1.0.13",
"illuminate/database": "^8.0",
"illuminate/view": "^8.0",
"livewire/livewire": "^2.0",
"spatie/sun": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"orchestra/testbench": "^5.0|^6.0",
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.3",
"spatie/phpunit-snapshot-assertions": "^4.1"
"spatie/phpunit-snapshot-assertions": "^4.2"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 10 additions & 6 deletions tests/DashboardTileComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

namespace Spatie\Dashboard\Tests;

use Illuminate\Foundation\Testing\Concerns\InteractsWithViews;

class DashboardTileComponentTest extends TestCase
{
use InteractsWithViews;

/** @test */
public function it_correctly_translates_a_single_position_to_grid_css_styles()
{
$renderedHtml = $this->renderBladeString('<x-dashboard-tile position="a1">Test</x-dashboard-tile>');

$this->assertStringContainsString('grid-area: 1 / 1;', $renderedHtml);
$this
->blade('<x-dashboard-tile position="a1">Test</x-dashboard-tile>')
->assertSee('grid-area: 1 / 1;');
}

/** @test */
public function it_correctly_translates_a_range_position_to_grid_css_styles()
{
$renderedHtml = $this->renderBladeString('<x-dashboard-tile position="a1:b2">Test</x-dashboard-tile>');

$this->assertStringContainsString('1 / 1 / 3 / 3;', $renderedHtml);
$this
->blade('<x-dashboard-tile position="a1:b2">Test</x-dashboard-tile>')
->assertSee('1 / 1 / 3 / 3;');
}
}
19 changes: 0 additions & 19 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use CreateDashboardTilesTable;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Str;
use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;
use Spatie\Dashboard\DashboardServiceProvider;
Expand Down Expand Up @@ -34,21 +32,4 @@ protected function setUpDatabase()
include_once __DIR__.'/../database/migrations/create_dashboard_tiles_table.php.stub';
(new CreateDashboardTilesTable())->up();
}

protected function renderBladeString(string $bladeContent): string
{
$temporaryDirectory = sys_get_temp_dir();

if (! in_array($temporaryDirectory, View::getFinder()->getPaths())) {
View::addLocation(sys_get_temp_dir());
}

$tempFilePath = tempnam($temporaryDirectory, 'tests') . '.blade.php';

file_put_contents($tempFilePath, $bladeContent);

$bladeViewName = Str::before(pathinfo($tempFilePath, PATHINFO_BASENAME), '.blade.php');

return view($bladeViewName)->render();
}
}

0 comments on commit 690cc5a

Please sign in to comment.