|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/php-unit-testing/
课程评论:没有评论
## Coursera 课程总结:PHPUnit 单元测试(PHP Unit Testing with PHPUnit) 本课程旨在帮助 PHP 开发者提升代码质量,减少 bug,掌握使用 PHPUnit 测试框架进行单元测试的技能。 **学习目标:** * 理解单元测试的概念。 * 掌握使用 PHPUnit 编写单元测试的方法。 * 构建 PHP 函数和类的测试套件。 * 学习如何让测试方法相互依赖。 * 掌握测试替身 (Test Doubles),包括 Mockery 的使用。 * 理解依赖注入 (Dependency Injection) 的概念及其用法。 * 学习测试驱动开发 (TDD) 流程。 * 了解如何测试受保护和私有方法/属性(以及其优缺点)。 * 学习如何测试抽象类。 **课程内容概述:** 本课程将带领学员从零开始,深入了解 Unit Testing 在 PHP 开发中的重要性。课程将讲解如何取代传统的、低效的手动测试方法(如使用 `var_dump`),转而采用自动化的单元测试。 * **基础入门:** 学习单元测试的基本概念,以及如何在 PHP 中使用断言 (Assertions)。 * **核心实践:** 掌握测试 PHP 函数和类的方法,了解 PHPUnit 框架的配置。 * **高级技巧:** 学习使用测试依赖、夹具 (Fixtures)、测试异常,以及 Mock 和 Stub 等测试替身。 * **开发模式:** 深入学习测试驱动开发 (TDD) 的实践,即先写测试,再写代码。 * **边缘场景:** 探讨如何测试受保护和私有方法/属性,并分析其合理性。 * **静态方法测试:** 详细介绍测试静态方法,并包含处理静态依赖的多种方法。 **学习收获:** 完成本课程后,学员将能够: * 为现有 PHP 代码编写单元测试。 * 使用测试驱动开发 (TDD) 的方式开发新代码。 * 编写出更高质量、更易于维护、文档更清晰且 bug 更少的 PHP 代码。 * 更快速地发现和修复 bug。 **课程特色:** * 提供课程中演示的所有代码。 * 允许学员与讲师在问答区进行互动,获取帮助。 * 完成课程后可获得可验证的结业证书。 **适合人群:** 所有 PHP 开发者,无论经验水平如何。 **重要提示:** 本课程是学习编写高质量 PHP 代码、提升开发效率的必备技能。掌握单元测试将使您在面对复杂的项目时更加得心应手。 **立即加入,将单元测试技能纳入您的 PHP 工具箱!**
If you are a PHP developer and you want to learn how to write better code, with fewer bugs, you will need to know how to write unit tests.Learn how to unit test your PHP code using the PHPUnit testing framework.Learn what unit tests areLearn how to write unit tests using PHPUnitBuild a test suite for PHP functions and classesMake test methods dependent on each otherUse test doubles: mocks and stubs, including how to use MockeryLearn how and why you should use dependency injectionLearn test-driven development (TDD)Learn how to test protected and private methods and properties (and whether you actually should or not!)Learn how to test abstract classesA skill that will enable you to write higher quality code, in a shorter time, with better documentation and fewer bugs.Learning how to write unit tests for your code will make you write better code. With automated tests, you can find bugs more easily, and if you break something you'll notice straight away.Many experienced developers write unit tests for their code. It's a repeatable way of checking that the code works as intended, and also serves as documentation. Many popular PHP projects are unit tested, such as WordPress and Moodle, and if you use frameworks such as Laravel or Symfony, these provide tight integration with the PHPUnit testing framework.Content and OverviewHow do you currently test your code? Maybe you run your code in a browser, use var_dump a lot and so on. The problem with this is that you only tend to test new code - you don't go back and test old code. What if you add some new code that breaks the old code?With automated unit tests, you have more control. If your new code breaks something, you'll notice straight away. You can fix bugs more easily, thereby reducing development time.Tests are also a form of documentation, just like comments: they serve to show why the code has been written that way. Suitable for all PHP developers, you'll start by learning the basics of unit testing PHP code, including how to use assertions.Then you'll learn how to test functions and classes, and how to configure the PHPUnit framework.Next you'll learn how to use test dependencies, fixtures and how to test for exceptions.You'll also see how test doubles work - mock objects and stub methods.Then you'll learn how to write code using test-driven development - writing the tests first, then the code.You'll also learn how to test protected and private class methods and properties, and whether this is actually a good idea or not.Testing static methods is covered in detail, including several methods for dealing with static dependencies.When you complete the course you'll be able to write unit tests for your existing PHP code, and develop new code using test-driven development.Complete with all the code shown in the lectures, you'll be able to work alongside the instructor and will receive a verifiable certificate of completion upon finishing the course.Also, at all times throughout the course you have access to the instructor in the Q & A section to ask for help with any topic related to the course.Enrol now and add unit testing to your PHP skillset!