Skip to content

Commit 076c3af

Browse files
committed
ParamReader test also tests class annotations
1 parent 4fb790d commit 076c3af

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

Tests/Request/ParamReaderTest.php

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,48 @@ public function setup()
3131
{
3232
$annotationReader = $this->getMock('Doctrine\Common\Annotations\Reader');
3333

34-
$annotations = array();
34+
$methodAnnotations = array();
3535
$foo = new QueryParam;
3636
$foo->name = 'foo';
3737
$foo->requirements = '\d+';
3838
$foo->description = 'The foo';
39-
$annotations[] = $foo;
39+
$methodAnnotations[] = $foo;
4040

4141
$bar = new QueryParam;
4242
$bar->name = 'bar';
4343
$bar->requirements = '\d+';
4444
$bar->description = 'The bar';
45-
$annotations[] = $bar;
45+
$methodAnnotations[] = $bar;
4646

47-
$annotations[] = new NamePrefix(array());
47+
$methodAnnotations[] = new NamePrefix(array());
4848

4949
$annotationReader
5050
->expects($this->any())
5151
->method('getMethodAnnotations')
52-
->will($this->returnValue($annotations));
52+
->will($this->returnValue($methodAnnotations));
5353

54+
$classAnnotations = array();
55+
56+
$baz = new QueryParam;
57+
$baz->name = 'baz';
58+
$baz->requirements = '\d+';
59+
$baz->description = 'The baz';
60+
$classAnnotations[] = $baz;
61+
62+
$mikz = new QueryParam;
63+
$mikz->name = 'mikz';
64+
$mikz->requirements = '\d+';
65+
$mikz->description = 'The real mikz';
66+
$classAnnotations[] = $mikz;
67+
68+
$not = new NamePrefix(array());
69+
$classAnnotations[] = $not;
70+
71+
$annotationReader
72+
->expects($this->any())
73+
->method('getClassAnnotations')
74+
->will($this->returnValue($classAnnotations));
75+
5476
$this->paramReader = new ParamReader($annotationReader);
5577
}
5678

@@ -61,7 +83,7 @@ public function testReadsOnlyParamAnnotations()
6183
{
6284
$annotations = $this->paramReader->read(new \ReflectionClass(__CLASS__), 'setup');
6385

64-
$this->assertCount(2, $annotations);
86+
$this->assertCount(4, $annotations);
6587

6688
foreach ($annotations as $name => $annotation) {
6789
$this->assertThat($annotation, $this->isInstanceOf('FOS\RestBundle\Controller\Annotations\Param'));

0 commit comments

Comments
 (0)