
Testing & PHPUnit
PHPUnit basics, Unit vs Feature tests, Database testing, HTTP assertions, Mocking & faking, Test organization
1What is PHPUnit in the context of Laravel?
What is PHPUnit in the context of Laravel?
Antwort
PHPUnit is the standard unit testing framework for PHP, natively integrated into Laravel. It provides the assertions, annotations, and structure needed to write and run automated tests. Laravel extends PHPUnit with additional features like HTTP helpers, database traits, and framework-specific test methods to facilitate testing web applications.
2Which Artisan command runs all tests in a Laravel application?
Which Artisan command runs all tests in a Laravel application?
Antwort
The php artisan test command runs all PHPUnit tests in the Laravel application. This command internally uses PHPUnit but offers more readable output and additional Laravel-specific options. It is also possible to directly use the vendor/bin/phpunit command for more granular control over test execution.
3In which directory are tests located by default in a Laravel application?
In which directory are tests located by default in a Laravel application?
Antwort
Tests are located in the tests directory at the root of the Laravel project. This directory contains two main subdirectories: Feature for functional tests that test complete behaviors, and Unit for unit tests that test isolated classes or methods. This organization clearly separates different test types and facilitates maintenance.
What is the difference between a Unit test and a Feature test in Laravel?
Which Artisan command creates a new Feature test in Laravel?
+21 Interview-Fragen
Weitere Laravel-Interviewthemen
PHP Basics
PHP OOP Essentials
Composer & Autoloading
Laravel Fundamentals
Laravel Routing
Blade Templates
Request & Response
Eloquent ORM Basics
Eloquent Relationships
Migrations & Schema Builder
Validation & Forms
Authentication
Authorization & Policies
API Resources & Authentication
Middleware
Service Container & DI
Queues & Jobs
Events & Listeners
Notifications & Mail
File Storage
Caching
Livewire & Inertia
Eloquent Advanced
Repository Pattern
Laravel Packages
Performance Optimization
Security Best Practices
Laravel Octane
Laravel Distributed Systems
Observability & Monitoring
Deployment & DevOps
Meistere Laravel für dein nächstes Interview
Zugang zu allen Fragen, Flashcards, technischen Tests, Code-Review-Übungen und Interview-Simulatoren.
Kostenlos starten