PHP code example of ralphjsmit / pest-plugin-livewire

1. Go to this page and download the library: Download ralphjsmit/pest-plugin-livewire library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ralphjsmit / pest-plugin-livewire example snippets


class TestRequiredPropertiesComponent extends Component
{
    public string $email_Req = '';
    public string $email = '';
    public ?int $age_Req = null;
    public ?int $age = null;

    protected array $rules = [
        'email' => '',
        'email_Req' => '

use function RalphJSmit\PestPluginLivewire\validInput;

$component = Livewire::test(TestRequiredPropertiesComponent::class);

$validInput = validInput([
    'email' => '[email protected]',
    'age' => 25,
]);

expect($component)
    ->toHaveRequiredProperties(validInput, ['email_Req', 'age_Req'], 'submit');

use function RalphJSmit\PestPluginLivewire\validInput;

$component = Livewire::test(TestRequiredPropertiesComponent::class);

$validInput = validInput([
    'email' => '[email protected]',
    'age' => 25,
]);

expect($component)
    ->toNotHaveRequiredProperties(validInput, ['email', 'name'], 'submit');

use function RalphJSmit\PestPluginLivewire\assertRequiredProperties;

assertRequiredProperties(TestableLivewire $livewire, Collection $validInput, array $

use function RalphJSmit\PestPluginLivewire\assertNotRequiredProperties;

assertNotRequiredProperties(TestableLivewire $livewire, Collection $validInput, array $