Download the PHP package maplephp/unitary without Composer

On this page you can find all versions of the php package maplephp/unitary. 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?
maplephp/unitary
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package unitary

MaplePHP - Unitary

PHP Unitary is a user-friendly and robust unit testing library designed to make writing and running tests for your PHP code easy. With an intuitive CLI interface that works on all platforms and robust validation options, Unitary makes it easy for you as a developer to ensure your code is reliable and functions as intended.

Prompt demo

Syntax You Will Love

Documentation

The documentation is divided into several sections:

Installation

To install MaplePHP Unitary, run the following command:

Guide

1. Create a Test File

Unitary will, by default, find all files prefixed with "unitary-" recursively from your project's root directory (where your "composer.json" file exists). The vendor directory will be excluded by default.

Start by creating a test file with a name that starts with "unitary-", e.g., "unitary-request.php". You can place the file inside your library directory, for example like this: tests/unitary-request.php.

Note: All of your library classes will automatically be autoloaded through Composer's autoloader inside your test file!

2. Create a Test Case

Now that we have created a test file, e.g., tests/unitary-request.php, we will need to add our test cases and tests. I will create a test for one of my other libraries below, which is MaplePHP/HTTP, specifically the Request library that has full PSR-7 support.

I will show you three different ways to test your application below.

The example above uses both built-in validation and custom validation (see below for all built-in validation options).

3. Run the Tests

Now you are ready to execute the tests. Open your command line of choice, navigate (cd) to your project's root directory (where your composer.json file exists), and execute the following command:

The Output:

Prompt demo And that is it! Your tests have been successfully executed!

With that, you are ready to create your own tests!

Configurations

Select a Test File to Run

After each test, a hash key is shown, allowing you to run specific tests instead of all.

Run Test Case Manually

You can also mark a test case to run manually, excluding it from the main test batch.

And this will only run the manual test:

Change Test Path

The path argument takes both absolute and relative paths. The command below will find all tests recursively from the "tests" directory.

Note: The vendor directory will be excluded from tests by default. However, if you change the --path, you will need to manually exclude the vendor directory.

Exclude Files or Directories

The exclude argument will always be a relative path from the --path argument's path.

Validation List

Each prompt can have validation rules and custom error messages. Validation can be defined using built-in rules (e.g., length, email) or custom functions. Errors can be specified as static messages or dynamic functions based on the error type.

Data Type Checks

  1. isString

    • Description: Checks if the value is a string.
    • Usage: "isString" => []
  2. isInt

    • Description: Checks if the value is an integer.
    • Usage: "isInt" => []
  3. isFloat

    • Description: Checks if the value is a float.
    • Usage: "isFloat" => []
  4. isBool

    • Description: Checks if the value is a boolean.
    • Usage: "isBool" => []
  5. isArray

    • Description: Checks if the value is an array.
    • Usage: "isArray" => []
  6. isObject

    • Description: Checks if the value is an object.
    • Usage: "isObject" => []
  7. isFile

    • Description: Checks if the value is a valid file.
    • Usage: "isFile" => []
  8. isDir

    • Description: Checks if the value is a valid directory.
    • Usage: "isDir" => []
  9. isResource

    • Description: Checks if the value is a valid resource.
    • Usage: "isResource" => []
  10. number
    • Description: Checks if the value is numeric.
    • Usage: "number" => []

Equality and Length Checks

  1. equal

    • Description: Checks if the value is equal to a specified value.
    • Usage: "equal" => ["someValue"]
  2. notEqual

    • Description: Checks if the value is not equal to a specified value.
    • Usage: "notEqual" => ["someValue"]
  3. length

    • Description: Checks if the string length is between a specified start and end length.
    • Usage: "length" => [1, 200]
  4. equalLength
    • Description: Checks if the string length is equal to a specified length.
    • Usage: "equalLength" => [10]

Numeric Range Checks

  1. min

    • Description: Checks if the value is greater than or equal to a specified minimum.
    • Usage: "min" => [10]
  2. max

    • Description: Checks if the value is less than or equal to a specified maximum.
    • Usage: "max" => [100]
  3. positive

    • Description: Checks if the value is a positive number.
    • Usage: "positive" => []
  4. negative
    • Description: Checks if the value is a negative number.
    • Usage: "negative" => []

String and Pattern Checks

  1. pregMatch

    • Description: Validates if the value matches a given regular expression pattern.
    • Usage: "pregMatch" => ["a-zA-Z"]
  2. atoZ (lower and upper)

    • Description: Checks if the value consists of characters between a-z or A-Z.
    • Usage: "atoZ" => []
  3. lowerAtoZ

    • Description: Checks if the value consists of lowercase characters between a-z.
    • Usage: "lowerAtoZ" => []
  4. upperAtoZ

    • Description: Checks if the value consists of uppercase characters between A-Z.
    • Usage: "upperAtoZ" => []
  5. hex

    • Description: Checks if the value is a valid hex color code.
    • Usage: "hex" => []
  6. email

    • Description: Validates email addresses.
    • Usage: "email" => []
  7. url

    • Description: Checks if the value is a valid URL (http|https is required).
    • Usage: "url" => []
  8. phone

    • Description: Validates phone numbers.
    • Usage: "phone" => []
  9. zip

    • Description: Validates ZIP codes within a specified length range.
    • Usage: "zip" => [5, 9]
  10. domain

    • Description: Checks if the value is a valid domain.
    • Usage: "domain" => [true]
  11. dns

    • Description: Checks if the host/domain has a valid DNS record (A, AAAA, MX).
    • Usage: "dns" => []
  12. matchDNS

    • Description: Matches DNS records by searching for a specific type and value.
    • Usage: "matchDNS" => [DNS_A]
  13. lossyPassword

    • Description: Validates a password with allowed characters [a-zA-Z\d$@$!%*?&] and a minimum length.
    • Usage: "lossyPassword" => [8]
  14. strictPassword
    • Description: Validates a strict password with specific character requirements and a minimum length.
    • Usage: "strictPassword" => [8]

Required and Boolean-Like Checks

  1. required

    • Description: Checks if the value is not empty (e.g., not "", 0, NULL).
    • Usage: "required" => []
  2. isBoolVal

    • Description: Checks if the value is a boolean-like value (e.g., "on", "yes", "1", "true").
    • Usage: "isBoolVal" => []
  3. hasValue

    • Description: Checks if the value itself is interpreted as having value (e.g., 0 is valid).
    • Usage: "hasValue" => []
  4. isNull
    • Description: Checks if the value is null.
    • Usage: "isNull" => []

Date and Time Checks

  1. date

    • Description: Checks if the value is a valid date with the specified format.
    • Usage: "date" => ["Y-m-d"]
  2. dateTime

    • Description: Checks if the value is a valid date and time with the specified format.
    • Usage: "dateTime" => ["Y-m-d H:i"]
  3. time

    • Description: Checks if the value is a valid time with the specified format.
    • Usage: "time" => ["H:i"]
  4. age
    • Description: Checks if the value represents an age equal to or greater than the specified minimum.
    • Usage: "age" => [18]

Version Checks

  1. validVersion

    • Description: Checks if the value is a valid version number.
    • Usage: "validVersion" => [true]
  2. versionCompare
    • Description: Validates and compares if a version is equal/more/equalMore/less than a specified version.
    • Usage: "versionCompare" => ["1.0.0", ">="]

Logical Checks

  1. oneOf

    • Description: Validates if one of the provided conditions is met.
    • Usage: "oneOf" => [["length", [1, 200]], "email"]
  2. allOf
    • Description: Validates if all the provided conditions are met.
    • Usage: "allOf" => [["length", [1, 200]], "email"]

Additional Validations

  1. creditCard

    • Description: Validates credit card numbers.
    • Usage: "creditCard" => []
  2. vatNumber
    • Description: Validates Swedish VAT numbers.
    • Usage: "vatNumber" => []

All versions of unitary with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
maplephp/blunder Version ^1.0
maplephp/dto Version ^3.0
maplephp/http Version ^1.0
maplephp/validate Version ^1.0
maplephp/prompts Version ^1.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 maplephp/unitary contains the following files

Loading the files please wait ....