Writing Tests for PHPUnit

Writing Tests for PHPUnit

Example 2.1 shows how we can write tests using PHPUnit that exercise PHP's array operations. The example introduces the basic conventions and steps for writing tests with PHPUnit:

  1. The tests for a class Class go into a class ClassTest.

  2. ClassTest inherits (most of the time) from PHPUnit\Framework\TestCase.

  3. The tests are public methods that are named test*.

    Alternatively, you can use the 登录查看完整内容