示例#1
0
 public function testGetAnnotations()
 {
     $doc = new DocBlock(self::$sample);
     $this->assertInternalType('array', $doc->getAnnotations());
     $this->assertCount(5, $doc->getAnnotations());
     foreach ($doc->getAnnotations() as $index => $annotations) {
         $this->assertInstanceOf('Symfony\\CS\\DocBlock\\Annotation', $annotations);
         $this->assertSame($doc->getAnnotation($index), $annotations);
     }
     $this->assertEmpty($doc->getAnnotation(5));
 }
 /**
  * Make sure the annotations are correctly separated.
  *
  * @param DocBlock $doc
  *
  * @return string
  */
 private function fixAnnotations(DocBlock $doc)
 {
     foreach ($doc->getAnnotations() as $index => $annotation) {
         $next = $doc->getAnnotation($index + 1);
         if (null === $next) {
             break;
         }
         if (true === $next->getTag()->valid()) {
             if (TagComparator::shouldBeTogether($annotation->getTag(), $next->getTag())) {
                 $this->ensureAreTogether($doc, $annotation, $next);
             } else {
                 $this->ensureAreSeparate($doc, $annotation, $next);
             }
         }
     }
     return $doc->getContent();
 }
 /**
  * @dataProvider provideRemoveCases
  */
 public function testRemove($index, $start, $end)
 {
     $doc = new DocBlock(self::$sample);
     $annotation = $doc->getAnnotation($index);
     $annotation->remove();
     $this->assertSame('', $annotation->getContent());
     $this->assertSame('', $doc->getLine($start)->getContent());
     $this->assertSame('', $doc->getLine($end)->getContent());
 }