Download the PHP package buildotter/php-core without Composer

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

Buildotter Logo

Buildotter Core

Tests GitHub release (latest SemVer) Conventional Commits

Foundation to implement the Test Data Builder Pattern in PHP.

Installation

What's the Test Data Builder Pattern?

Creating and managing test data is a critical aspect of ensuring the quality and reliability of an application.

The Test Data Builder Pattern is a technique for simplifying the process of constructing test data, making tests more maintainable and readable.

It provides a structured way to create complex and consistent test data for your test cases.

This pattern isolate the process of creating test data from the actual test logic.

By doing so, it promotes separation of concerns and helps you write cleaner and more focused tests.

It helps for the following problems:

The 4 rules to keep in mind are:

To know more about the Test Data Builder Pattern, you can read the following articles:

Why do we need libraries to implement the Test Data Builder Pattern?

We don't.

It is more about helping with repetitive tasks, speed up the process of creating test data builders and being focused on the test logic itself.

With time passing, we gathered parts that are common to projects. So why not share them?

Furthermore, it helps to have a common foundation for the adoption of the pattern in a team.

Usage

We tried not to be too opinionated about the foundation here. For instance, we like to use functions like anElephant() instead of ElephantBuilder::new() (we find it more readable and allow us to focus on what is important) but nothing forces you to do the same.

The main foundation: Buildotter\Core\Buildatable interface

You may found the name weird, it is a mix of "build" and "data" with the suffix "-able". "-able" is used to form adjectives from verbs, with the meaning "capable of, fit for, tending to". With this name, we want to express that the object is capable of building data as a test data builder.

The Buildotter\Core\Buildatable::new() method is the named constructor to create a new instance of the class with commonly used or safe values. Imagine that you develop a dating app, you know the age of your customers. Most of the time you don't mind about the exact age, you just need one respecting the invariants of your domain (see Propery-Based Testing for more about this). It is less likely that a customer is 300 or 10 years old than between 18 and 60 years old for instance. It means that a commonly used or safe value for the age of a customer is between 18 and 60 years old. So instead of choosing an arbitrary value, you may use a random value between 18 and 60 years old.

The Buildotter\Core\Buildatable::build() method to create a new object using the values in its properties.

A ::with() method with Buildotter\Core\BuildableWithXXX traits

We provide some traits that already implement a ::with() method.

Buildotter\Core\BuildableWithArgUnpacking allows you to use named arguments to set the properties of the builder.

Buildotter\Core\BuildableWithArray allows you to set properties of the builder by passing an array as its argument.

You may prefer one or the other depending on your preferences. You may choose to use both. You may choose to not use them at all.

Build multiple objects

You may need multiple objects of the same type at once. Buildotter\Core\Many static methods are here to help you.

Example

Imagine you have a class Elephant with the following constructor:

You may create a test data builder for this class like this:

Feel free to create functions like anElephant() and someTopics() to make your tests more readable.

For instance, we may have a file containing the following functions:

And then, during testing:

More

To generate test data builders, you may use the Buildotter Maker Standalone. Instead, you may prefer to use PHPStorm Live templates. Or combine them.

Question: Do you think that it could be helpful to share some live templates that helps for testing?

Contributing

See the contributing guide.

TODOs


All versions of php-core with dependencies

PHP Build Version
Package Version
Requires php Version ^8.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 buildotter/php-core contains the following files

Loading the files please wait ....