PHPackages                             shortcodes/tests - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. shortcodes/tests

ActivePackage[Testing &amp; Quality](/categories/testing)

shortcodes/tests
================

This is test package for Laravel Application

0.0.5(5y ago)02.7k[2 PRs](https://github.com/shortcodes/tests/pulls)mitPHPPHP &gt;=7.0.0

Since Nov 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/shortcodes/tests)[ Packagist](https://packagist.org/packages/shortcodes/tests)[ RSS](/packages/shortcodes-tests/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (5)DependenciesVersions (11)Used By (0)

Test tools for laravel application 2
====================================

[](#test-tools-for-laravel-application-2)

This is package of test tools to help test laravel app properly

Tools
=====

[](#tools)

#### Api CRUD testing

[](#api-crud-testing)

To test CRUD in your API you need to create test that extends `Shortcodes\Tests\Blueprints\ApiCrudTest` and provide model class in protected property

```
class ModelCrudTest extends ApiCrudTest
{
    protected $model = Model::class;
}

```

By default test will perform assertions to test

- i\_can\_make\_index\_request\_and\_get\_200\_status
- i\_can\_make\_show\_request\_and\_get\_200\_status
- i\_can\_make\_store\_request\_and\_get\_201\_status
- i\_can\_make\_update\_request\_and\_get\_200\_status
- i\_can\_make\_delete\_request\_and\_get\_204\_status

It is crucial to remember that provided `model` must have factory with valid generated data.

If `index` method requires some query string parameters you can define it in class method

```
class ModelCrudTest extends ApiCrudTest
{
    protected $model = Model::class;

    public function getQueryStringParams(){
        return [
            'length' => 10,
            'page' => 1
        ];
    }
}

```

#### Form Request testing

[](#form-request-testing)

To test Form Request in your API you need to create test that extends `Shortcodes\Tests\Blueprints\FormRequestTest` and provide request class in protected property

```
class IndexModelRequestTest extends FormRequestTest
{
    protected $model = IndexModelRequest::class;
}

```

`FormRequestTest` class allow to use method to validate request like in the example

```
class IndexModelRequestTest extends FormRequestTest
{
    protected $model = IndexModelRequest::class;

    public function testValidRequest(){
        $this->prepareRequest(['some_data'=>'value'])->assertValidRequest()
    }

    public function testInvalidRequest(){
        $this->prepareRequest(['some_data'=>'value'])->assertInvalidRequest()
    }

    public function testInvalidParameterInRequest(){
        $this->prepareRequest(['some_data'=>'value','invalid_parameter'=>'value'])
            ->assertInvalidRequest()
            ->assertInvalidParameter(['invalid_parameter'])
            ->assertInvalidParameter('invalid_parameter')   //or without array
            ->assertInvalidParameter('missing_request_required_parameter')
    }

    public function testValidParameterInInvalidRequestRequest(){
        $this->prepareRequest(['some_data'=>'value','invalid_parameter'=>'value'])
            ->assertInvalidRequest()
            ->assertInvalidParameter(['invalid_parameter'])
            ->assertValidParameter(['some_data'])
    }
}

```

There is also possibility to test request whit required injected model like with query parameters.

```
class IndexModelRequestTest extends FormRequestTest
{
    protected $model = UpdateModelRequest::class;

    public function testTitleDuplicationRequest(){
        $object = Model::first();
        $this->prepareRequest(['title'=>$object->title'], $object)->assertValidRequest()
    }
}

```

#### Api request testing

[](#api-request-testing)

To test Api Request in you need to create test that extends `Shortcodes\Tests\Blueprints\TestCase`. This is a simple wrapper on standard method that allows to write less code.

```
$response = $this->apiRequest('POST', url('named.route.name'), $data, $headers);

```

Method create request that act as user defined in class `user` property or create one from factory. And attach header for authorization `X-App-Token` which is taken from `env('AUTH_KEY')`,

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~108 days

Total

5

Last Release

1987d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/30219536?v=4)[Roman Szymański](/maintainers/shortcodes)[@shortcodes](https://github.com/shortcodes)

---

Top Contributors

[![shortcodes](https://avatars.githubusercontent.com/u/30219536?v=4)](https://github.com/shortcodes "shortcodes (4 commits)")[![ttryka-mindz](https://avatars.githubusercontent.com/u/275661947?v=4)](https://github.com/ttryka-mindz "ttryka-mindz (2 commits)")

### Embed Badge

![Health badge](/badges/shortcodes-tests/health.svg)

```
[![Health](https://phpackages.com/badges/shortcodes-tests/health.svg)](https://phpackages.com/packages/shortcodes-tests)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M360](/packages/dms-phpunit-arraysubset-asserts)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
