2017 © Pedro Peláez
 

symfony-bundle blueprint-bundle

The bundle provides a way to manage test data for the Doctrine ORM

image

dakatsuka/blueprint-bundle

The bundle provides a way to manage test data for the Doctrine ORM

  • Friday, December 6, 2013
  • by dakatsuka
  • Repository
  • 1 Watchers
  • 4 Stars
  • 7,118 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Blueprint Bundle Build Status

The bundle provides a way to manage test data for the Doctrine ORM., (*1)

Installation

Add this lines to your composer.json:, (*2)

{
    "require": {
        "dakatsuka/blueprint-bundle": "1.1.0"
    },
}

And then execute:, (*3)

$ php composer.phar install

And import a BlueprintBundle to AppKernel.php:, (*4)

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
    $bundles[] = new Dakatsuka\BlueprintBundle\DakatsukaBlueprintBundle();
}

Usage

src/Acme/BlogBundle/Tests/Blueprints/post.php:, (*5)

namespace Acme\BlogBundle\Tests\Blueprints;

use Dakatsuka\BlueprintBundle\Blueprint;

Blueprint::register('post', 'Acme\BlogBundle\Entity\Post', function($post, $blueprint) {
    $post->setTitle('Title'.$blueprint->sequence());
    $post->setBody('BodyBodyBody');
});

src/Acme/BlogBundle/Tests/Blueprints/comment.php:, (*6)

namespace Acme\BlogBundle\Tests\Blueprints;

use Dakatsuka\BlueprintBundle\Blueprint;

Blueprint::register('comment', 'Acme\BlogBundle\Entity\Comment', function($comment, $blueprint) {
    $comment->setPost($blueprint->create('post'));
    $comment->setBody('CommentCommentComment');
});

How to use:, (*7)

static::$kernel = static::createKernel();
static::$kernel->boot();
static::$container = static::$kernel->getContainer();

$blueprint = static::$container->get('dakatsuka.blueprint');
$blueprint->loadFromDirectory(static::$kernel->getRootDir() . '/../src/Acme/BlogBundle/Tests/Blueprints');

$post = $blueprint->create('post');
$this->assertEquals('Title1', $post->getTitle());
$this->assertEquals('BodyBodyBody', $post->getBody());

$comment = $blueprint->create('comment');
$this->assertEquals('CommentCommentComment', $comment->getBody());
$this->assertEquals('Title2', $comment->getPost()->getTitle());

// optional
$comment2 = $blueprint->create('comment', array('post' => $post));
$this->assertSame($post, $comment2->getPost());

Tips

Nested blueprint (required cascade={"persist"} option):, (*8)

Blueprint::register('post', 'Acme\BlogBundle\Entity\Post', function($post, $blueprint) {
    $post->setTitle('Title'.$blueprint->sequence());
    $post->setBody('BodyBodyBody');
    $post->getComments()->add($blueprint->build('comment', array('post' => $post));
    $post->getComments()->add($blueprint->build('comment', array('post' => $post));
    $post->getComments()->add($blueprint->build('comment', array('post' => $post));
});

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Test

$ make phpunit
$ make test

Copyright (C) 2013 Dai Akatsuka, released under the MIT License., (*9)

The Versions

06/12 2013

dev-master

9999999-dev

The bundle provides a way to manage test data for the Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

test symfony2 blueprint

06/12 2013

1.1.0

1.1.0.0

The bundle provides a way to manage test data for the Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

test symfony2 blueprint

02/08 2013

1.0.3

1.0.3.0

The bundle provides a way to manage test data for the Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

test symfony2 blueprint

29/07 2013

1.0.2

1.0.2.0

The bundle provides a way to manage test data for the Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

test symfony2 blueprint

29/07 2013

1.0.1

1.0.1.0

The bundle provides a way to manage test data for the Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

test symfony2 blueprint

05/06 2013

1.0.0

1.0.0.0

The bundle provides a way to manage test data for the Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

test symfony2 blueprint