Code Monkey home page Code Monkey logo

contributions-atoum-praspelextension's Introduction

atoum/praspel-extension

This extension introduces Praspel inside atoum.

atoum is a simple, modern and intuitive unit testing framework for PHP!

Hoa is a modular, extensible and structured set of PHP libraries. Moreover, Hoa aims at being a bridge between industrial and research worlds.

Installation

With Composer, to include this library into your dependencies, you need to require atoum/praspel-extension:

composer require --dev atoum/praspel-extension

Please, read the website to get more informations about how to install.

And to activate the extension, add this line on your .atoum.php configuration file:

$runner->addExtension(new \Atoum\PraspelExtension\Manifest());

Quick usage

This extension brings two aspects into atoum: automatic test data generation (from Hoa\Realdom) and automatic test suite generation (from Hoa\Praspel, which relies on Hoa\Realdom).

Automatic test data generation

[more explications needed] We will use three asserters to generate data and one to validate data:

  1. realdom to create a realistic domains disjunction,
  2. sample to generate one data from a realistic domains disjunction,
  3. sampleMany to generate several data,
  4. predicate to validate a data against a realistic domains disjunction.

As an example, we are going to generate an integer defined by: [7; 13] ∪ [42; 153]:

$this->sample($this->realdom->boundinteger(7, 13)->or->boundinteger(42, 153))

We can obviously use the classical asserters from atoum:

foreach ($this->sampleMany($this->realdom->boundinteger(-5, 5), 1024) as $i) {
    $this->integer($i)->isGreaterThan(0);
}

(this example is a little dummy ;-)).

We can generate more sophisticated data (please, see the standard realistic domain library in Hoa\Realdom), such as strings based on regular expressions (and also grammars):

$data = $this->realdom->regex('/[\w\-_]+(\.[\w\-\_]+)*@\w\.(net|org)/');
$this->string($this->sample($data))
     ->contains(…)->…;

Or even dates:

$data = $this->realdom->date(
    'd/m H:i',
    $this->realdom->boundinteger(
        $this->realdom->timestamp('yesterday'),
        $this->realdom->timestamp('next Monday')
    )
);

foreach ($this->sampleMany($data, 10) as $date) {
    var_dump($date);
}

Automatic test suite generation

We will use the Bin/praspel binary script. [TODO]

Documentation of Hoa

Different documentations can be found on the website: https://hoa-project.net/.

Links

License

Hoa, along with this extension, is under the New BSD License (BSD-3-Clause). Please, see LICENSE.

atoum + Hoa

contributions-atoum-praspelextension's People

Contributors

agallou avatar hywan avatar jubianchi avatar vonglasow avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

contributions-atoum-praspelextension's Issues

Remove call to Hoa\Core

Still have dependencies to Hoa\Core in binary Praspel.php

Bin/Praspel.php
60:use Hoa\Core;
65:Core::enableErrorHandler();
66:Core::enableExceptionHandler();
88:catch ( Core\Exception $e ) {

Bin/Command/Generate.php
40:use Hoa\Core;
140:        $phpBinary = Core::getPHPBinary() ?:
147:        $envVariable   = '__ATOUM_PRASPEL_EXTENSION_' . md5(Core::uuid());
151:        $reflectionner->on('input', function ( Core\Event\Bucket $bucket )
166:        $reflectionner->on('output', function ( \Hoa\Core\Event\Bucket $bucket )

Exception.php
42: * Extending the \Hoa\Core\Exception class.
49:class Exception extends \Hoa\Core\Exception { }

Autoloader.php
46:if(is_file($vendorAutoloader = $vendorDirectory . '/hoa/core/Core.php'))
47:    require_once $vendorDirectory . '/hoa/core/Core.php';
55:    ->addDirectory('Hoa\Core', $vendorDirectory . '/hoa/core')

Praspel/Generator.php
40:use Hoa\Core;
150:            catch ( Core\Exception $e ) {
223:            catch ( Core\Exception $e ) {

Replace Core usage in files

  • Bin/Praspel.php
  • Bin/Command/Generate.php
  • Exception.php
  • Autoloader.php
  • Praspel/Generator.php

Use Hoa\Exception\Idle::enableUncaughtHandler for exceptions
Use Hoa\Exception\Error::enableErrorHandler for errors

Update hoa/realdom/

Currently I'm getting some warning regarding
The each() function is deprecated. This message will be suppressed on further calls
I think this is fixed upstream. Can we update this dependency?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.