1. Go to this page and download the library: Download kengos/factory_girl library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kengos / factory_girl example snippets
use FactoryGirl\Factory as FactoryGirl;
$factoryPaths = array('foo/bar/factories', 'bar/baz/factories');
FactoryGirl::setup($factoryPaths);
// UserFactory.php
return array(
'class' => 'User',
'attributes' => array(),
'save' => array('generate'),
);
// In your test
FactoryGirl::create('User');
// called `generate`, instead of `save`
// UserFactory.php
return array(
'class' => 'User',
'attributes' => array(
'setName' => 'foo',
'generatePassword' => array('plain_password', 'seed'),
),
);
// In your test
FactoryGirl::create('User');
// $user = new User;
// $user->setName('foo');
// $user->generatePassword('plain_password', 'seed');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.