Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / common / tests / Doctrine / Tests / Common / Util / ClassUtilsTest.php
1 <?php
2
3 namespace Doctrine\Tests\Common\Util
4 {
5     use Doctrine\Tests\DoctrineTestCase;
6     use Doctrine\Common\Util\ClassUtils;
7
8     class ClassUtilsTest extends DoctrineTestCase
9     {
10         static public function dataGetClass()
11         {
12             return array(
13                 array('stdClass', 'stdClass'),
14                 array('Doctrine\Common\Util\ClassUtils', 'Doctrine\Common\Util\ClassUtils'),
15                 array( 'MyProject\Proxies\__CG__\stdClass', 'stdClass' ),
16                 array( 'MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__\stdClass', 'stdClass' ),
17                 array( 'MyProject\Proxies\__CG__\Doctrine\Tests\Common\Util\ChildObject','Doctrine\Tests\Common\Util\ChildObject' )
18             );
19         }
20
21         /**
22          * @dataProvider dataGetClass
23          */
24         public function testGetRealClass($className, $expectedClassName)
25         {
26             $this->assertEquals($expectedClassName, ClassUtils::getRealClass($className));
27         }
28
29         /**
30          * @dataProvider dataGetClass
31          */
32         public function testGetClass( $className, $expectedClassName )
33         {
34             $object = new $className();
35             $this->assertEquals($expectedClassName, ClassUtils::getClass($object));
36         }
37
38         public function testGetParentClass()
39         {
40             $parentClass = ClassUtils::getParentClass( 'MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__\Doctrine\Tests\Common\Util\ChildObject' );
41             $this->assertEquals('stdClass', $parentClass);
42         }
43
44         public function testGenerateProxyClassName()
45         {
46             $this->assertEquals( 'Proxies\__CG__\stdClass', ClassUtils::generateProxyClassName( 'stdClass', 'Proxies' ) );
47         }
48
49         /**
50          * @dataProvider dataGetClass
51          */
52         public function testNewReflectionClass( $className, $expectedClassName )
53         {
54             $reflClass = ClassUtils::newReflectionClass( $className );
55             $this->assertEquals( $expectedClassName, $reflClass->getName() );
56         }
57
58         /**
59          * @dataProvider dataGetClass
60          */
61         public function testNewReflectionObject( $className, $expectedClassName )
62         {
63             $object = new $className;
64             $reflClass = ClassUtils::newReflectionObject( $object );
65             $this->assertEquals( $expectedClassName, $reflClass->getName() );
66         }
67     }
68
69     class ChildObject extends \stdClass
70     {
71     }
72 }
73
74 namespace MyProject\Proxies\__CG__
75 {
76     class stdClass extends \stdClass
77     {
78     }
79 }
80
81 namespace MyProject\Proxies\__CG__\Doctrine\Tests\Common\Util
82 {
83     class ChildObject extends \Doctrine\Tests\Common\Util\ChildObject
84     {
85     }
86 }
87
88 namespace MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__
89 {
90     class stdClass extends \MyProject\Proxies\__CG__\stdClass
91     {
92     }
93 }
94
95 namespace MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__\Doctrine\Tests\Common\Util
96 {
97     class ChildObject extends \MyProject\Proxies\__CG__\Doctrine\Tests\Common\Util\ChildObject
98     {
99     }
100 }