[0:00] welcome to testing php from gary clark [0:02] tech let me tell you what this course is [0:04] all about the goal of this course is to [0:06] show you how to achieve clean code with [0:09] maximum test coverage so it may differ [0:12] somewhat from other testing resources [0:14] you've seen whether that be on testing [0:16] php or testing software in general [0:18] because [0:19] the strategy tends to be to show people [0:22] how to use the tools and using fairly [0:24] simplistic examples [0:26] and there's nothing wrong with that [0:27] approach because i've myself i've [0:29] recorded videos where i'm showing people [0:31] how to use the tools using fairly [0:33] simplistic examples and it is probably [0:35] the best way to show someone how to use [0:37] the tools [0:38] but learning how to use the tools is not [0:42] learning how to test because you're not [0:44] learning how to write code which is [0:45] testable you're not learning how to [0:47] refactor code to make it more testable [0:49] and you're not learning how to approach [0:50] different problems from a testing [0:52] perspective and so there's a much bigger [0:55] problem to solve and that's what this [0:57] course aims to address [1:02] we're going to approach testing from [1:03] different angles we will start out in [1:05] the traditional manner i'll show you how [1:07] to use the tools and how to configure [1:09] them for your specific needs and then [1:12] what we'll do is we'll take a small [1:14] application which will just be a handful [1:16] of small files that i'll provide and [1:19] it'll contain no tests but it will [1:21] contain some problems which need solving [1:23] that provide a challenge to testing and [1:26] so we're going to try and gain maximum [1:28] test coverage using a combination of [1:31] unit tests integration tests and feature [1:34] tests which are sometimes also called [1:36] functional tests [1:40] throughout this we're going to practice [1:41] a lot of stuff which will make you a [1:42] good developer and a good tester and so [1:45] we're talking about things such as [1:47] refactoring code to make it more [1:49] testable using fake objects testables [1:52] can be a confusing subject so i'm going [1:55] to make it really clear for you i'll [1:57] show you what you should fake why you [1:58] should fake it when and how to do it and [2:01] also [2:02] we'll talk about some of the terminology [2:04] such as mocks and stubs is there a [2:06] difference between the two what is that [2:08] difference we'll also look at things [2:10] like static methods are they really an [2:13] evil thing that is impossible to test [2:15] all of this will be explained in our [2:18] integration tests we'll consider how we [2:21] can test parts of our application which [2:23] communicates with external services that [2:26] are outside of our control so we're [2:28] talking about things such as third-party [2:30] apis which is all part of modern [2:32] software development modern web [2:34] development we'll also examine database [2:37] integration and test that the correct [2:40] records can be stored in and retrieved [2:42] from a database and while we're on that [2:44] subject we'll also consider the [2:46] structure of our application and see how [2:49] writing good tests can sort of point us [2:52] in the direction of actually [2:54] creating a more logical structure and a [2:56] better separation of concerns and so [2:59] we'll also add some new code to our [3:00] application which will be backed up by [3:02] tests and we'll finish off that part of [3:04] the course by adding [3:06] feature tests which will cover the whole [3:07] process from end to end and that will [3:10] give us maximum test coverage that will [3:12] lead us nicely into an examination of [3:15] code coverage where i'll show you how [3:17] you can use tools in order to generate [3:19] cold coverage reports and then i'll show [3:21] you how you can read these reports in [3:23] order to see where you have good test [3:25] coverage and which parts of your code [3:27] don't have sufficient test coverage and [3:29] i'll also explain [3:31] some of the limitations of cold coverage [3:33] reports called coverage tools and why [3:35] cold coverage does not mean the same [3:37] thing as functionality coverage or logic [3:39] path coverage [3:43] up to that point we'll mainly have [3:45] tested code which was already written [3:47] and we'll have written and refactored [3:49] code in order to make it more testable [3:51] and these are important skills to have [3:53] definitely ones that you'll need however [3:55] at this point in the course we're then [3:57] going to flip things on the head and [3:59] we're going to build a mini application [4:01] from scratch using test driven [4:03] development the big difference here will [4:05] be that we're going to write the tests [4:07] first and then we write code to make [4:10] those tests pass and then the code which [4:12] we have written will guide us and inform [4:15] us on what tests we need to write next [4:21] this part of the course was a lot of fun [4:22] to research and record the application [4:25] that we'll build will be able to take [4:27] different amounts of money in different [4:29] currencies you'll be able to add them [4:31] together multiply them do all kinds of [4:32] things and then reduce them back down to [4:35] a single currency and a single monetary [4:37] amount and so if that sounds familiar to [4:40] you it's because i borrowed that example [4:42] from a book called test driven [4:44] development by example by a developer [4:46] called kent beck it was originally [4:48] written in java and i've converted it to [4:50] modern php and it's a really good [4:52] example for demonstrating this stuff [4:54] because the problem is complex enough to [4:56] make it very interesting but at the same [4:58] time the other small problems which it [5:00] throws up are nice ones for being able [5:03] to explain tdd concepts and also the [5:05] thinking behind tdd quite clearly and [5:08] we'll finish up with a nice clean [5:10] application with a minimal code base and [5:12] complete test coverage i'm 100 confident [5:15] that you'll be able to take what you've [5:16] learned in that section walk away and [5:18] apply and solve any problem which is [5:21] thrown at you testing development can [5:23] and probably will make you a better [5:25] developer in fact just learning to test [5:28] well learning how to combine different [5:30] approaches such as the ability to test [5:33] already existing code with the ability [5:35] to drive out functionality with tests [5:38] all of these things will make you a [5:39] better developer and i'll be totally [5:42] frank with you [5:43] learning to test well you will work a [5:45] lot less hard than the developers that [5:47] don't you'll spend limited amount of [5:50] time revisiting code or revisiting work [5:52] which is already done and that you [5:54] believe to be complete limited time and [5:56] bug fixing it'll just be clean code [5:59] peace of mind respect from your [6:00] colleagues your work won't feel like [6:02] work it's all good let's dive in