Gedmo \ Tree测试:SQLite失败,MySQL通过

时间:2015-04-08 17:59:17

标签: php mysql sqlite symfony

在使用SQLite对类别树进行简单测试时,使用

进行设置时测试失败
  

的appbundle \测试\实体\ CategoryTest :: testSetProductCategory()   Doctrine \ DBAL \ DBALException:执行时发生异常   ' INSERT INTO类别(title,lft,lvl,rgt,root,deletedAt,   parent_id)VALUES(?,?,?,?,?,?,?)'用params [" Hook",null,   null,null,null,null,null]:SQLSTATE [23000]:完整性约束   违规:19 NOT NULL约束失败:category.lft

使用MySQL数据库执行相同的测试,测试成功。测试环境数据库&模式是使用控制台命令创建的。

测试设置:

public function setUp()
{
    self::bootKernel();
    $this->em = static::$kernel->getContainer()
            ->get('doctrine')
            ->getManager()
    ;
    $product = new \AppBundle\Entity\Product();
    $product->setName('foo');
    $this->em->persist($product);

    $cat = new \AppBundle\Entity\Category();
    $cat->setTitle('Hook');
    $this->em->persist($cat);

    $child = new \AppBundle\Entity\Category();
    $child->setTitle('Dry');
    $child->setParent($cat);
    $this->em->persist($child);

    $this->em->flush();
}

config_test.yml with SQLite:

doctrine:
    dbal:
        default_connection: test
        connections:
            test:
                driver:   pdo_sqlite
                path:     %kernel.cache_dir%/test.sqlite
带有MySQL的

config_test.yml:

doctrine:
    dbal:
        host:     localhost
        dbname:   flyby_test
        user:     root
        password: [password]

MySQL架构:

enter image description here

SQLite架构:

enter image description here

0 个答案:

没有答案