NativePHP
Windows support is here! 🔥 Read the full announcement →
Windows

NativePHP is currently in alpha development

Let's get to beta!

#
Fake Windows

#
Example test case

Copied!
1use Native\Laravel\Facades\Window;
2use Illuminate\Support\Facades\Http;
3 
4 #[\PHPUnit\Framework\Attributes\Test]
5public function example(): void
6{
7 Http::fake();
8 Window::fake();
9 
10 $this->get('/whatever-action');
11 
12 Window::assertOpened(fn (string $windowId) => Str::startsWith($windowId, ['window-name']));
13 Window::assertClosed('window-name');
14 Window::assertHidden('window-name');
15}

#
Available assertions

  • assertOpened
  • assertClosed
  • assertHidden

#
Asserting against a window instance (advanced)

Copied!
1use Illuminate\Support\Facades\Http;
2use Native\Laravel\Facades\Window;
3use Native\Laravel\Windows\Window as WindowImplementation;
4use Mockery;
5 
6#[\PHPUnit\Framework\Attributes\Test]
7public function example(): void
8{
9 Http::fake();
10 Window::fake();
11 Window::alwaysReturnWindows([
12 $mockWindow = Mockery::mock(WindowImplementation::class)->makePartial(),
13 ]);
14 
15 $mockWindow->shouldReceive('route')->once()->with('action')->andReturnSelf();
16 $mockWindow->shouldReceive('transparent')->once()->andReturnSelf();
17 $mockWindow->shouldReceive('height')->once()->with(500)->andReturnSelf();
18 $mockWindow->shouldReceive('width')->once()->with(775)->andReturnSelf();
19 $mockWindow->shouldReceive('minHeight')->once()->with(500)->andReturnSelf();
20 $mockWindow->shouldReceive('minWidth')->once()->with(775)->andReturnSelf();
21 
22 $this->get(route('action'));
23}