public function testCreateBean() { $this->assertInstanceOf('\\Dongww\\Db\\Doctrine\\Dbal\\Manager\\Bean', static::$userManager->createBean()); $bean = static::$userManager->createBean(['username' => 'silex', 'password' => 'pass']); $this->assertEquals('silex', $bean->username); $this->assertEquals('pass', $bean->password); }
public function remove(Bean $bean) { //todo 可能有点问题,需要进一步测试 $qb = $this->getSelectQueryBuilder()->select('id')->where('parent_id = :pid')->setParameter('pid', $bean->id); $data = $this->getConnection()->fetchAll($qb->getSQL(), $qb->getParameters()); foreach ($data as $d) { $childBean = $this->get($d['id']); $this->move($childBean, null, 1); } $qb = $this->getUpdateQueryBuilder()->set('sort', 'sort - 1')->where('sort > :sort')->setParameter('sort', $bean->sort); if ($bean->parent_id) { $qb->andWhere('parent_id = :pid')->setParameter('pid', $bean->parent_id); } else { $qb->andWhere('parent_id is null'); } $this->getConnection()->executeUpdate($qb->getSQL(), $qb->getParameters()); return parent::remove($bean); }