I'm trying to get Phactory working with a Symfony2 project. Here's what I have in one of my unit tests:
<?php
namespace VNN\PressboxBundle\Tests\Entity;
namespace VNN\PressboxBundle\Entity;
use VNN\PressboxBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Phactory\Sql\Phactory;
class UserTest extends EntityTest
{
public function testCreate()
{
Phactory::define('user', array(
'username' => 'jasonswett',
));
}
}
The error I'm getting when I try to run that test is this:
PHP Fatal error: Class 'Phactory\Sql\Phactory' not found in /Users/jason/Web/pressbox/src/VNN/PressboxBundle/Tests/Entity/UserTest.php on line 12
Fair enough. How do I get this file to talk to Phactory? If it helps, I know that the Phactory class is defined in vendor/chriskite/phactory/lib/Phactory/Sql/Phactory.php and the first few lines of it look like this:
<?php
namespace Phactory\Sql;
class Phactory {
Just add the
Phactorynamespace toautoload.php.Also, I prefer to set PHPUnit's
bootstrapargument toautoload.phpinphpunit.xml.dist:This works great for Symfony 2.1 projects based on Composer, but I'm not sure about the 2.0 ones.