<commit_before># TestDummy

![image](https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/testdummy/crashtestdummy.jpg)

TestDummy makes the process of preparing your database for integration tests as easy as possible. ...As easy as:

### Make a Post entity with dummy attributes.

```php
use Laracasts\TestDummy\Factory;

$post = Factory::build('Post');
```

This might return:

```bash
array(4) {
  ["title"]=>
  string(21) "The Title of the Post"
  ["author_id"]=>
  string(1) "5"
  ["body"]=>
  string(226) "Iusto qui optio et iste. Cumque aliquid et omnis enim. Nesciunt ad esse a reiciendis expedita quidem veritatis. Nostrum repellendus reiciendis distinctio amet sapiente. Eum molestias a recusandae modi aut et adipisci corrupti."
  ["publish_date"]=>
  string(19) "2014-03-02 11:05:48"
}
```

### Create a post, but override the default title

```php
use Laracasts\TestDummy\Factory;

Factory::create('Post', ['title' => 'My Title']);
```

```bash
array(4) {
  ["title"]=>
  string(14) "My New Package"
  ["author_id"]=>
  string(1) "5"
  ["body"]=>
  string(254) "In eos porro qui est rerum possimus voluptatem non. Repudiandae eaque nostrum eaque aut deleniti possimus quod minus. Molestiae commodi odit sunt dignissimos corrupti repudiandae quibusdam quo. Autem maxime tenetur autem corporis aut quis sint occaecati."
  ["publish_date"]=>
  string(19) "2013-06-24 10:01:30"
}
```

### Build a song entity, and save it to the database.

```php
use Laracasts\TestDummy\Factory;

$song = Factory::create('Song');
```

If the `songs` table has relationships - like `album_id`, then the relationship entities will be built and saved, too.

### Create and persist a comment three times

```php
use Laracasts\TestDummy\Factory;
<commit_msg>Readme stuff<commit_after># TestDummy

![image](https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/testdummy/crashtestdummy.jpg)

TestDummy makes the process of preparing your database for integration tests as easy as possible. ...As easy as:

### Make a Post entity with dummy attributes.

```php
use Laracasts\TestDummy\Factory;

$post = Factory::build('Post');
```

If we then do `$post->toArray()`, this might return:

```bash
array(4) {
  ["title"]=>
  string(21) "The Title of the Post"
  ["author_id"]=>
  string(1) "5"
  ["body"]=>
  string(226) "Iusto qui optio et iste. Cumque aliquid et omnis enim. Nesciunt ad esse a reiciendis expedita quidem veritatis. Nostrum repellendus reiciendis distinctio amet sapiente. Eum molestias a recusandae modi aut et adipisci corrupti."
  ["publish_date"]=>
  string(19) "2014-03-02 11:05:48"
}
```

### Build a post, but override the default title

```php
use Laracasts\TestDummy\Factory;

Factory::build('Post', ['title' => 'My Title']);
```

Again, when cast to an array...

```bash
array(4) {
  ["title"]=>
  string(14) "My New Package"
  ["author_id"]=>
  string(1) "5"
  ["body"]=>
  string(254) "In eos porro qui est rerum possimus voluptatem non. Repudiandae eaque nostrum eaque aut deleniti possimus quod minus. Molestiae commodi odit sunt dignissimos corrupti repudiandae quibusdam quo. Autem maxime tenetur autem corporis aut quis sint occaecati."
  ["publish_date"]=>
  string(19) "2013-06-24 10:01:30"
}
```

### Build a song entity, and save it to the database.

```php
use Laracasts\TestDummy\Factory;

$song = Factory::create('Song');
```

If the `songs` table has relationships - like `album_id`, then the relationship entities will be built and saved, too.

### Create and persist a comment three times

```php
use Laracasts\TestDummy\Factory;

{'fraction_non_alphanumeric': 0.13531723750701852, 'fraction_numerical': 0.030320044918585063, 'mean_word_length': 4.709935897435898, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7601914', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1224, 'n_words': 406}