1. Go to this page and download the library: Download ylsideas/laravel-additions 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/ */
ylsideas / laravel-additions example snippets
'stub_path' => resource_path(),
trait WithSomething
{
use \YlsIdeas\LaravelAdditions\Testing\WithApplicationTraitHooks;
protected $user;
/**
* @afterAppCreated
*/
public function createUser()
{
$this->user = factory(User::class)->create();
}
public function actingByDefault()
{
return $this->actingAs($this->user);
}
}
class SomethingTest extends \Tests\TestCase
{
use WithSomething;
public function testSomething()
{
$this->actingByDefault()
->get('/home')
->assertOk();
}
}
class LaravelAdditionsServiceProvider extends LaravelAdditionsHooksServiceProvider
{
public function onSetup(bool $initial, Command $command) {
$command->call('migrate:fresh', ['--seed' => true]);
return true;
}
public function beforeTesting(InputInterface $input, OutputInterface $output) {
$output->writeln('Starting...');
}
public function afterTesting(bool $passed, InputInterface $input, OutputInterface $output) {
$output->writeln('Complete!');
}
}
class TestCase {
public function testMailable()
{
Mail::fake();
$mailable = new MailType();
$mailable->send();
Mail::assertSent(MailableType::class, MailViewAssertion::make(function (ViewAssertion $assertion) {
$assertion->contains('Hello World!');
}));
}
public function testMailable()
{
Notification::fake();
$notification = new ExampleNotification();
$user->notify($notification);
Notification::assertSentTo(
$user,
ExampleNotification::class,
MailViewAssertion::make(function (ViewAssertion $assertion) {
$assertion->contains('Hello World!');
})
);
}
}
bash
php artisan configure --macros --helpers
shell script
php artisan configure --hooks
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.