Download the PHP package bogdanghervan/laravel-dummy-observer without Composer

On this page you can find all versions of the php package bogdanghervan/laravel-dummy-observer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-dummy-observer

Laravel Dummy Observer

A purpose-built model observer that can be registered with an Eloquent model to intercept all attempted saves and perform assertions on the data. The data being saved never reaches the database.

Tests

Installation

Requirements

Installation

Install it via Composer:

Usage

Let's assume we'd like to test a method named landed on a model called Flight. This method would update the flight's status by invoking save internally.

This is how a unit test could look like:

Available assertions

assertSavedAttributes($attributes)

Verify that expected attributes are saved.

It's possible to verify that only a relevant subset of the attributes was saved.

We can make multiple assertions if consecutive saves are being made in the code being tested. Just make sure to specify them in the same order.

assertSavedTimes($times = 1)

Make an assertion on the number of times a model has been saved.

assertNothingSaved()

Make an assertion the model hasn't been saved.

clear()

Make sure to clear any captured data after every test. A good place to do this from is in the tearDown method:

Limitations

When working with multiple models, it is not possible to assert a save against the model where the save originated. See issue #1 for more details.

Support

Has this just helped you in a pinch when you tried to mock the Eloquent save method and nothing was working? Consider leaving me a note and buying me a coffee by clicking the button below.

ko-fi

Have you found a problem? Submit an issue

I myself have been inspired by the work done by @timacdonald on timacdonald/log-fake whom I'd like to thank!

Contributing

Pull requests are welcome. All contributions should follow the PSR-2 coding standard and should be accompanied by passing tests.

License

This package is available under the MIT License.


All versions of laravel-dummy-observer with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
phpunit/phpunit Version ^9.5
illuminate/database Version >=5.3
dms/phpunit-arraysubset-asserts Version ^0.2.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bogdanghervan/laravel-dummy-observer contains the following files

Loading the files please wait ....