
Testing Symfony
PHPUnit, test cases, functional tests, database fixtures, mocking, code coverage, Panther
1What is the default testing framework used by Symfony?
What is the default testing framework used by Symfony?
คำตอบ
PHPUnit is the official testing framework integrated into Symfony. Symfony provides the symfony/test-pack package which includes PHPUnit and base classes like WebTestCase and KernelTestCase for easier testing. PHPUnit is the de facto standard for PHP testing and offers a rich ecosystem of assertions and features.
2Which base class should be used to test a Symfony service without loading the HTTP kernel?
Which base class should be used to test a Symfony service without loading the HTTP kernel?
คำตอบ
KernelTestCase is the base class for integration tests that need access to the service container without loading the HTTP layer. It boots the Symfony kernel and allows access to services via self::getContainer(). It's lighter than WebTestCase as it doesn't initialize the HTTP client.
3How to access the service container in a test extending KernelTestCase?
How to access the service container in a test extending KernelTestCase?
คำตอบ
In Symfony 5.3+, the static method self::getContainer() is the recommended way to access the container after booting the kernel with self::bootKernel(). This method returns a test container that makes all services public for easier testing. The old self::$container syntax is deprecated.
Which class should be used to test controllers with HTTP request simulation?
How to verify that an HTTP request returns a 200 status code in a functional test?
+19 คำถามสัมภาษณ์
หัวข้อสัมภาษณ์ Symfony อื่นๆ
Modern PHP (8.1+)
Symfony Basics
Routing & Controllers
Twig & Templates
Doctrine ORM Basics
Symfony Forms
Data Validation
Dependency Injection & Services
Security & Authentication
Doctrine Advanced
API Platform
Serializer Component
Events & Event Subscribers
Console & Commands
Messenger Component
HTTP Client
Cache & Performance
Workflow Component
Mailer Component
Translations & i18n
EasyAdmin Bundle
Symfony Architecture
Performance & Optimization
Security Advanced
Custom Bundles
Microservices with Symfony
Real-time & WebSockets
Deployment & DevOps
เชี่ยวชาญ Symfony สำหรับการสัมภาษณ์ครั้งถัดไป
เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์
เริ่มใช้ฟรี