Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fdc34e
commit f6bcf99
Showing
4 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
use recess\lang\ReflectionClass; | ||
use recess\lang\ReflectionProperty; | ||
use recess\lang\Object; | ||
|
||
require_once __DIR__ . '/DummyAnnotation.class.php'; | ||
use made\up\space\DummyAnnotation; | ||
|
||
class ReflectionClassTest extends PHPUnit_Framework_TestCase { | ||
|
||
function testGetAnnotations() { | ||
DummyAnnotation::load(); | ||
$klass = new ReflectionClass('ReflectionClassObject'); | ||
$annotations = $klass->getAnnotations(); | ||
$this->assertEquals(1, count($annotations)); | ||
$this->assertEquals(array(new DummyAnnotation), $annotations); | ||
} | ||
|
||
function testGetProperties() { | ||
DummyAnnotation::load(); | ||
$childClass = new ReflectionClass('ReflectionClassObject'); | ||
$parentClass = new ReflectionClass('recess\lang\Object'); | ||
$this->assertEquals(1, count($childClass->getProperties())-count($parentClass->getProperties())); | ||
} | ||
|
||
function testGetMethods() { | ||
DummyAnnotation::load(); | ||
$childClass = new ReflectionClass('ReflectionClassObject'); | ||
$parentClass = new ReflectionClass('recess\lang\Object'); | ||
$this->assertEquals(1, count($childClass->getMethods())-count($parentClass->getMethods())); | ||
} | ||
|
||
function testGetAttachedMethods() { | ||
DummyAnnotation::load(); | ||
ReflectionClassObject::attachMethod('aMethod',function($self){return true;}); | ||
$childClass = new ReflectionClass('ReflectionClassObject'); | ||
$parentClass = new ReflectionClass('recess\lang\Object'); | ||
$this->assertEquals(2, count($childClass->getMethods())-count($parentClass->getMethods())); | ||
} | ||
|
||
} | ||
|
||
/** !Dummy */ | ||
class ReflectionClassObject extends Object { | ||
/** !Dummy */ | ||
function fooMethod() {} | ||
|
||
/** !Dummy */ | ||
public $fooProperty; | ||
} |