3
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
* This software consists of voluntary contributions made by many individuals
16
* and is licensed under the MIT license. For more information, see
17
* <http://www.doctrine-project.org>.
20
namespace Doctrine\Tests\Common\Persistence\Mapping;
22
use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService;
27
class RuntimeReflectionServiceTest extends \PHPUnit_Framework_TestCase
30
* @var RuntimeReflectionService
32
private $reflectionService;
34
public $unusedPublicProperty;
36
public function setUp()
38
$this->reflectionService = new RuntimeReflectionService();
41
public function testShortname()
43
$this->assertEquals("RuntimeReflectionServiceTest", $this->reflectionService->getClassShortName(__CLASS__));
46
public function testClassNamespaceName()
48
$this->assertEquals("Doctrine\Tests\Common\Persistence\Mapping", $this->reflectionService->getClassNamespace(__CLASS__));
51
public function testGetParentClasses()
53
$classes = $this->reflectionService->getParentClasses(__CLASS__);
54
$this->assertTrue(count($classes) >= 1, "The test class ".__CLASS__." should have at least one parent.");
57
public function testGetParentClassesForAbsentClass()
59
$this->setExpectedException('Doctrine\Common\Persistence\Mapping\MappingException');
60
$this->reflectionService->getParentClasses(__NAMESPACE__ . '\AbsentClass');
63
public function testGetReflectionClass()
65
$class = $this->reflectionService->getClass(__CLASS__);
66
$this->assertInstanceOf("ReflectionClass", $class);
69
public function testGetMethods()
71
$this->assertTrue($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods"));
72
$this->assertFalse($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods2"));
75
public function testGetAccessibleProperty()
77
$reflProp = $this->reflectionService->getAccessibleProperty(__CLASS__, "reflectionService");
78
$this->assertInstanceOf("ReflectionProperty", $reflProp);
80
$reflProp = $this->reflectionService->getAccessibleProperty(__CLASS__, "unusedPublicProperty");
81
$this->assertInstanceOf("Doctrine\Common\Reflection\RuntimePublicReflectionProperty", $reflProp);