GithubHelp home page GithubHelp logo

camspiers / silverstripe-fixturegenerator Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 3.0 249 KB

Allows the generation of SilverStripe unit test fixtures from existing DataObjects either programatically created or from the database

PHP 100.00%

silverstripe-fixturegenerator's Introduction

SilverStripe Fixture Generator

Build Status against 2.2 and 3.0

Allows the generation of SilverStripe unit test fixtures from existing DataObjects either programatically created or from the database.

Creating fixtures files for unit tests is tedious at best, and this library's goal is to alleviate some of the pain.

Installation (with composer)

$ composer require camspiers/silverstripe-fixturegenerator:~0.1

Usage

Example with all relations allowed

use Camspiers\SilverStripe\FixtureGenerator;

$records = //some DataObjectSet

(new FixtureGenerator\Generator(
    new FixtureGenerator\Dumpers\Yaml(
        __DIR__ . '/tests/MyFixture.yml'
    )
))->process($records);

Example with certain relations allowed

use Camspiers\SilverStripe\FixtureGenerator;

$records = //some DataObjectSet

(new FixtureGenerator\Generator(
    new FixtureGenerator\Dumpers\Yaml(
        __DIR__ . '/tests/MyFixture.yml'
    ),
    array(
        'MyDataObject.SomeHasOneRelation',
        'MyDataObject.SomeHasManyRelation'
    )
))->process($records);

Example with certain relations excluded

use Camspiers\SilverStripe\FixtureGenerator;

$records = //some DataObjectSet

(new FixtureGenerator\Generator(
    new FixtureGenerator\Dumpers\Yaml(
        __DIR__ . '/tests/MyFixture.yml'
    ),
    array(
        'MyDataObject.SomeHasOneRelation',
        'MyDataObject.SomeHasManyRelation'
    ),
    FixtureGenerator\Generator::RELATION_MODE_EXCLUDE
))->process($records);

Unit testing

$ composer install --dev
$ phpunit

silverstripe-fixturegenerator's People

Contributors

camspiers avatar

Stargazers

Gordon Anderson avatar Nic avatar Milan Jelicanin avatar

Watchers

 avatar James Cloos avatar

silverstripe-fixturegenerator's Issues

How much work would there be to support SS3 and SS4?

Hi,

I just found this module and I don't have any SS2.4 project so I could test if this module generally works. But if it's meaningful, I could do some work to get this running on SS3 and also SS4. What do you think, did this module have any major issues back in the day when SS2.4 was current? If there were no big issues and the module was performing well, I could opt in bringing it up-to-date. Otherwise I need to seek for other options.

Thanks! :)

Module lacks a license

There's currently no license for this code making using it in projects a minor legal risk. Could you please add a LICENSE file or section to the ReadMe. GitHub has produced a simple site to help choose a reasonable open source license: http://choosealicense.com/

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.