Laravel 5.2 Testing – example

php artisan make:test UserTest

Running on Windows:

E:\server\www\projects\laravel5\myproject>E:\server\www\projects\laravel5\myproject\vendor\bin\phpunit

visit('user/create') // user/create is defined in the routes.php !!!
->type('PHPUnitTest', 'name') //form name
->type('phpunit@test.local', 'email')
->type('1234', 'password')
->type('1234', 'password_confirmation')
->press('Create')
->see('Your account have been created.');

}

}

https://laravel.com/docs/5.2/testing

Two tips to speedup your Laravel tests : https://driesvints.com/blog/two-tips-to-speedup-your-laravel-tests/

Useful tips for Collection operations In Laravel

https://www.dunebook.com/useful-tips-for-collection-operations-in-laravel/
$books = AppBook::all();

if($books->contains(3))
{
return ‘yeah, book 3 is here!’;
}

$book = $books->get(2, “Not Found!”);

if($books->has(3))
{
$book = $books->get(3);
}
$book = new Book;
// other attributes assignment here…

$books->put(2, $book);

$firstBook = new Book;
// other attributes assignment here…

$books->prepend($book);