What are the best practices for setting up a test environment using PHPUnit in PHP, and how does it relate to PEAR installations?

Setting up a test environment using PHPUnit in PHP involves installing PHPUnit using Composer, creating a separate directory for your tests, and writing test cases for your code. It is recommended to use Composer for managing dependencies and autoloading classes. PEAR installations are not commonly used for PHPUnit anymore, as Composer has become the standard dependency manager for PHP projects.

// Composer.json file
{
    "require-dev": {
        "phpunit/phpunit": "^9.5"
    }
}

// Command to install PHPUnit using Composer
composer require --dev phpunit/phpunit

// Example test case
use PHPUnit\Framework\TestCase;

class MyTest extends TestCase
{
    public function testAddition()
    {
        $result = 1 + 1;
        $this->assertEquals(2, $result);
    }
}