Playing
01. Introduction and demo

Transcript

00:00
So welcome to Up and Running with PEST. In this course, we're going to build out a real world application and write tests alongside it using PEST.
00:08
PEST is a testing framework for PHP, not specifically for Laravel. So we're going to be leaning on a lot of Laravel testing functionality that's already available to us. But we'll be covering pretty much every PEST feature.
00:21
So once you're done with the course, you'll be able to comfortably write tests with PEST and leverage nearly all of its features. Okay, so let's take a look at the application that we're going to be building and we'll run the tests that we're going to be writing together as well.
00:36
So the app that we're going to be building is Book Friends, which is essentially a way to sign up, add books that you are either wanting to read, currently reading or have read, and you can share that with your friends.
00:48
So we're going to be building out and of course testing a friend system as well. So we can add a friend, accept a friend request. So that's a pretty big feature of this course. So I'm going to go ahead and just sign up here.
01:02
Let's go ahead and just write my name in here and my email address. And I'll go ahead and choose a password. And there we go. We've got a feed here which will show us all of our friends
01:12
and the books that they're currently reading. We've got a list of our books, which at the moment is empty. We can add a book, which we're going to take a look at. And we can look at our friends list and of course add a friend as well.
01:23
So let's go ahead and first of all add a book. So let's just call this example book one. And we'll just put example author one. Just keep things simple.
01:34
And I'll just say I want to read this book. So once we've added that over on the my book section, you can see that we've got this book in here under this want to read section. We can edit that.
01:44
So if this changes to the fact that we're reading it, we can do that as well. And if we just add another book, example book two, and we'll just copy and paste that down, example author two, and I say read, then you can see that these come under different headings.
02:00
Now let's hop over to another browser window and we'll go ahead and sign up with a completely different user. So let's say mabel at codecourse.com and again add a password in. Now this user of course doesn't have any books
02:13
and we don't have anything in the feed. If we head over to the friends section though and we add my email address and we hit send a friend request, we now get a list of pending friend requests.
02:23
We can cancel that if we want to and re-add it in. And let's go over to here and go over to our friends list. So you can see here we've got a list of friend requests which we can go ahead and accept.
02:35
So once we do accept this friend request and we come over to Mabel's account, you can now see that comes under this friends heading. And if we head over to the feed, you can see here Alex has read example book two. So this is now in past tense and you can see that book there
02:50
and it tells you when as well. So what we can do is just come over and edit this. So let's come over to Alex's account and let's go over to our books and let's set reading to read.
03:04
And let's hop back over and give that a refresh. And there we go. So Alex has read example book one one second ago. So that's all going to keep up to date.
03:11
And of course we can manage our friends by unfriending them if we want to and all that stuff. So let's take a look at some of the tests that we're going to write. If we just go ahead and open this up,
03:21
you can see we've got a huge amount of feature tests. We're going to focus on feature tests here, but we are going to write some unit tests specifically around the friend functionality. And that's where pests expectations come in.
03:33
But most of these are going to be feature tests. And we're going to try and pack as many pest features into this in the correct context so we can see how pest shines. And to run the tests, of course, which is really important,
03:46
we're going to go ahead and use pest. And you can see here that's going to run through all of these. And we have written a total of 48 tests. And they have all run and, of course, have all passed.
03:57
So there we go. That is the example app that we're going to be building. Pretty simple. The most complex part about this is the friend functionality,
04:05
which we're going to be thoroughly unit testing. But that's what we're going to be building and learning pest along the way. So let's head over to the next episode, get a fresh Laravel project set up and get pest up and running.
35 episodes4 hrs 19 mins

Overview

Pest is a PHP testing framework that brings beautifully simple syntax to your tests, without sacrificing on features. In this course, we'll get up and running with Pest in a Laravel project and write tests for a real-world application that we'll build along the way.

You'll learn how to set Pest up in a Laravel project, write tests with Pest's built-in assertions, generate code coverage, and more.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Episode discussion

No comments, yet. Be the first!