Yii 1.1: generator4fixtures

Extension for Gii. Generate fixtures (PHPUnit).
16 followers

Just unpack 'gii' to application.protected and run /index.php?r=gii

Screen 1

Screen 2

protected
      |--   gii
      |   `--   fixture
      |       |--   templates
      |       |   `--   default
      |       `--   views

https://bitbucket.org/denis_medved/my-yii-extension

Similar extensions ΒΆ

yii-generator-collection

Total 12 comments

#11317 report it
le_top at 2013/01/05 11:13am
Removing file

I understand that removing the file is a solution, but why not use a feature (difference, replace, ...) when it already exists?

#11316 report it
Denis Medved at 2013/01/05 10:59am
Fixture regeneration

Remove files from 'application.tests.fixtures' (alias) if you need rebuild your fixtures. Thanks for reporting.

#11311 report it
le_top at 2013/01/05 05:27am
Regeneration of fixtures

Thanks for this usefull extension.

I wanted to regenerate certain fixtures, but the code did not allow this. You need to comment part of the following line in FixtureCode::prepare as indicated:

if (!in_array($tableName, $tableNames) /* && !file_exists($writeTo)*/)

During the preview, files do not get committed to disk and we get a list of files that would change and those the would not change, as usual.

#8321 report it
Denis Medved at 2012/05/25 10:17am
Re: "Fixed for Enum classes and Giix generated classes."

Fixed. Thanks for report.

#8320 report it
warden at 2012/05/25 09:15am
Fixed for Enum classes and Giix generated classes.

Giix generated classes have abstract classes inside models/base/ directory. Also, I am using Enum class that has a private constructor and cannot be instantiated.

Modified version of scanDir function:

protected function scanDir($path){
        foreach (scandir($path) as $file){
            $filename = $path . DIRECTORY_SEPARATOR . $file;
            $className = pathinfo($filename,PATHINFO_FILENAME);
            if ('.' !== $file && '..' !== $file)
                if (is_file($filename = $path . DIRECTORY_SEPARATOR . $file) && 'php' === pathinfo($file,PATHINFO_EXTENSION) && false === strpos($className,'Enum')){
                    $reflection = new ReflectionClass($className);
                    if (!$reflection->isAbstract())
                        $this->_models[] = $file;
                }
                else if (is_dir($filename))
                {
                    Yii::import($this->modelPath . '.' . $file . '.*');
                    $this->scanDir($filename);
                }
        }
    }
#5357 report it
Denis Medved at 2011/10/06 04:26pm
fix of "fixture file name by aliases due to db table prefix"

I was getting DB aliases like {{mytable}} that didn't work for me inside the UnitTest fixture call probably because I use prefixes tbl_ I simply added line 55 $tableName = str_replace(array("{{","}}"), array("tbl_",""),$obj->tableName());

the prefix could even be pulled out of config db settings

Thanks you for report. Issues fixed: https://bitbucket.org/denis_medved/my-yii-extension/changeset/dd60b21284ce (line 57-59)

#5350 report it
Tibor Katelbach at 2011/10/06 07:20am
fixture file name by aliases due to db table prefix

I was getting DB aliases like {{mytable}} that didn't work for me inside the UnitTest fixture call probably because I use prefixes tbl_ I simply added line 55 $tableName = str_replace(array("{{","}}"), array("tbl_",""),$obj->tableName());

the prefix could even be pulled out of config db settings

#4375 report it
Raoul at 2011/07/01 01:55pm
for PHP 5.3 only ..unless...

Hi, static reference using a variable is not supported before PHP 5.3. I've replaced

$models = $class::model()->findAll($criteria);

by

$models = $obj->findAll($criteria);

(FixtureCode.php Line 63 & 65) and it seems to work fine.

Thanks for this useful extension !

#3759 report it
Denis Medved at 2011/05/05 04:30pm
'out of memory' fixed

Fixed https://bitbucket.org/BuCeFaL/ext4yii/issue/2/out-of-memory

#3435 report it
prchakal at 2011/04/12 05:02pm
Error

Yes :)

#3434 report it
Denis Medved at 2011/04/12 04:46pm
LIMIT

Optional limit for rows, can help ?

#3433 report it
prchakal at 2011/04/12 04:03pm
Error

Hi,

I have some tables with too many data. And when i try make the preview os fixtures, i get the error:

**[12-Apr-2011 17:02:36] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 40 bytes) in /usr/local/zend/apache2/htdocs/sdc/protected/framework/db/CDbCommand.php on line 496 **

Can you make same cache feature using files on something else? My database is so big and the 512M reserved to PHP is low.

Leave a comment

Please to leave your comment.

Create extension
Downloads