You are here

class ClassUtilsTest in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/ClassUtilsTest.php \Doctrine\Tests\Common\Util\ClassUtilsTest

Hierarchy

  • class \Doctrine\Tests\Common\Util\ClassUtilsTest extends \Doctrine\Tests\DoctrineTestCase

Expanded class hierarchy of ClassUtilsTest

File

vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/ClassUtilsTest.php, line 8

Namespace

Doctrine\Tests\Common\Util
View source
class ClassUtilsTest extends DoctrineTestCase {
  public static function dataGetClass() {
    return array(
      array(
        'stdClass',
        'stdClass',
      ),
      array(
        'Doctrine\\Common\\Util\\ClassUtils',
        'Doctrine\\Common\\Util\\ClassUtils',
      ),
      array(
        'MyProject\\Proxies\\__CG__\\stdClass',
        'stdClass',
      ),
      array(
        'MyProject\\Proxies\\__CG__\\OtherProject\\Proxies\\__CG__\\stdClass',
        'stdClass',
      ),
      array(
        'MyProject\\Proxies\\__CG__\\Doctrine\\Tests\\Common\\Util\\ChildObject',
        'Doctrine\\Tests\\Common\\Util\\ChildObject',
      ),
    );
  }

  /**
   * @dataProvider dataGetClass
   */
  public function testGetRealClass($className, $expectedClassName) {
    $this
      ->assertEquals($expectedClassName, ClassUtils::getRealClass($className));
  }

  /**
   * @dataProvider dataGetClass
   */
  public function testGetClass($className, $expectedClassName) {
    $object = new $className();
    $this
      ->assertEquals($expectedClassName, ClassUtils::getClass($object));
  }
  public function testGetParentClass() {
    $parentClass = ClassUtils::getParentClass('MyProject\\Proxies\\__CG__\\OtherProject\\Proxies\\__CG__\\Doctrine\\Tests\\Common\\Util\\ChildObject');
    $this
      ->assertEquals('stdClass', $parentClass);
  }
  public function testGenerateProxyClassName() {
    $this
      ->assertEquals('Proxies\\__CG__\\stdClass', ClassUtils::generateProxyClassName('stdClass', 'Proxies'));
  }

  /**
   * @dataProvider dataGetClass
   */
  public function testNewReflectionClass($className, $expectedClassName) {
    $reflClass = ClassUtils::newReflectionClass($className);
    $this
      ->assertEquals($expectedClassName, $reflClass
      ->getName());
  }

  /**
   * @dataProvider dataGetClass
   */
  public function testNewReflectionObject($className, $expectedClassName) {
    $object = new $className();
    $reflClass = ClassUtils::newReflectionObject($object);
    $this
      ->assertEquals($expectedClassName, $reflClass
      ->getName());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ClassUtilsTest::dataGetClass public static function
ClassUtilsTest::testGenerateProxyClassName public function
ClassUtilsTest::testGetClass public function @dataProvider dataGetClass
ClassUtilsTest::testGetParentClass public function
ClassUtilsTest::testGetRealClass public function @dataProvider dataGetClass
ClassUtilsTest::testNewReflectionClass public function @dataProvider dataGetClass
ClassUtilsTest::testNewReflectionObject public function @dataProvider dataGetClass