Spatie presents:
Updated for Pest v2
Are you...
Learn how to write quality tests in Pest and PHPUnit
VAT will be calculated during checkout by Paddle.
We support Purchasing Power Parity.
Subscribe to Testing Tidbits, a free newsletter with small but handy testing techniques.
You'll receive a daily email for one week, and occassional updates for this course.
Brent shows how you can easily automate the testing of forms by using Laravel's response assertions.
Freek explains two neat ways to make sure a middleware class works correctly.
Before continuing, learn more about why testing your applications is so important.
You will learn how to write a test suite from scratch. We'll cover how to make sure your homepage works, how you can test form submissions, what the different types of tests are, and much more!
/** @test */
public function it_can_handle_a_form_submission()
{
$this
->post(route('contact.submit'), [
'message' => 'Hello, PHPUnit!',
])
->assertRedirect(route('home'))
->assertSessionHasNoErrors();
}
After we've covered the basics, we'll show you how to tests policies, middlewares, controllers, mails, views, and all kinds of features. We'll cover snapshots testing, pragmatic mocks, how to test domain code, how to set up CI, and much more.
/** @test */
public function the_command_will_publish_scheduled_posts()
{
TestTime::freeze('Y-m-d H:i:s', '2021-01-01 00:00:00');
$post = Post::factory()->create([
'publish_date' => now()->addHour(),
'published' => false,
]);
// Travel to a second before the post should be published
TestTime::addHour()->subSecond();
$this->artisan(PublishScheduledPostsCommand::class);
$this
->get(route('posts.show'), $post->slug))
->assertNotFound();
// Travel to the time that a post should be published
TestTime::addSecond();
$this->artisan(PublishScheduledPostsCommand::class);
$this
->get(route('posts.show'), $post->slug))
->assertSuccessful();
$this->assertTrue($post->refresh()->published);
}
Pest is the new kid on the block in the PHP testing world that focuses on stellar developer experience. It's rapidly rising in popularity, and we believe it'll only grow in the near future. That's why we've recorded our entire course twice: first with PHPUnit, then with Pest v2 and all the awesome features it has to offer.
We'll also show you how to convert an existing PHPUnit test suite to Pest.
it('has a scope to retrieve all published blogposts', function() {
$publishedBlogPost = BlogPost::factory()->published()->create();
$draftBlogPost = BlogPost::factory()->draft()->create();
$publishedBlogPosts = BlogPost::wherePublished()->get();
expect($publishedBlogPosts)
->toHaveCount(1)
->and($publishedBlogPosts->first()->id)->toBe($publishedBlogPost->id);
});
Nothing inspires confidence while shipping like a good test suite. I'm thrilled Spatie is introducing a new generation of Laravel developers to the strong testing culture of the Laravel ecosystem.
Wish I had seen a video course like "Testing Laravel" years ago when was learning Laravel myself. It's the perfect starting point for developers that want to learn how to write tests in Laravel.
Anyone can show you how to write tests. A few can answer the question of what to test. Which is the real elephant in the room. Spatie has the experience and expertise to answer the big question. This course is going to have a huge impact on how Laravel developers test their apps.
Subscribe to Testing Tidbits, a free newsletter with small but handy testing techniques.
You'll receive a daily email for one week, and occassional updates for this course.