Test requests in Laravel without all the boilerplate.

Overview

Request Factories

Test requests in Laravel without all the boilerplate.

Unit Tests PHPStan

💡 Psst. Although our examples use Pest PHP, this works just as well in PHPUnit.

Take a look at the following test:

it('can sign up a user with an international phone number', function () {
    $this->put('/users', [
        'phone' => '+375 154 767 1088',
        'email' => '[email protected]', 🙄
        'name' => 'Luke Downing', 😛
        'company' => 'Worksome', 😒
        'bio' => 'Blah blah blah', 😫
        'profile_picture' => UploadedFile::fake()->image('luke.png', 200, 200), 😭
        'accepts_terms_and_conditions' => true, 🤬
    ]);
    
    expect(User::latest()->first()->phone)->toBe('+375 154 767 1088');
});

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:

it('can sign up a user with an international phone number', function () {
    SignupRequest::fake();

    $this->put('/users', ['phone' => '+375 154 767 1088']);

    expect(User::latest()->first()->phone)->toBe('+375 154 767 1088');
});

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:

composer require --dev worksome/request-factories 

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:

php artisan make:request-factory "App\Http\Requests\SignupRequest"

Note that we've passed the SignupRequest FQCN as an argument. This will create a new request factory at tests/RequestFactories/SignupRequestFactory.php.

You can also pass your desired request factory name as an argument instead:

php artisan make:request-factory SignupRequestFactory

Whilst you're free to name your request factories as you please, we recommend two defaults for a seamless experience:

  1. Place them in tests/RequestFactories. The Artisan command will do this for you.
  2. Use a Factory suffix. So SignupRequest becomes SignupRequestFactory.

Factory basics

Let's take a look at our newly created SignupRequestFactory. You'll see something like this:

namespace Tests\RequestFactories;

use Worksome\RequestFactories;

class SignupRequestFactory extends RequestFactory
{
    public function definition(): array
    {
        return [
            // 'email' => $this->faker->email,
        ];
    }
}

If you've used Laravel's model factories before, this will look pretty familiar. That's because the basic concept is the same: a model factory is designed to generate data for eloquent models, a request factory is designed to generate data for form requests.

The definition method should return an array of valid data that can be used when submitting your form. Let's fill it out for our example SignupRequestFactory:

namespace Tests\RequestFactories;

use Worksome\RequestFactories;

class SignupRequestFactory extends RequestFactory
{
    public function definition(): array
    {
        return [
            'phone' => '01234567890',
            'email' => '[email protected]',
            'name' => 'Luke Downing',
            'company' => 'Worksome',
            'bio' => $this->faker->words(300, true),
            'accepts_terms_and_conditions' => true,
        ];
    }
    
    public function files(): array
    {
        return [
            'profile_picture' => $this->file()->image('luke.png', 200, 200),
        ];
    }
}

Note that we have access to a faker property for easily generating fake content, such as a paragraph for our bio, along with a files method we can declare to segregate files from other request data.

Usage in tests

So how do we use this factory in our tests? There are a few options, depending on your preferred style.

Using create on the factory

This method is most similar to Laravel's model factories. The create method returns an array, which you can then pass as data to put, post or any other request testing method.

it('can sign up a user with an international phone number', function () {
    $data = SignupRequest::factory()->create(['phone' => '+44 1234 567890']);
    
    $this->put('/users', $data)->assertValid();
});

Using fake on the request factory

Seeing as you only normally make a single request per test, we support registering your factory globally with fake. If you're using this approach, make sure that it's the last method you call on the factory, and that you call it before making a request to the relevant endpoint.

it('can sign up a user with an international phone number', function () {
    SignupRequestFactory::new()->fake();
    
    $this->put('/users')->assertValid();
});

Using fake on the form request

If you've used Laravel model factories, you'll likely be used to calling ::factory() on eloquent models to get a new factory instance. Request factories have similar functionality available. First, add the Worksome\RequestFactories\Concerns\HasFactory trait to the relevant FormRequest:

class SignupRequest extends \Illuminate\Foundation\Http\FormRequest
{
    use \Worksome\RequestFactories\Concerns\HasFactory;
}

This provides access to 2 new static methods on the form request: ::factory() and ::fake(). You can use these methods in your tests instead of instantiating the request factory directly:

it('can sign up a user with an international phone number', function () {
    // Using the factory method...
    SignupRequest::factory()->fake();
    
    // ...or using the fake method
    SignupRequest::fake();
    
    $this->put('/users')->assertValid();
});

Using fakeRequest in Pest PHP

If you're using Pest, we provide a higher order method that you can chain onto your tests:

// You can provide the form request FQCN...
it('can sign up a user with an international phone number', function () {
    $this->put('/users')->assertValid();
})->fakeRequest(SignupRequest::class);

// Or the request factory FQCN...
it('can sign up a user with an international phone number', function () {
    $this->put('/users')->assertValid();
})->fakeRequest(SignupRequestFactory::class);

// Or even a closure that returns a request factory...
it('can sign up a user with an international phone number', function () {
    $this->put('/users')->assertValid();
})->fakeRequest(fn () => SignupRequest::factory());

You can even chain factory methods onto the end of the fakeRequest method:

it('can sign up a user with an international phone number', function () {
    $this->put('/users')->assertValid();
})
    ->fakeRequest(SignupRequest::class)
    ->state(['name' => 'Jane Bloggs']);

Overriding request factory data

It's important to note the order of importance request factories take when injecting data into your request.

  1. Any data passed to get, post, put, patch, delete or similar methods will always take precedence.
  2. Data defined using state, or methods called on a factory that alter state will be next in line.
  3. Data defined in the factory definition and files methods come last, only filling out missing properties from the request.

Let's take a look at an example to illustrate this order of importance:

it('can sign up a user with an international phone number', function () {
    SignupRequest::factory()->state(['name' => 'Oliver Nybroe', 'email' => '[email protected]'])->fake();
    
    $this->put('/users', ['email' => '[email protected]'])->assertValid();
});

The default email defined in SignupRequestFactory is [email protected]. The default name is Luke Downing. Because we override the name property using the state method before calling fake, the name used in the form request will actually be Oliver Nybroe, not Luke Downing.

However, because we pass [email protected] as data to the put method, that will take priority over all other defined data, both [email protected] and [email protected].

The power of factories

Factories are really cool, because they allow us to create a domain-specific-language for our feature tests. Because factories are classes, we can add declarative methods that serve as state transformers.

// In our factory...
class SignupRequestFactory extends RequestFactory
{
    // After the definition...
    public function withOversizedProfilePicture(): static
    {
        return $this->state(['profile_picture' => $this->file()->image('profile.png', 2001, 2001)])
    }
}

// In our test...
it('does not allow profile pictures larger than 2000 pixels', function () {
    SignupRequest::factory()->withOversizedProfilePicture()->fake();
    
    $this->put('/users')->assertInvalid(['profile_picture' => 'size']);
});

The state method is your friend for any data you want to add or change on your factory. What about if you'd like to omit a property from the request? Try the without method!

it('requires an email address', function () {
    SignupRequest::factory()->without(['email'])->fake();
    
    $this->put('/users')->assertInvalid(['email' => 'required']);
});

💡 You can use dot syntax in the without method to unset deeply nested keys

Sometimes, you'll have a property that you want to be based on the value of other properties. In that case, you can provide a closure as the property value, which receives an array of all other parameters:

class SignupRequestFactory extends RequestFactory
{
    public function definition(): array
    {
        return [
            'name' => 'Luke Downing',
            'company' => 'Worksome',
            'email' => fn ($properties) => Str::of($properties['name'])
                ->replace(' ', '.')
                ->append("@{$properties['company']}.com")
                ->lower()
                ->__toString(), // [email protected]
        ];
    }
}

Occasionally, you'll notice that multiple requests across your application share a similar subset of fields. For example, a signup form and a payment form might both contain an address array. Rather than duplicating these fields in your factory, you can nest factories inside factories:

class SignupRequestFactory extends RequestFactory
{
    public function definition(): array
    {
        return [
            'name' => 'Luke Downing',
            'company' => 'Worksome',
            'address' => AddressRequestFactory::new(),
        ];
    }
}

Now, when the SignupRequestFactory is created, it will resolve the AddressRequestFactory for you and fill the address property with all fields contained in the AddressRequestFactory definition. Pretty cool hey?

Using factories without form requests

Not every controller in your app requires a backing form request. Thankfully, we also support faking a generic request:

it('lets a guest sign up to the newsletter', function () {
    NewsletterSignupFactory::new()->fake();
    
    post('/newsletter', ['email' => '[email protected]'])->assertRedirect('/thanks');
});

Solving common issues

I'm getting a CouldNotLocateRequestFactoryException

When using the HasFactory trait on a FormRequest, we attempt to auto-locate the relevant request factory for you. If your directory structure doesn't match for whatever reason, this exception will be thrown.

It can easily be resolved by adding a public static $factory property to your form request:

class SignupRequest extends FormRequest
{
    use HasFactory;
    
    public static $factory = SignupRequestFactory::class; 
}

I call multiple routes in a single test and want to fake both

No sweat. Just place a call to fake on the relevant request factory before making each request:

it('allows a user to sign up and update their profile', function () {
    SignupRequest::fake();
    post('/signup');
    
    ProfileRequest::fake();
    post('/profile')->assertValid();
});

I don't want to use the default location for storing request factories

Not a problem. We provide a config file you may publish where you can edit the path and namespace of request factories. First, publish the config file:

php artisan vendor:publish --tag=request-factories

Now, in the newly created config/request-factories.php, alter the path and namespace keys to suit your requirements:

return [
    'path' => base_path('request_factories'),
    'namespace' => 'App\\RequestFactories',
];

Testing

We pride ourselves on a thorough test suite and strict static analysis. You can run all of our checks via a composer script:

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Resolve Faker generator via application service container

    Resolve Faker generator via application service container

    In an application (where we make use of this package) we have a custom Faker provider. I a service provider we add the custom provider so we can make use of it in our database factories:

    // ...
    
    $this->app->afterResolving(Generator::class, static function (Generator $generator): void {
        $generator->addProvider(new CustomProvider($generator));
    });
    
    // ...
    

    With the changes in this pull request I can use the same custom Faker provider methods inside the definition array.

    // ...
    
    public function definition(): array
    {
        return [
            'foo' => $this->faker()->customMethod,
        ];
    }
    
    // ...
    

    I had to move the RequestFactoryTest class inside the Feature namespace because a Laravel's container is needed for resolving a Generator instance.

    opened by maartenpaauw 6
  • Adds dot-notation support for the `state` method.

    Adds dot-notation support for the `state` method.

    Based on discussion #9, this PR allows a user to set a deeply nested array value using the state method.

    $data = MyRequestFactory::new()->state(['address.line_one' => '1 Test Street'])->create();
    

    @dcaswel can you please verify that this solves your use case?

    opened by lukeraymonddowning 6
  • TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, int given

    TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, int given

    I am getting below error, after the new release.

    TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, int given
    
    /vendor/worksome/request-factories/src/Actions/UndotArrayKeys.php:50
    /vendor/worksome/request-factories/src/Actions/UndotArrayKeys.php:50
    /vendor/worksome/request-factories/src/Actions/UndotArrayKeys.php:30
    /vendor/worksome/request-factories/src/Actions/UndotArrayKeys.php:34
    /vendor/worksome/request-factories/src/Actions/UndotArrayKeys.php:25
    /vendor/worksome/request-factories/src/RequestFactory.php:76
    
    opened by parth391 2
  • Bump ramsey/composer-install from 1 to 2

    Bump ramsey/composer-install from 1 to 2

    Bumps ramsey/composer-install from 1 to 2.

    Release notes

    Sourced from ramsey/composer-install's releases.

    2.0.0

    Added

    • Use --prefer-stable with lowest dependencies (#178)
    • Allow use of a custom cache key (#167)
    • Allow ability to ignore the cache

    Changed

    Fixed

    • Fix case where working-directory did not run composer install in the correct working directory (#187)
    • Fix problems with retrieving cache with parallel builds (#161, #152)
    • Fix problems restoring from cache on Windows (#79)

    1.3.0

    • Support passing --working-dir as part of composer-options

    1.2.0

    • Support Composer working-directory option for when composer.json is in a non-standard location.
    • Add operating system name to the cache key.

    1.1.0

    Display Composer output with ANSI colors.

    1.0.3

    Patch release for dependency updates.

    1.0.2

    • Use the GitHub cache action directly to avoid duplication of code/effort.
    • Turn on output of Composer command to provide feedback in the job log
    • Use Composer cache-dir instead of cache-files-dir

    1.0.1

    Rewrite and refactor as a JavaScript action.

    Commits
    • 83af392 :sparkles: Add new custom-cache-suffix option (#239)
    • 7f9021e Fix use of deprecated set-output command (#238)
    • 4617231 Tests: update the included composer.phar from v 2.2.2 to 2.2.18 (#237)
    • 72896eb Add dependabot configuration file (#227)
    • 69e970d GH Actions: version update for codecov action runner (#226)
    • e3612f6 GH Actions: version update for actions/cache (#224)
    • d515102 GH Actions: version update for various predefined actions (#222)
    • 6085843 GH Actions: re-work the integration tests (#221)
    • f680dac test: add PHP path back to command, as well as debug message
    • 3c51967 test: ensure we use the alternate composer location
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    opened by dependabot[bot] 1
  • Target [Worksome\RequestFactories\Contracts\Actions\CreatesFactoryResult] is not instantiable.

    Target [Worksome\RequestFactories\Contracts\Actions\CreatesFactoryResult] is not instantiable.

    Environment:

    php: 8.1.0
    
    laravel/framework: v9.38.0
    pestphp/pest: v1.22.2
    worksome/request-factories: v2.5.0
    

    Test:

    it('creates the invoice with invoice items', function () {
      $data = StoreInvoiceRequestFactory::new()->create();
    
      $result = (new CreateInvoiceAction())->run($data);
    });
    

    The error:

       PHPUnit\Framework\ExceptionWrapper 
    
      Target [Worksome\RequestFactories\Contracts\Actions\CreatesFactoryResult] is not instantiable.
    
      at vendor/laravel/framework/src/Illuminate/Container/Container.php:1091
        1087▕         } else {
        1088▕             $message = "Target [$concrete] is not instantiable.";
        1089▕         }
        1090▕ 
      ➜ 1091▕         throw new BindingResolutionException($message);
        1092▕     }
        1093▕ 
        1094▕     /**
        1095▕      * Throw an exception for an unresolvable primitive.
        ```
    
    opened by hjJunior 1
  • Bump dependabot/fetch-metadata from 1.3.3 to 1.3.4

    Bump dependabot/fetch-metadata from 1.3.3 to 1.3.4

    Bumps dependabot/fetch-metadata from 1.3.3 to 1.3.4.

    Release notes

    Sourced from dependabot/fetch-metadata's releases.

    v1.3.4

    What's Changed

    New Contributors

    Full Changelog: https://github.com/dependabot/fetch-metadata/compare/v1.3.3...v1.3.4

    Commits
    • bfc19f4 v1.3.4
    • 4367f58 Merge pull request #258 from dependabot/dependabot/npm_and_yarn/yaml-2.1.1
    • 00ab600 Manually bump dist/
    • bdbe81d Bump yaml from 2.0.1 to 2.1.1
    • 5fc325a Merge pull request #257 from dependabot/dependabot/npm_and_yarn/typescript-4.8.3
    • c91309c Bump typescript from 4.6.3 to 4.8.3
    • 264d039 Merge pull request #266 from dependabot/dependabot/npm_and_yarn/ts-node-10.9.1
    • d1cd6ed Bump ts-node from 10.7.0 to 10.9.1
    • e3cb77e Merge pull request #265 from dependabot/dependabot/npm_and_yarn/actions/githu...
    • e462341 [dependabot skip] Update dist/ with build changes
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    opened by dependabot[bot] 1
  • Adds support for passing a string to without.

    Adds support for passing a string to without.

    Small QOL improvement. Most of the time, you only want to unset a single item using without, so I thought it would be nice to accept a string as well as an array.

    opened by lukeraymonddowning 1
  • Replace request data recursively

    Replace request data recursively

    If my expectations mentioned in discussion #18 are correct, this pull request will solve it.

    Only downside is it does not work for nested request factories (because the fake data of nested request factories is resolved later in the process).

    opened by maartenpaauw 1
  • Bump dependabot/fetch-metadata from 1.3.1 to 1.3.3

    Bump dependabot/fetch-metadata from 1.3.1 to 1.3.3

    Bumps dependabot/fetch-metadata from 1.3.1 to 1.3.3.

    Release notes

    Sourced from dependabot/fetch-metadata's releases.

    v1.3.3

    What's Changed

    New Contributors

    Full Changelog: https://github.com/dependabot/fetch-metadata/compare/v1.3.2...v1.3.3

    v1.3.2

    What's Changed

    New Contributors

    Full Changelog: https://github.com/dependabot/fetch-metadata/compare/v1.3.1...v1.3.2

    Commits
    • 605e039 Merge pull request #233 from dependabot/v1.3.3-release-notes
    • e0f3842 v1.3.3
    • ac6adf8 Merge pull request #232 from jsok/patch-1
    • 15259f7 action.yaml: fix skip-commit-verification quoting
    • 90ed90d Merge pull request #226 from dependabot/v1.3.2-release-notes
    • 28b141f v1.3.2
    • cfb7274 Merge pull request #225 from dependabot/brrygrdn/skip-commit-verification
    • 6c87543 Bump dist/
    • d882a80 Update documentation
    • b1673a7 Add skip-commit-verification input
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    opened by dependabot[bot] 1
  • Bump dependabot/fetch-metadata from 1.3.0 to 1.3.1

    Bump dependabot/fetch-metadata from 1.3.0 to 1.3.1

    Bumps dependabot/fetch-metadata from 1.3.0 to 1.3.1.

    Release notes

    Sourced from dependabot/fetch-metadata's releases.

    v1.3.1

    Highlights

    This release is primarily catching up on our dependencies, but it also includes a few bug fixes:

    What's Changed

    New Contributors

    Full Changelog: https://github.com/dependabot/fetch-metadata/compare/v1.3.0...v1.3.1

    Commits
    • bfac3fa Merge pull request #210 from dependabot/v1.3.1-release-notes
    • 80173ff Small correction to bump-version script
    • 525fbe9 v1.3.1
    • 58f09fc Merge pull request #206 from dependabot/dependabot/npm_and_yarn/yaml-2.0.1
    • b1d2cf8 Bump dist/
    • 70c6c9e Bump yaml from 1.10.2 to 2.0.1
    • 7b49493 Merge pull request #209 from dependabot/dependabot/npm_and_yarn/vercel/ncc-0....
    • 13f5830 Bump @​vercel/ncc from 0.33.3 to 0.33.4
    • 59ab888 Merge pull request #208 from dependabot/dependabot/npm_and_yarn/types/node-17...
    • aad4446 Bump @​types/node from 17.0.23 to 17.0.25
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    opened by dependabot[bot] 1
  • Bump dependabot/fetch-metadata from 1.1.1 to 1.3.0

    Bump dependabot/fetch-metadata from 1.1.1 to 1.3.0

    Bumps dependabot/fetch-metadata from 1.1.1 to 1.3.0.

    Release notes

    Sourced from dependabot/fetch-metadata's releases.

    v1.3.0 - Fetch additional metadata via the GitHub API

    Highlights

    🆕 Fetch additional metadata about Dependabot commits

    You can now optionally enable API lookups within the Action to retrieve extra information about Dependabot PRs.

    Example:

    -- .github/workflows/dependabot-prs.yml
    name: Dependabot Pull Request
    on: pull_request_target
    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
        - name: Fetch Dependabot metadata
          id: dependabot-metadata
          uses: dependabot/[email protected]
          with:
            alert-lookup: true
            compat-lookup: true
    

    The flags enable the following new outputs:

    • steps.dependabot-metadata.outputs.alert-state
      • If this PR is associated with a security alert and alert-lookup is true, this contains the current state of that alert (OPEN, FIXED or DISMISSED).
    • steps.dependabot-metadata.outputs.ghsa-id
      • If this PR is associated with a security alert and alert-lookup is true, this contains the GHSA-ID of that alert.
    • steps.dependabot-metadata.outputs.cvss
      • If this PR is associated with a security alert and alert-lookup is true, this contains the CVSS value of that alert (otherwise it contains 0).
    • steps.dependabot-metadata.outputs.compatibility-score
      • If this PR has a known compatibility score and compat-lookup is true, this contains the compatibility score (otherwise it contains 0).

    Many thanks to @​mwaddell for contributing these additional flags 🥇

    The Action no longer fails if other commits are present

    We received feedback at this change was highly obtrusive and blocking common workflows that merging in the target branch. Following on from changes in 1.2.1 to make it easier for a user to re-run failed workflows this friction was much more obvious.

    Thanks for the feedback, and thanks @​mwaddell for contributing the change.

    The Action defaults to using the GITHUB_TOKEN

    This makes us consistent with other GitHub Actions such as actions/checkout in using the baseline token provided to the workflow. Since the Action doesn't have any features which require write scopes this defaulting is adequate for all use cases.

    Thanks @​jablko for contributing this change 🏆

    What's Changed

    ... (truncated)

    Commits
    • a96c30f Merge pull request #170 from dependabot/v1.3.0-release-notes
    • 11d3bb7 v1.3.0
    • 0ca01a5 Merge pull request #146 from pangaeatech/get_compat_score
    • f4b2d0d Merge pull request #83 from jablko/patch-1
    • 26e18ca Merge branch 'main' into patch-1
    • a30bbbb Merge pull request #166 from pangaeatech/allow-other-commits
    • 9a3daaf linting
    • 4a87565 Allow fetch-metadata to run on a PR even if it has additional commits, as lon...
    • 749688a Merge pull request #165 from pangaeatech/update_readme
    • 592101e Updated README to reference correct version
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    opened by dependabot[bot] 1
  • Bump dependabot/fetch-metadata from 1.3.4 to 1.3.5

    Bump dependabot/fetch-metadata from 1.3.4 to 1.3.5

    Bumps dependabot/fetch-metadata from 1.3.4 to 1.3.5.

    Release notes

    Sourced from dependabot/fetch-metadata's releases.

    v1.3.5

    What's Changed

    New Contributors

    Full Changelog: https://github.com/dependabot/fetch-metadata/compare/v1...v1.3.5

    Commits
    • 5ef0018 Merge pull request #282 from dependabot/v1.3.5-release-notes
    • a9380d2 v1.3.5
    • 404ba25 Merge pull request #280 from dependabot/drop-readme-from-bump-script
    • f40d4c7 Don't bump pin versions in README.md
    • 7db64c3 Merge pull request #252 from dependabot/document-release-steps
    • daa85e7 Add mention of npm run build if dev deps need updating.
    • b768c40 Document steps for cutting a new release
    • 9833f74 Merge pull request #273 from dependabot/dependabot/npm_and_yarn/yargs-and-typ...
    • 32b7ed3 Bump yargs and @​types/yargs
    • 7942397 Merge pull request #271 from dependabot/dependabot/npm_and_yarn/actions/githu...
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    opened by dependabot[bot] 1
Releases(v2.5.0)
  • v2.5.0(Sep 15, 2022)

    What's Changed

    • Adds support for passing a string to without. by @lukeraymonddowning in https://github.com/worksome/request-factories/pull/26

    Full Changelog: https://github.com/worksome/request-factories/compare/v2.4.0...v2.5.0

    Source code(tar.gz)
    Source code(zip)
  • v2.4.0(Sep 13, 2022)

    What's Changed

    • Adds support for nested arrays and lazily resolving model factories. by @lukeraymonddowning in https://github.com/worksome/request-factories/pull/24

    Full Changelog: https://github.com/worksome/request-factories/compare/v2.3.0...v2.4.0

    Source code(tar.gz)
    Source code(zip)
  • v2.3.0(Sep 1, 2022)

    What's Changed

    • Adds image as a new helper method inside the factory. by @lukeraymonddowning in https://github.com/worksome/request-factories/pull/23

    Full Changelog: https://github.com/worksome/request-factories/compare/v2.2.0...v2.3.0

    Source code(tar.gz)
    Source code(zip)
  • v2.2.0(Aug 30, 2022)

    What's Changed

    • Allows passing an instance of self to the request factory ::new method. by @lukeraymonddowning in https://github.com/worksome/request-factories/pull/22

    Full Changelog: https://github.com/worksome/request-factories/compare/v2.1.0...v2.2.0

    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Aug 4, 2022)

    What's Changed

    • Adds support for custom Faker instances by @lukeraymonddowning and @maartenpaauw in https://github.com/worksome/request-factories/pull/21

    Full Changelog: https://github.com/worksome/request-factories/compare/v2.0.2...v2.1.0

    Source code(tar.gz)
    Source code(zip)
  • v2.0.2(Jul 25, 2022)

    What's Changed

    • Bump dependabot/fetch-metadata from 1.3.1 to 1.3.3 by @dependabot in https://github.com/worksome/request-factories/pull/16
    • Replace request data recursively by @maartenpaauw in https://github.com/worksome/request-factories/pull/19

    New Contributors

    • @maartenpaauw made their first contribution in https://github.com/worksome/request-factories/pull/19

    Full Changelog: https://github.com/worksome/request-factories/compare/v2.0.1...v2.0.2

    Source code(tar.gz)
    Source code(zip)
  • v2.0.1(Jun 23, 2022)

    What's Changed

    • Fixes bug with lists and dot notation introduced in v2 by @lukeraymonddowning in https://github.com/worksome/request-factories/pull/14

    Full Changelog: https://github.com/worksome/request-factories/compare/v2.0.0...v2.0.1

    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Jun 20, 2022)

    What's Changed

    • Fix Typo: compliments->complements by @jdlien in https://github.com/worksome/request-factories/pull/4
    • Change license email by @olivernybroe in https://github.com/worksome/request-factories/pull/5
    • Add extra line break by @driesvints in https://github.com/worksome/request-factories/pull/6
    • Typo fix in readme by @glennforrest in https://github.com/worksome/request-factories/pull/7
    • Adds dot-notation support for the state method. by @lukeraymonddowning in https://github.com/worksome/request-factories/pull/10

    New Contributors

    • @jdlien made their first contribution in https://github.com/worksome/request-factories/pull/4
    • @olivernybroe made their first contribution in https://github.com/worksome/request-factories/pull/5
    • @driesvints made their first contribution in https://github.com/worksome/request-factories/pull/6
    • @glennforrest made their first contribution in https://github.com/worksome/request-factories/pull/7
    • @lukeraymonddowning made their first contribution in https://github.com/worksome/request-factories/pull/10

    Full Changelog: https://github.com/worksome/request-factories/compare/v1.1.1...v2.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Worksome
Building a future platform for flexible employment.
Worksome
Mock HTTP requests on the server side in your PHP unit tests

HTTP Mock for PHP Mock HTTP requests on the server side in your PHP unit tests. HTTP Mock for PHP mocks the server side of an HTTP request to allow in

InterNations GmbH 386 Dec 27, 2022
This plugin adds basic HTTP requests functionality to Pest tests, using minicli/curly

Curly Pest Plugin This plugin adds basic HTTP requests functionality to Pest tests, using minicli/curly. Installation composer require minicli/pest-pl

minicli 16 Mar 24, 2022
⛽ Pest plugin to test Laravel applications powered by Octane.

⛽ Laravel Octane (Pest Plugin) Pest plugin to test Laravel applications powered by Octane. Install Via Composer composer require --dev cerbero/pest-pl

Andrea Marco Sartori 21 Apr 5, 2022
A sample RESTful API in Laravel with PHPunit test.

Laravel PHP Framework URL | URI | Action |

Fasil 9 Jul 11, 2020
Patchstack Test task Laravel&Vue CRUD

Patchstack Test Task - Laravel & Vue CRUD SPA Written with Laravel and Vue2 using mix. Installation Clone this repository Run "composer update" comman

Crypto Rookie 3 Aug 25, 2022
:heavy_check_mark: PHP Test Framework for Freedom, Truth, and Justice

Kahlan is a full-featured Unit & BDD test framework a la RSpec/JSpec which uses a describe-it syntax and moves testing in PHP one step forward. Kahlan

Kahlan 1.1k Jan 2, 2023
Event driven BDD test framework for PHP

The highly extensible, highly enjoyable, PHP testing framework. Read more at peridot-php.github.io or head over to the wiki. Building PHAR Peridot's p

Peridot 327 Jan 5, 2023
BDD test framework for PHP

BDD test framework for PHP, inspired by Jasmine and RSpec. Features a familiar syntax, and a watch command to automatically re-run specs during develo

Daniel St. Jules 286 Nov 12, 2022
vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with any unit test framework, like PHPUnit or SimpleTest.

vfsStream vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with

null 1.4k Dec 23, 2022
PHPUnit Application Architecture Test

PHPUnit Application Architecture Test Idea: write architecture tests as well as feature and unit tests Installation Install via composer composer requ

null 19 Dec 11, 2022
A Composer script to run a 'test' or 'spec' Composer script against multiple PHP versions.

composer-multitest composer-multitest is a Composer script that runs a test or spec Composer script against multiple PHP versions managed by PHPBrew o

Raphael Stolt 5 Aug 27, 2019
The Phoronix Test Suite is the most comprehensive testing and benchmarking platform

The Phoronix Test Suite is the most comprehensive testing and benchmarking platform available for Linux, Solaris, macOS, Windows, and BSD operating systems.

Phoronix Test Suite 1.9k Jan 7, 2023
Prevent none-test output in your Pest tests.

Pest Plugin Silence Often, when writing tests, we echo and dump test code to debug and check everything is working correctly. It can be easy to forget

Worksome 5 Feb 23, 2022
PHP Test Generator - A CLI tool which generates unit tests

This project make usages of PHPStan and PHPParser to generate test cases for a given PHP File.

Alexander Schranz 7 Dec 3, 2022
Few additional testing assertions for Laravel views

Laravel View Test Assertions Few additional assertions for testing Laravel views. Why Laravel has well established and documented way of testing reque

null 13 Jun 12, 2022
Real-world Project to learning about Unit Testing/TDD with Laravel for everybody

KivaNote - a Laravel TDD Sample Project Let me introduce you to KivaNote, a simple real-world application using Laravel to show you how the TDD & Unit

(Seth) Phat Tran 10 Dec 31, 2022
Package for unit testing Laravel form request classes

Package for unit testing Laravel form request classes. Why Colin DeCarlo gave a talk on Laracon online 21 about unit testing Laravel form requests cla

null 18 Dec 11, 2022
Wraps your Pest suite in a Laravel application instance, allowing global use of the framework in tests.

Pest Larastrap Plugin This is currently a highly experimental project and is subject to large pre-release changes. Pest PHP is an awesome PHP testing

Luke Downing 3 Jan 6, 2022