Skip to content
This repository
Browse code

Merge pull request #123 from FabioBatSilva/DCOM-97

Coverage for DCOM-97
  • Loading branch information...
commit 7ec510dbb2279f76a00ecf3f911298879c6ba1a1 2 parents d62352c + 49a997c
Guilherme Blanco authored March 25, 2012
52  tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithClosure.php
... ...
@@ -0,0 +1,52 @@
  1
+<?php
  2
+
  3
+namespace Doctrine\Tests\Common\Annotations\Fixtures;
  4
+
  5
+use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
  6
+use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
  7
+
  8
+/**
  9
+ * @AnnotationTargetAll("Foo")
  10
+ */
  11
+final class ClassWithClosure
  12
+{
  13
+
  14
+    /**
  15
+     * @AnnotationTargetAll(@AnnotationTargetAnnotation)
  16
+     * @var string
  17
+     */
  18
+    public $value;
  19
+
  20
+    /**
  21
+     * @AnnotationTargetAll(@AnnotationTargetAnnotation)
  22
+     *
  23
+     * @param   \Closure $callback
  24
+     * @return  \Closure
  25
+     */
  26
+    public function methodName(\Closure $callback)
  27
+    {
  28
+        $self = $this;
  29
+        return function() use ($self, $callback) {
  30
+            return $callback;
  31
+        };
  32
+    }
  33
+
  34
+    /**
  35
+     * @param   integer $year
  36
+     * @param   integer $month
  37
+     * @param   integer $day
  38
+     * @return  \Doctrine\Common\Collections\ArrayCollection
  39
+     */
  40
+    public function getEventsForDate($year, $month, $day){
  41
+        $extractEvents  = null; // check if date of item is inside day given
  42
+        $extractEvents  = $this->events->filter(function ($item) use ($year, $month, $day) {
  43
+            $leftDate   = new \DateTime($year.'-'.$month.'-'.$day.' 00:00');
  44
+            $rigthDate  = new \DateTime($year.'-'.$month.'-'.$day.' +1 day 00:00');
  45
+            return ( ( $leftDate <= $item->getDateStart() ) && ( $item->getDateStart() < $rigthDate ) );
  46
+
  47
+            }
  48
+        );
  49
+        return $extractEvents;
  50
+    }
  51
+
  52
+}
15  tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php
@@ -176,4 +176,19 @@ public function testIfPointerResetsOnMultipleParsingTries()
176 176
             'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
177 177
         ), $parser->parseClass($class));
178 178
     }
  179
+
  180
+    /**
  181
+     * @group DCOM-97
  182
+     * @group regression
  183
+     */
  184
+    public function testClassWithClosure()
  185
+    {
  186
+        $parser = new PhpParser();
  187
+        $class  = new ReflectionClass(__NAMESPACE__ . '\Fixtures\ClassWithClosure');
  188
+
  189
+        $this->assertEquals(array(
  190
+          'annotationtargetall'         => __NAMESPACE__ . '\Fixtures\AnnotationTargetAll',
  191
+          'annotationtargetannotation'  => __NAMESPACE__ . '\Fixtures\AnnotationTargetAnnotation',
  192
+        ), $parser->parseClass($class));
  193
+    }
179 194
 }

0 notes on commit 7ec510d

Please sign in to comment.
Something went wrong with that request. Please try again.