Ejemplo n.º 1
0
 /**
  * Class annotations test.
  * @return void
  */
 public function testClassAnnotations()
 {
     $rc = new ReflectionClass('TestClass');
     $tmp = Annotations::getAll($rc);
     $this->assertEquals("Johno's addendum", $tmp["title"][0]->value);
     $this->assertTrue($tmp["title"][0]->mode);
     $this->assertEquals("One, Two", $tmp["title"][1]->value);
     $this->assertEquals("true or false", $tmp["title"][1]->mode);
     $this->assertEquals("Three (Four)", $tmp["title"][2]->value);
     $this->assertEquals("false", $tmp["title"][2]->mode);
     $this->assertEquals("item 1", $tmp["components"][0]);
     $this->assertTrue($tmp["persistent"][0]);
     $this->assertFalse($tmp["persistent"][1]);
     $this->assertNull($tmp["persistent"][2]);
     $this->assertTrue($tmp["renderable"][0]);
     $this->assertSame($tmp, Annotations::getAll($rc), 'cache test');
     $this->assertNotSame($tmp, Annotations::getAll(new ReflectionClass('ReflectionClass')), 'cache test');
     $this->assertTrue(Annotations::has($rc, 'title'), "has('title')");
     $this->assertEquals("Three (Four)", Annotations::get($rc, 'title')->value);
     $this->assertEquals("false", Annotations::get($rc, 'title')->mode);
     $tmp = Annotations::getAll($rc, 'title');
     $this->assertEquals("Johno's addendum", $tmp[0]->value);
     $this->assertTrue($tmp[0]->mode);
     $this->assertEquals("One, Two", $tmp[1]->value);
     $this->assertEquals("true or false", $tmp[1]->mode);
     $this->assertEquals("Three (Four)", $tmp[2]->value);
     $this->assertEquals("false", $tmp[2]->mode);
     $this->assertTrue(Annotations::has($rc, 'renderable'), "has('renderable')");
     $this->assertTrue(Annotations::get($rc, 'renderable'), "get('renderable')");
     $tmp = Annotations::getAll($rc, 'renderable');
     $this->assertTrue($tmp[0]);
     $tmp = Annotations::getAll($rc, 'persistent');
     $this->assertNull(Annotations::get($rc, 'persistent'), "get('persistent')");
     $this->assertTrue($tmp[0]);
     $this->assertFalse($tmp[1]);
     $this->assertNull($tmp[2]);
     $this->assertFalse(Annotations::has($rc, 'xxx'), "has('xxx')");
     $this->assertNull(Annotations::get($rc, 'xxx'), "get('xxx')");
 }