15
15
use Symfony \Bridge \Doctrine \Test \DoctrineTestHelper ;
16
16
use Doctrine \DBAL \Connection ;
17
17
18
- class ORMQueryBuilderLoaderTest extends DoctrineTestHelper
18
+ class ORMQueryBuilderLoaderTest extends \PHPUnit_Framework_TestCase
19
19
{
20
20
/**
21
21
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
@@ -27,6 +27,7 @@ public function testItOnlyWorksWithQueryBuilderOrClosure()
27
27
28
28
/**
29
29
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
30
+ * @group legacy
30
31
*/
31
32
public function testClosureRequiresTheEntityManager ()
32
33
{
@@ -47,7 +48,7 @@ public function testIdentifierTypeIsIntegerArray()
47
48
48
49
protected function checkIdentifierType ($ classname , $ expectedType )
49
50
{
50
- $ em = $ this -> createTestEntityManager ();
51
+ $ em = DoctrineTestHelper:: createTestEntityManager ();
51
52
52
53
$ query = $ this ->getMockBuilder ('QueryMock ' )
53
54
->setMethods (array ('setParameter ' , 'getResult ' , 'getSql ' , '_doExecute ' ))
@@ -56,7 +57,7 @@ protected function checkIdentifierType($classname, $expectedType)
56
57
$ query ->expects ($ this ->once ())
57
58
->method ('setParameter ' )
58
59
->with ('ORMQueryBuilderLoader_getEntitiesByIds_id ' , array (), $ expectedType )
59
- ->will ( $ this -> returnValue ( $ query) );
60
+ ->willReturn ( $ query );
60
61
61
62
$ qb = $ this ->getMockBuilder ('Doctrine\ORM\QueryBuilder ' )
62
63
->setConstructorArgs (array ($ em ))
@@ -65,12 +66,41 @@ protected function checkIdentifierType($classname, $expectedType)
65
66
66
67
$ qb ->expects ($ this ->once ())
67
68
->method ('getQuery ' )
68
- ->will ( $ this -> returnValue ( $ query) );
69
+ ->willReturn ( $ query );
69
70
70
71
$ qb ->select ('e ' )
71
72
->from ($ classname , 'e ' );
72
73
73
74
$ loader = new ORMQueryBuilderLoader ($ qb );
74
75
$ loader ->getEntitiesByIds ('id ' , array ());
75
76
}
77
+
78
+ public function testFilterNonIntegerValues ()
79
+ {
80
+ $ em = DoctrineTestHelper::createTestEntityManager ();
81
+
82
+ $ query = $ this ->getMockBuilder ('QueryMock ' )
83
+ ->setMethods (array ('setParameter ' , 'getResult ' , 'getSql ' , '_doExecute ' ))
84
+ ->getMock ();
85
+
86
+ $ query ->expects ($ this ->once ())
87
+ ->method ('setParameter ' )
88
+ ->with ('ORMQueryBuilderLoader_getEntitiesByIds_id ' , array (1 , 2 , 3 ), Connection::PARAM_INT_ARRAY )
89
+ ->willReturn ($ query );
90
+
91
+ $ qb = $ this ->getMockBuilder ('Doctrine\ORM\QueryBuilder ' )
92
+ ->setConstructorArgs (array ($ em ))
93
+ ->setMethods (array ('getQuery ' ))
94
+ ->getMock ();
95
+
96
+ $ qb ->expects ($ this ->once ())
97
+ ->method ('getQuery ' )
98
+ ->willReturn ($ query );
99
+
100
+ $ qb ->select ('e ' )
101
+ ->from ('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity ' , 'e ' );
102
+
103
+ $ loader = new ORMQueryBuilderLoader ($ qb );
104
+ $ loader ->getEntitiesByIds ('id ' , array (1 , '' , 2 , 3 , 'foo ' ));
105
+ }
76
106
}
0 commit comments