<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kirschbaum-development / laravel-actions example snippets
/**
* Event to dispatch before action starts.
*
* @var string
*/
public $before = ChuckNorrisWillBlowYourMind::class;
/**
* Event to dispatch after action completes.
*
* @var string
*/
public $after = ChuckNorrisBlewYourMind::class;
/**
* Create a new action instance.
*
* @return void
*/
public function __construct()
{
// Pass any arguments you need.
}
/**
* Execute the action.
*
* @return mixed
*/
public function __invoke()
{
// Handle your action here.
}
use Kirschbaum\Actions\Action;
public function index (Action $action)
{
$action->act(ChuckNorris::class, $data);
$action->actWhen($isChuckNorrisMighty, ChuckNorris::class, $data);
$action->actUnless($isChuckNorrisPuny, ChuckNorris::class, $data);
}
/**
* Handle failure of the action.
*
* @throws Throwable
*
* @return mixed
*/
public function failed(Throwable $exception)
{
event(new VanDammeFailedEvent);
}
/**
* Event to dispatch if action throws an exception.
*
* @var string
*/
public $exception = SeagalFailedException::class;
return [
'paths' => [],
];
use Kirschbaum\Actions\Facades\Action;
Action::shouldReceive('act')
->once()
->andReturnTrue();
use Kirschbaum\Actions\Action;
$this->mock(Action::class, function ($mock) {
$mock->shouldReceive('act')
->once()
->andReturnTrue();
});
use App\Actions\ChuckNorris;
$this->mock(ChuckNorris::class, function ($mock) {
$mock->shouldReceive('act')
->once()
->andReturnTrue();
});