{"repo":"worksome/request-factories","free":true,"listed":false,"github":"https://github.com/worksome/request-factories","clone":"git clone https://github.com/worksome/request-factories.git","description":"Test requests in Laravel without all the boilerplate.","language":"PHP","stars":623,"topics":["laravel","package","pest","php","testing"],"license":"MIT","category":"dev-tools","readme_excerpt":"Request Factories Test requests in Laravel without all the boilerplate. 💡 Psst. Although our examples use Pest PHP, this works just as well in PHPUnit. Take a look at the following test: Oof. See, all we wanted to test was the phone number, but because our route's FormRequest has validation rules, we have to send all of these additional fields at the same time. This approach has a few downsides: 1. It muddies the test. Tests are supposed to be terse and easy to read. This is anything but. 2. It makes writing tests annoying. You probably have more than one test for each route. Every test you write requires all of these fields over and over again. 3. It requires knowledge of the FormRequest. You'd need to understand what each field in this form does before being able to write a passing test. If you don't, you're likely going to be caught in a trial-and-error loop, or worse, a false positive, whilst creating the test. We think this experience can be vastly improved. Take a look: Soooooo much nicer. And all thanks to Request Factories. Let's dive in... Installation You can install the package as a developer dependency via Composer: Usage First, let's create a new RequestFactory . A RequestFactory usually complements a FormRequest in your application (request factories work with standard requests too!). You can create a RequestFactory using the make:request-factory Artisan command: Note that we've passed the SignupRequest FQCN as an argument. This will create a new request factor","default_branch":null,"files":null,"tree":[],"storefront":"/r/worksome","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/worksome/request-factories/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}