Skip to content

Recursively convert existing objects into Alice fixtures

License

Notifications You must be signed in to change notification settings

trappar/AliceGenerator

Repository files navigation

AliceGenerator Build Status

Recursively convert existing objects into Alice Fixtures.

Introduction

Sometimes you find yourself working on a large project with no existing fixtures. In this case even though Alice makes fixtures much easier to write, that process can still be tedious.

This library proposes an alternate starting point - automatically generate fixtures from your existing data.

This opens up a whole new, much faster way to get your test data established... just enter it in your user interface!

Example

Let's say you have the following objects

<?php
class Post {
    public $title;
    public $body;
    public $postedBy;
}

class User {
    public $username;
}

$user = new User();
$user->username = 'Trappar';

$post1 = new Post();
$post1->title = 'Is Making Fixtures Too Time Consuming?';
$post1->body = 'Check out Alice!';
$post1->postedBy = $user;

$post2 = new Post();
$post2->title = 'Too Much Data to Hand Write?';
$post2->body = 'Check out AliceGenerator!';
$post2->postedBy = $user;

This library let's you turn that directly into...

Post:
    Post-1:
        title: 'Is Making Fixtures Too Time Consuming?'
        body: 'Check out Alice!'
        postedBy: '@User-1'
    Post-2:
        title: 'Too Much Data to Hand Write?'
        body: 'Check out AliceGenerator!'
        postedBy: '@User-1'
User:
    User-1:
        username: Jeff

Installation

You can use Composer to install the library to your project:

composer require trappar/alice-generator

Features

  • Framework support
    • Supports Symfony via AliceGeneratorBundle - Start generating fixtures immediately with zero custom code required!
  • ORM support
    • Supports Doctrine natively
    • Can operate without any ORM
    • Can be extended to support any ORM
  • Many ways to make use of Faker providers
  • Configure how your objects are serialized using annotations or YAML metadata
  • Can serialize any object type using custom ObjectHandlers
  • Supports multiple levels of recursion taming
    • Handles circular references automatically
    • Customizable maximum recursion depth
    • Can restrict object traversal to only specific objects of a type
  • Supports several methods of naming Alice references natively - fully customizable

Table of Contents

Resources

Credits

This bundle was developed by Jeff Way with quite a lot of inspiration from:

Other contributors.

License

license

About

Recursively convert existing objects into Alice fixtures

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages