What are the common tools used for unit testing in combination with Symfony, and how does PHPUnit compare to other testing frameworks in PHP?

Common tools used for unit testing in combination with Symfony include PHPUnit, Prophecy, and Mockery. PHPUnit is the most widely used testing framework in PHP and is specifically designed for unit testing. It provides a rich set of assertion methods and tools for mocking objects and functions, making it a powerful tool for testing Symfony applications.

// Example PHPUnit test case for a Symfony service
use PHPUnit\Framework\TestCase;
use App\Service\Calculator;

class CalculatorTest extends TestCase
{
    public function testAdd()
    {
        $calculator = new Calculator();
        $result = $calculator->add(2, 3);
        $this->assertEquals(5, $result);
    }
}