Skip to content

Commit a8a0918

Browse files
authored
Move Tests to New Folders
1 parent bb005d0 commit a8a0918

File tree

103 files changed

+250
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+250
-110
lines changed

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
failOnEmptyTestSuite="false"
1010
beStrictAboutOutputDuringTests="true" >
1111
<testsuites>
12-
<testsuite name="Laravel Livewire Tables Test Suite">
13-
<directory>tests</directory>
12+
<testsuite name="Laravel Livewire Tables Unit Test Suite">
13+
<directory>tests/Unit</directory>
1414
</testsuite>
1515
</testsuites>
1616
<source>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Tests\Browser;
4+
5+
use Illuminate\Contracts\Console\Kernel;
6+
7+
trait CreatesApplication
8+
{
9+
/**
10+
* Creates the application.
11+
*
12+
* @return \Illuminate\Foundation\Application
13+
*/
14+
public function createApplication()
15+
{
16+
$app = require __DIR__.'/../../bootstrap/app.php';
17+
18+
$app->make(Kernel::class)->bootstrap();
19+
20+
return $app;
21+
}
22+
}

tests/Browser/DuskTestCase.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
3+
namespace Tests\Browser;
4+
5+
use Facebook\WebDriver\Chrome\ChromeOptions;
6+
use Facebook\WebDriver\Remote\DesiredCapabilities;
7+
use Facebook\WebDriver\Remote\RemoteWebDriver;
8+
use Illuminate\Support\Collection;
9+
use Laravel\Dusk\Browser;
10+
use Laravel\Dusk\TestCase as BaseTestCase;
11+
use Tests\Browser\CreatesApplication;
12+
13+
abstract class DuskTestCase extends BaseTestCase
14+
{
15+
use CreatesApplication;
16+
17+
/**
18+
* Register the base URL with Dusk.
19+
*/
20+
protected function setUp(): void
21+
{
22+
parent::setUp();
23+
24+
Browser::$storeScreenshotsAt = __DIR__.'/Logs/screenshots';
25+
26+
Browser::$storeConsoleLogAt = __DIR__.'/Logs/console';
27+
}
28+
29+
/**
30+
* Define routes setup.
31+
*
32+
* @param \Illuminate\Routing\Router $router
33+
*
34+
* @return void
35+
*/
36+
protected function defineRoutes($router)
37+
{
38+
Route::get('/tailwind', function () {
39+
return view('users.tw');
40+
})->name('tw');
41+
42+
Route::get('/tailwind-slidedown', function () {
43+
return view('users.tw', ['displayStyle' => 'slide-down']);
44+
})->name('tw-slidedown');
45+
46+
}
47+
48+
/**
49+
* Prepare for Dusk test execution.
50+
*
51+
* @beforeClass
52+
*/
53+
public static function prepare(): void
54+
{
55+
if (! static::runningInSail()) {
56+
static::startChromeDriver();
57+
}
58+
}
59+
60+
/**
61+
* Create the RemoteWebDriver instance.
62+
*/
63+
protected function driver(): RemoteWebDriver
64+
{
65+
$options = (new ChromeOptions)->addArguments(collect([
66+
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
67+
])->unless($this->hasHeadlessDisabled(), function (Collection $items) {
68+
return $items->merge([
69+
'--disable-gpu',
70+
'--headless=new',
71+
]);
72+
})->all());
73+
74+
return RemoteWebDriver::create(
75+
$_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515',
76+
DesiredCapabilities::chrome()->setCapability(
77+
ChromeOptions::CAPABILITY,
78+
$options
79+
)
80+
);
81+
}
82+
83+
/**
84+
* Determine whether the Dusk command has disabled headless mode.
85+
*/
86+
protected function hasHeadlessDisabled(): bool
87+
{
88+
return isset($_SERVER['DUSK_HEADLESS_DISABLED']) ||
89+
isset($_ENV['DUSK_HEADLESS_DISABLED']);
90+
}
91+
92+
/**
93+
* Determine if the browser window should start maximized.
94+
*/
95+
protected function shouldStartMaximized(): bool
96+
{
97+
return isset($_SERVER['DUSK_START_MAXIMIZED']) ||
98+
isset($_ENV['DUSK_START_MAXIMIZED']);
99+
}
100+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Tests\Browser\Feature;
4+
5+
use Laravel\Dusk\Browser;
6+
use Tests\Browser\DuskTestCase;
7+
8+
class Tailwind3Test extends DuskTestCase
9+
{
10+
/**
11+
* All Filters Load
12+
*/
13+
public function testCorrectThemeDisplays(): void
14+
{
15+
$this->browse(function (Browser $browser) {
16+
$browser->visit('/tailwind');
17+
$browser->assertSee('Tailwind 2 Implementation');
18+
$browser->assertDontSee('Tailwind 3 Implementation');
19+
$browser->assertDontSee('Bootstrap 4 Implementation');
20+
$browser->assertDontSee('Bootstrap 5 Implementation');
21+
});
22+
}
23+
}

tests/TestCase.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
use Rappasoft\LaravelLivewireTables\LaravelLivewireTablesServiceProvider;
1212
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{BreedsTable,PetsTable,PetsTableEvents,PetsTableUnpaginated,PetsTableWithOwner,SpeciesTable};
1313
use Rappasoft\LaravelLivewireTables\Tests\Http\TestComponent;
14-
use Rappasoft\LaravelLivewireTables\Tests\Models\Breed;
15-
use Rappasoft\LaravelLivewireTables\Tests\Models\Owner;
16-
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
17-
use Rappasoft\LaravelLivewireTables\Tests\Models\Species;
18-
use Rappasoft\LaravelLivewireTables\Tests\Models\Veterinary;
14+
use Rappasoft\LaravelLivewireTables\Tests\Models\{Breed,Owner,Pet,Species,Veterinary};
1915

2016
class TestCase extends Orchestra
2117
{

tests/Attributes/AggregateColumnProvider.php renamed to tests/Unit/Attributes/AggregateColumnProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rappasoft\LaravelLivewireTables\Tests\Attributes;
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Attributes;
44

55
final class AggregateColumnProvider
66
{

tests/DataTableComponentTest.php renamed to tests/Unit/DataTableComponentTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?php
22

3-
namespace Rappasoft\LaravelLivewireTables\Tests;
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Unit;
44

55
use Livewire\Livewire;
6-
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables\NoColumnsTable;
7-
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables\NoPrimaryKeyTable;
86
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
7+
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables\{NoColumnsTable,NoPrimaryKeyTable};
98

109
class DataTableComponentTest extends TestCase
1110
{

tests/DataTransferObjects/DebuggableDataTest.php renamed to tests/Unit/DataTransferObjects/DebuggableDataTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rappasoft\LaravelLivewireTables\Tests\DataTransferObjects;
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\DataTransferObjects;
44

55
use Rappasoft\LaravelLivewireTables\DataTransferObjects\DebuggableData;
66
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

tests/Events/ColumnsSelectedTest.php renamed to tests/Unit/Events/ColumnsSelectedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rappasoft\LaravelLivewireTables\Events;
3+
namespace Rappasoft\LaravelLivewireTables\Unit\Events;
44

55
use Illuminate\Support\Facades\Event;
66
use Rappasoft\LaravelLivewireTables\Events\ColumnsSelected;

tests/Events/FilterAppliedTest.php renamed to tests/Unit/Events/FilterAppliedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rappasoft\LaravelLivewireTables\Events;
3+
namespace Rappasoft\LaravelLivewireTables\Unit\Events;
44

55
use Illuminate\Support\Facades\Event;
66
use Rappasoft\LaravelLivewireTables\Events\FilterApplied;

0 commit comments

Comments
 (0)