mirror of
https://github.com/archtechx/livewire-access.git
synced 2025-12-12 04:14:03 +00:00
initial
This commit is contained in:
parent
a29235253b
commit
e50e22434f
12 changed files with 159 additions and 138 deletions
55
tests/LivewireAccessTest.php
Normal file
55
tests/LivewireAccessTest.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Lean\LivewireAccess\Tests;
|
||||
|
||||
use Livewire\Exceptions\NonPublicComponentMethodCall;
|
||||
use Livewire\Exceptions\PublicPropertyNotFoundException;
|
||||
use Livewire\Livewire;
|
||||
use Livewire\LivewireServiceProvider;
|
||||
use Orchestra\Testbench\TestCase as TestbenchTestCase;
|
||||
|
||||
class LivewireAccessTest extends TestbenchTestCase
|
||||
{
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
LivewireServiceProvider::class,
|
||||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function public_properties_are_not_accessible_by_default()
|
||||
{
|
||||
$this->expectException(PublicPropertyNotFoundException::class);
|
||||
|
||||
Livewire::test(TestComponent::class)
|
||||
->call('$set', 'foo', 'xxx');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function public_properties_can_be_explicitly_accessible()
|
||||
{
|
||||
Livewire::test(TestComponent::class)
|
||||
->call('$set', 'bar', 'xxx');
|
||||
|
||||
// No exception
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function public_methods_are_not_acccessible_by_default()
|
||||
{
|
||||
$this->expectException(NonPublicComponentMethodCall::class);
|
||||
|
||||
Livewire::test(TestComponent::class)
|
||||
->call('abc');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function public_methods_can_be_explicitly_accessible()
|
||||
{
|
||||
Livewire::test(TestComponent::class)
|
||||
->call('def');
|
||||
|
||||
// No exception
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Package\Tests;
|
||||
|
||||
use Orchestra\Testbench\TestCase as TestbenchTestCase;
|
||||
use Stancl\Package\PackageServiceProvider;
|
||||
|
||||
class TestCase extends TestbenchTestCase
|
||||
{
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
PackageServiceProvider::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
27
tests/TestComponent.php
Normal file
27
tests/TestComponent.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Lean\LivewireAccess\Tests;
|
||||
|
||||
use Lean\LivewireAccess\WithExplicitAccess;
|
||||
use Lean\LivewireAccess\FrontendAccess;
|
||||
use Livewire\Component;
|
||||
|
||||
class TestComponent extends Component
|
||||
{
|
||||
use WithExplicitAccess;
|
||||
|
||||
public string $foo = 'foo';
|
||||
|
||||
#[FrontendAccess]
|
||||
public string $bar = 'bar';
|
||||
|
||||
public function abc() {}
|
||||
|
||||
#[FrontendAccess]
|
||||
public function def() {}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue