Download the PHP package ddinchev/yii-factory-girl without Composer

On this page you can find all versions of the php package ddinchev/yii-factory-girl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii-factory-girl

yii-factory-girl

yii-factory-girl is a fixtures replacement with a straightforward definition syntax for Yii 1.1, inspired by though_bot's factory_girl for Ruby and kengos' FactoryGirl.

It was created in attempt to address the following limitations of kengos' FactoryGirlPHP:

Install

yii-factory-girl is installed most easily via Composer. Use the following command to install the latest 1.x.x version. Remove the --dev flag if you plan to run tests on environment where require-dev composer packages are not installed.

Usage

Make sure you have separate database for running unit tests. As with fixtures, any records in a table you are creating factories for, will be truncated first!

1) add the component to your test config (protected\config\test.php). The YiiFactoryGirl\Factory component has more attributes than the listed below. They are well documented in the class itself.

2) optionally create predefined factory data files under protected\tests\factories (configurable). They use the following file format:

3) now, if you call in your tests Yii::app()->factorygirl->create('Users'); this would create a Users record.

In the above last example, if you haven't defined VehiclesFactory.php file, you can create factories just the same. All that YiiFactoryGirl\Factory expects is that a class named Vehicles exists (or whatever you are trying to create) and you won't benefit from having predefined aliases/attributes which in many cases is just fine!

But there is one unpleasant small thing that you won't be able to use IDE auto-completion on your model created with Yii::app()->factorygirl->create(). First thing you can do is define a shortcut function in your tests bootstrap:

Now you can create new models with just $user = fg()->create('Users');. Now your IDE should know that $user is CActiveRecord, even if not the specific Users one. Of course, you could create a shortcut for creation of specific models. You could create a protected\tests\factories\shortcuts.php file and require it in your bootstrap.php with a definition like this:

From now on you will be able to create user factories in your tests just calling $testuser = UsersFactory::create(['username' => 'testname']); and your IDE will know that $testuser is instance of Users! This of course is some repetetive work, so it makes sense for models used a lot through the application.

FactoryGirl Sequence

This has been "borrowed" directly from kengos' FactoryGirl.

Contributing

Opening issues for feature requests/bug reports is an option but proposing a solution is much more helpful!

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

All versions of yii-factory-girl with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ddinchev/yii-factory-girl contains the following files

Loading the files please wait ....