Example #1
0
 /** @depends testCacheInit */
 function testCacheContent()
 {
     $obj = new ReflectionClass(__CLASS__);
     $arr = $obj->getAnnotations();
     $this->assertEquals(1, \Notoj\Cache::save());
     $this->assertEquals(0, \Notoj\Cache::save());
     $content = file_get_contents(CACHE);
     $this->assertTrue(strpos($content, sha1($obj->getDocComment())) !== FALSE);
 }
Example #2
0
 /**
  *  @dataProvider fileProvider
  */
 public function ztestNotojFile($file)
 {
     $obj = new \Notoj\File($file);
     foreach ($obj->getAnnotations() as $annotations) {
         $this->AssertEquals(realpath($file), $annotations->GetFile());
         if ($annotations->isMethod()) {
             $this->assertTrue($annotations instanceof \Notoj\tMethod);
             $this->assertTrue($annotations->isPublic());
             if (!preg_match('/Parser.php/', $file)) {
                 $this->assertEquals($annotations->isStatic(), in_array($annotations->getName(), array('tokenName', 'getInstance')), $annotations->GetName() . ' on ' . $file);
             }
             $refl = new ReflectionMethod($annotations['class'], $annotations['function']);
             $meta = $refl->getAnnotations()->getMetadata();
             $this->assertTrue(is_array($meta['params']));
             foreach ($meta['params'] as $param) {
                 $this->assertEquals('$', $param[0]);
             }
         } else {
             if ($annotations->isProperty()) {
                 $this->assertTrue($annotations instanceof \Notoj\tProperty);
                 $refl = new ReflectionProperty($annotations['class'], $annotations['property']);
                 $this->assertTrue(is_array($annotations['visibility']));
                 $this->assertTrue(count($annotations['visibility']) >= 1);
             } else {
                 if ($annotations->isFunction()) {
                     $this->assertTrue($annotations instanceof \Notoj\tFunction);
                     $refl = new ReflectionFunction($annotations['function']);
                     $meta = $refl->getAnnotations()->getMetadata();
                     $this->assertTrue(is_array($meta['params']));
                     foreach ($meta['params'] as $param) {
                         $this->assertEquals('$', $param[0]);
                     }
                 } elseif ($annotations->isClass()) {
                     $this->assertTrue($annotations instanceof \Notoj\tClass);
                     $this->assertFalse($annotations->isAbstract());
                     $this->assertFalse($annotations->isFinal());
                     $refl = new ReflectionClass($annotations['class']);
                 }
             }
         }
         $this->assertEquals((array) $refl->getAnnotations(), (array) $annotations['annotations']);
     }
 }
 /**
  * @return array|\Notoj\Annotation\Annotations
  */
 public function getAnnotations()
 {
     return $this->reflectionClass->getAnnotations();
 }