13. PHP Unit testing tutorial and pages list | Automated testing with PHPUnit | CMS OOP tutorial MVC

preview_player
Показать описание
Let's list pages in CMS admin, but also discuss PHP Unit Testing in practice, how it can help us in one real life example, and what are the benefits of PHPUnit framework. PHP Automated testing in general improves your code base, because if something is easy (or possible) to test, it usually fallows good programming practices (Single Responsibility, does not have dependencies etc). So even if you do not write tests, it is very important to "pretend" you would and see how will your architecture behave.

Interested in learning real-life PHP design patterns?

➤ LINKS
(use tags to navigate between lessons)

Timestamps:
Intro (00:00)
Automated and Unit Testing introduction (16:13)
Practical solution (23:40)
Homework (46:22)
Conclusion (47:29)
Рекомендации по теме
Комментарии
Автор

one of the best teachers in the world respect ❤ thank you so much ❤️

gamerszone
Автор

thank you for all the effort you put into these videos! it's clear they are well thought out. I am trying to learn PHPUnit, and unit testing in general, to start using it in my workplace.

Rtzoor
Автор

the effort you put into your videos is clear. I am actually learning a lot from you. Now I am off to get your course

AlbertAngmor
Автор

Thank you for your wonderful and professional tutorial. I was able to understand the true oop php concept after watching tutorial series. Please continue the good work.

arunkumark
Автор

Hi, This is the first time Im learning testing with PHP Unit, thank you for awesome introduction.
By the way optional parameter mode in fetch PDO statement (PDO::FETCH_OBJ) can help us fetch the data from database in proper format so we dont have to make objects from the array and can save few lines of code I think.

brtj
Автор

Thank you for this excellent in depth course, I have watched everything so far. This video has been especially helpful, I have not used testing before, it is indeed a great helper.

phixphixation
Автор

Do you use an extension to format your var_dumps to be more readable? My arrays just get printed as one long ugly string.

HarryNewman-jm
Автор

Please make more beginner project on mvc
Btw vdo is cool 👍

saumyaranjanpani
Автор

I am interested into PHP Unit testing Course.

vilhemleshi
Автор

File not found error while including class file in unit tests

aleenshrestha
Автор

I did the homework. I made a new page: page-editor, with the following URL: As you can see I added to the dashboardController the method editAction, which loads the findAll with title and content from the database and renders the page-editor with the template engine and pageTitle in the $variables. At the editor page I retrieve the page to edit from the URL and use the foreach and if statement to show the data.

$pageTitle = trim($_GET['page']);

Between the textarea tags from the editor:

foreach ($pages as $page) {
if($page->title === $pageTitle) {
echo $page->content;
}
}



It works fine now for every page, except I can't do anything with it. So to save it in the database I do have to add another case to the switch statement, like update and create an update method in the controller. Or with future db handlings in mind I should make a new controller for updating fields in the database dynamically. After succesfull updating the database it returns the user (admin) to the updated page.

Also when logged in the user can view the frontside with some extra buttons like edit page directly.

I am curious how you solve it, when does your next video come out?

thanks in advance and good luck with the video's.

zakelijkvoordeel