Git Product home page Git Product logo

phactory's People

Contributors

abarrera avatar amsa avatar cgarvis avatar chriskite avatar cschwendiman avatar drock avatar jimbojsb avatar lumbendil avatar maciej-bielski avatar ramsey avatar renebruns avatar sebastianbergmann avatar trimbletodd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phactory's Issues

ErrorException: strpos() expects parameter 1 to be string, object given

Why does this fail?

           # User
            Phactory::define('user', array(
                'user_name_first' => 'Test_$n',
                'user_name_last' => 'User_$n',
                'user_name_display' => 'Testerman_$n',
                'user_type' => 'Tester',
            ));

            # Montage
            Phactory::define('montage', 
                array(
                    'theme_id' => 1,
                    'featured' => '$n'
                ),
                array (
                    'user_id' => Phactory::oneToOne('user', 'user_id', 'user_id')
                )
            );

            # Cast
            Phactory::define('cast', 
                array(
                    'active' => true,
                    'joined_date_start' => $this->now()
                ),
                array(
                    'user_id' => Phactory::manyToOne('user'),
                    'montage_id' => Phactory::oneToOne('montage', 'montage_id', 
                        'montage_id'),
            ));

           # Create three users
            $user1 = Phactory::create('user');
            $user2 = Phactory::create('user');
            $user3 = Phactory::create('user');

            # Create one montage for $user1 to make him cast leader
            $montage = Phactory::createWithAssociations('montage',
                array('user_id' => $user1));

            # Create the cast
            $cast = Phactory::createWithAssociations('cast',
                array('user_id' => $user2, 'montage_id' => $montage));

ErrorException: strpos() expects parameter 1 to be string, object given

/usr/share/php/Phactory/lib/Phactory/Blueprint.php:146
/usr/share/php/Phactory/lib/Phactory/Blueprint.php:76
/usr/share/php/Phactory/lib/Phactory/Blueprint.php:96
/usr/share/php/Phactory/lib/Phactory.php:110
/home/mark/dev/projects/cameo/cameo-api/tests/includes/Table/NotificationTest.php:19


isset() doesn't work as expected

When calling isset(), it doesn't look like the model is implementing the magic method __isset() to look in _storage for the value.

Phactory::define('users', array('uid'=>'$n'));
$user = Phactory::create('users', array('uid'=>1));
var_dump($user->uid);  // string(1) "1"
var_dump(isset($user->uid)); // bool(false)

Site hacked?

Hey, not sure, but I think your website has been hacked and replaced with wedding planning?

can't set the table prefix

Our system uses table prefixes and Phactory has no way that I could find to add the prefix for table names

Backticks on table name causes problems in multi-database testing

Referring to the patch here: #14

This is great for fixing table names that are reserved words (although this really should be avoided in the first place IMO), but it causes issues when working and testing with multiple databases.

If using a multi-database set-up the syntax "database_name.table_name" doesn't work with surrounding backticks, as it treats the whole expression as a table name.

I'm having to revert this patch on my copy to get it working, is there a workaround to this?

Perhaps maintaining a list of reserved words and escaping those explicitly, or detecting and seperating expressions containing a '.', although this would genuine table names containing a fullstop/period.. or alternatively modding the code to allow you to specify database as a separate argument?

Cant find Phactory error when attempting to use with composer.

You cant use this "as is" with composer. This was something I could not find in the documentation. You must have the following "use" keyword

use Phactory\Sql\Phactory;

at the beginning of your file if you want to use it as it is currently documented. You will get the following error otherwise:

Fatal error: Class 'Phactory' not found in ...

I was really excited to use this library in my unit tests... until none of it really worked. The documentation is horribly outdated. I appreciate the attempt made to make this a composer package, however it does not work at all, and I constantly keep getting errors as I "fix" one item after another.

Phactory::define() naming problem

Hi Chris,

I have a bit of annoyance when using Phactory in Eclipse and a few other IDE's. The Phactory::define() method doesn't validate since Eclipse thinks that we are trying to call php's native define().

I am going to submit a pull request/patch that aliases the Phactory::define() method defineBlueprint(). In my honest opinion define() was not the best naming choice in your otherwise awesome component.

Inflector.php conflicts with existing Inflector.php in CakePHP

I'm evaluating Phactory to create PHPUnit tests on a project that uses a pre-Cake 2.0 version CakePHP. When I first pulled it down I was getting errors that the Inflector class conflicts with the Inflector class in CakePHP. This made it impossible to use the pear'd version.

I've renamed the class locally to Inflector_p for evaluation purposes, but it might be worth adding a namespace or changing the name to something less common to avoid issues like this.

More configurations for get

It would be nice to pass conditions to the get.

Like if I wanted to get the latest created user:

Phactory::get('user', array('name' => 'testuser'), array(
    'order' => 'id DESC', 
    'limit' => 1,
);

should be able to associate an array of objects when creating with a manyToMany association

For example, this should work:

Phactory::define('tag');

Phactory::define('post',
                 array('name' => 'Test Blog Post'),
                 array('tag' => Phactory::manyToMany('tag', 'posts_tags')));

$tag1 = Phactory::create('tag', array('name' => 'PHP'));
$tag1 = Phactory::create('tag', array('name' => 'Testing'));

$post = Phactory::createWithAssociations('post', array('tag' => array($tag1, $tag2)));

Existing functionality should be retained for backwards-compatibility.

UUID instead of Integer ID

Hey does this support UUIDs instead of Integers. The read me under "Limitations" says Integer, what about Unique UUID. Much more common now than INT.

Short tag problem

Hi chriskite.

I like this idea so much for relieving pain with DB testing.

By the way, I hit problem when requiring Phactory classes with PHPUnit.
I surely specified correct path to 'Phactory.php', but following error was appeard:

{{{
Fatal error: Class 'Phactory' not found in C:\work\scripts\excercise\src\tests\class\models\excerciseTest.php on line 26
}}}

Finally, I found that the problem is solved by rewriting all "<?" to "<?php".
It seems php short tags cause this problem.

It will need to be fixed.

The 'safe' option is deprecated, please use 'w' instead

Using phactory with mongo 2.6.5 and Apache mongo driver 1.5.6 i'm getting following error
MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead
Temporal fix was to change 'safe' with 'w' on file Blueprint.php on line 91

FindOne using integer property fails - but the same works using string

//Given:
Phactory::define('keys', array('Xid' => 9999999));
Phactory::create('keys');

// This FAILS to find the record:
...
$keysCollection = $udb->selectCollection('keys');
$keyResults = $keysCollection->findOne(array('Xid' => 9999999));

// However - if we simply change the data (stored and searched) to STRING it works!
Phactory::define('keys', array('Xid' => "9999999"));
Phactory::create('keys');
...
$keysCollection = $udb->selectCollection('keys');
$keyResults = $keysCollection->findOne(array('Xid' => "9999999"));

As you can see the number is small enough not to cause any potential Int64 strangeness.
Clearly a bug.

Should Use Safe Insert in Mongo

Since for testing purpose we check phactory writen data in mongo with our own code readden data, we are exposed to race condition.
It happens that Phactory::create use MongoCollection->insert and that '$collection->insert' don't wait for mongod response and our PHP test go on even if the data status is not what we expect. It happens for example on a slow development environnement.

I think Phactory::create should invoke collection->insert with array('safe'=>true) as second argument.

tests don't run on PHPUnit 3.5.13

All tests are generating errors like this:

  1. Phactory_Association_ManyToManyTest::testGuessFromColumn
    RuntimeException: PHP Notice: Constant PHACTORY_PATH already defined in C:\Site
    s\phactory_branch\phactory\tests\bootstrap.php on line 2
    PHP Stack trace:
    PHP 1. {main}() -:0
    PHP 2. require_once() -:1
    PHP 3. require_once() C:\Users\Owner\AppData\Local\Temp\PHPF57.tmp:43
    PHP 4. define() C:\Sites\phactory_branch\phactory\tests\bootstrap.php:2

Is there a recommended config to get these tests running? Also there are some deprecated warnings generated by latest PHPUnit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.