1
0
Fork 0
mirror of synced 2025-04-01 20:36:14 +03:00

Adjusted test to verify that findBy*(null) is now supported

This commit is contained in:
Alexander 2011-10-17 18:54:20 +02:00
parent fea855004c
commit 91bc9c0329
2 changed files with 21 additions and 13 deletions

View file

@ -19,7 +19,7 @@ class CmsUser
*/
public $id;
/**
* @Column(type="string", length=50)
* @Column(type="string", length=50, nullable=true)
*/
public $status;
/**

View file

@ -38,18 +38,25 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user2->status = 'dev';
$this->_em->persist($user2);
$user3 = new CmsUser;
$user3->name = 'Benjamin';
$user3->username = 'beberlei';
$user3->status = null;
$this->_em->persist($user3);
$this->_em->flush();
$user1Id = $user->getId();
unset($user);
unset($user2);
unset($user3);
$this->_em->clear();
return $user1Id;
}
public function loadAssociatedFixture()
{
$address = new CmsAddress();
@ -189,7 +196,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users = $repos->findAll();
$this->assertEquals(2, count($users));
$this->assertEquals(3, count($users));
}
public function testFindByAlias()
@ -202,7 +209,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$repos = $this->_em->getRepository('CMS:CmsUser');
$users = $repos->findAll();
$this->assertEquals(2, count($users));
$this->assertEquals(3, count($users));
}
/**
@ -284,10 +291,11 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testFindMagicCallByNullValue()
{
$this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$this->setExpectedException('Doctrine\ORM\ORMException');
$users = $repos->findByStatus(null);
$this->assertEquals(1, count($users));
}
/**
@ -411,7 +419,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$users1 = $repos->findBy(array(), null, 1, 0);
$users2 = $repos->findBy(array(), null, 1, 1);
$this->assertEquals(2, count($repos->findBy(array())));
$this->assertEquals(3, count($repos->findBy(array())));
$this->assertEquals(1, count($users1));
$this->assertEquals(1, count($users2));
$this->assertNotSame($users1[0], $users2[0]);
@ -428,10 +436,10 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$usersAsc = $repos->findBy(array(), array("username" => "ASC"));
$usersDesc = $repos->findBy(array(), array("username" => "DESC"));
$this->assertEquals(2, count($usersAsc), "Pre-condition: only two users in fixture");
$this->assertEquals(2, count($usersDesc), "Pre-condition: only two users in fixture");
$this->assertSame($usersAsc[0], $usersDesc[1]);
$this->assertSame($usersAsc[1], $usersDesc[0]);
$this->assertEquals(3, count($usersAsc), "Pre-condition: only three users in fixture");
$this->assertEquals(3, count($usersDesc), "Pre-condition: only three users in fixture");
$this->assertSame($usersAsc[0], $usersDesc[2]);
$this->assertSame($usersAsc[2], $usersDesc[0]);
}