Download the PHP package tobento/app-testing without Composer

On this page you can find all versions of the php package tobento/app-testing. 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 app-testing

App Testing

Testing support for the app.

Table of Contents

Getting Started

Add the latest version of the app testing project running this command.

Requirements

Documentation

Getting Started

To test your application extend the class.

Next, use the method to create the app for testing:

Tmp App

You may use the method, to create an app for testing individual boots only.

Finally, write tests using the available fakers.

By default, the app is not booted nor run yet. You will need to do it on each test method. Some faker methods will run the app automatically though such as the fakeHttp method.

App clearing

When creating a tmp app, you may call the method to delete the app directory.

Or you may use the method:

Config Tests

In some cases you may want to define or replace config values for specific tests:

Http Tests

Request And Response

If you have installed the App Http bundle you may test your application using the method.

Request method

Or you may prefer using methods:

Use the method to create a request with the following headers:

Response method

Calling the response method will automatically run the app.

withoutMiddleware

previousUri

You may set a previous uri if your controller uses the previous uri to redirect back if an error occurs for example.

Http Url

You may sometimes wish to modify the http url in order to have relative urls for instance;

Subsequent Requests

After making a request, subsequent requests will create a new app. Any fakers from the first request will be rebooted.

Following redirects

File Uploads

You can use the file factory to generate dummy files or images for testing purposes:

Create a fake image

Create a fake file

Crawl Response Content

You may crawl the response content using the Symfony Dom Crawler.

assertNodeExists

assertNodeMissing

Example Form Crawling

JSON Response

You may test JSON responses using the method.

Assertable Json

You may use the class to fluently test JSON responses.

Assert Key

Assert that the key exists:

Assert Value

Assert that the value matches:

Assert Key And Value

Assert that the value matches the key value:

Assert Items

Asserts that the items count matches.

Assert Passes

Asserts that passes evaluates to true.

Hasnt

Use the method asserting the opposite of the method.

Response Macros

You may want to write convenience helpers to the test response using macros.

Refresh Session

You may refresh your session after each test by using trait:

Auth Tests

If you have installed the App User bundle you may test your application using the method.

The next two examples assumes you have already seeded test users in some way:

Example With Token

You may want to authenticate a user by creating a token:

Example Seeding Users

This is one possible way of seeding users for testing. You could also seed users by creating and using Seeders.

You may check out the User Seeding to learn more about the .

File Storage Tests

If you have installed the App File Storage bundle you may test your application using the method which allows you to create a fake storage that mimics the behavior of a real storage, but doesn't actually send any files to the cloud. This way, you can test file uploads without worrying about accidentally sending real files to the cloud.

Example using a tmp app:

Storage Method

Storages Method

Queue Tests

If you have installed the App Queue bundle you may test your application using the method which allows you to create a fake queue to prevent jobs from being sent to the actual queue.

Example using a tmp app:

Clear Queue

Sometimes it may be useful to clear the queue using the method:

Run Jobs

Sometimes it may be useful to run jobs using the method:

Event Tests

If you have installed the App Event bundle you may test your application using the method which records all events that are dispatched and provides assertion methods that you can use to check if specific events were dispatched and how many times. Currently, only Default Events will be recorded. Specific Events are not supported yet.

Example using a tmp app:

Mail Tests

If you have installed the App Mail bundle you may test your application using the method which allows you to create a fake mailer to prevent messages from being sent.

Example using a tmp app:

Notifier Tests

If you have installed the App Notifier bundle you may test your application using the method which allows you to create a fake notifier to prevent notification messages from being sent.

Example using a tmp app:

Database Tests

If you have installed the App Database bundle you may interact with your databases.

Reset Databases

There are two strategies to reset your databases:

Refresh Strategy

This strategy cleans your database after each test.

Migrate Strategy

This strategy cleans your database after each test using migrations.

Replace Databases

You may replace your database to test different databases.

Example replacing the default storage database:

Logging Tests

If you have installed the App Logging bundle you may test your application using the method which allows you to create a fake logger to prevent logging with the actual logger.

Example using a tmp app:

Credits


All versions of app-testing with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
tobento/app Version ^1.0.7
tobento/app-console Version ^1.0
tobento/app-seeding Version ^1.0
tobento/service-collection Version ^1.0
tobento/service-iterable Version ^1.0
tobento/service-macro Version ^1.0
mockery/mockery Version ^1.6
nyholm/psr7 Version ^1.4
symfony/mime Version ^6.0 || ^7.0
symfony/dom-crawler Version ^6.0
symfony/css-selector Version ^6.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 tobento/app-testing contains the following files

Loading the files please wait ....