chriskite / phactory

A Database Factory for PHP Unit Tests

Home Page:http://phactory.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

joslinm opened this issue · comments

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


$this->now(); was returning a DateTime object.