Download the PHP package symfonyboot/inject-mocks without Composer

On this page you can find all versions of the php package symfonyboot/inject-mocks. 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 inject-mocks

Inject-Mocks

Tests Maintainability Test Coverage

Automatic injection of mocks into test subjects via @InjectMocks and @Mock annotations, to speed up unit testing with PHPUnit.

Summary

Language / Idioma

Leia a versão em português :brazil: aqui.

Instalation

To install in the development environment:

Requirements

Features

Using @InjectMocks and @Mock annotations in test classes you can automatically inject mocks into test subjects.

In a typical scenario, we would do it like this:

Example without @InjectMocks/@Mock:

This approach brings the difficulty of maintenance, because if the test subject is changed, either by adding, decreasing or replacing the dependencies, you will have to change it in each test.

With the @InjectMocks/@Mock annotations, we abstract these test subject changes. Example:

Example with @InjectMocks/@Mock:

Usage

As in the example in the previous topic, the @InjectMocks annotation must be placed on the property of the test subject that you want to test, and the @Mock annotation must be placed on the properties corresponding to the dependencies that you want to mock or inject.

After that, run the injector service with the sentence MockInjector::inject($this). This execution can be declared in each test or in setUp.

After executing the injector, the service annotated with @InjectMocks will be a real instance available in the scope of the test class, and each dependency annotated with @Mock will be an instance of MockObject, injected into the test subject via the constructor, and will also be available in the scope of the test class.

Details

1. Scope of Annotations

2. Behaviors

@InjectMocks and @Mock work independently and alone, or together. Details about each one:

2.1. @InjectMocks

It will create a real instance through the constructor, and if there are parameters in the constructor, the following value will be used in each parameter, in this order:

Obs.: You can use @Mock annotation on all, some or none of the test subject's dependencies.

2.2. @Mock

Will create a mock injected into the TestCase scope, without using the constructor. This creation behavior is identical to TestCase::createMock().


All versions of inject-mocks with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
doctrine/annotations Version ^2.0
silasyudi/optional Version ^2.0
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 symfonyboot/inject-mocks contains the following files

Loading the files please wait ....