コード例 #1
0
 /**
  * Tests that initialization from a reflection class that reflects and abstract
  * Servlet interface won't work.
  *
  * @return void
  */
 public function testFromReflectionClassIsInterface()
 {
     // create a servlet instance
     $servlet = $this->getMockBuilder('AppserverIo\\Psr\\Servlet\\ServletInterface')->setMethods(get_class_methods('AppserverIo\\Psr\\Servlet\\ServletInterface'))->getMock();
     // create a PHP \ReflectionClass instance
     $phpReflectionClass = $this->getMockBuilder('\\ReflectionClass')->setMethods(array('isAbstract', 'isInterface'))->disableOriginalConstructor()->getMock();
     // mock the methods
     $phpReflectionClass->expects($this->once())->method('isInterface')->will($this->returnValue(true));
     // create a ReflectionClass instance
     $reflectionClass = $this->getMockBuilder('AppserverIo\\Lang\\Reflection\\ReflectionClass')->setMethods(array('toPhpReflectionClass', 'implementsInterface'))->setConstructorArgs(array($servlet, array(), array()))->getMock();
     // mock the methods
     $reflectionClass->expects($this->any())->method('toPhpReflectionClass')->will($this->returnValue($phpReflectionClass));
     $reflectionClass->expects($this->once())->method('implementsInterface')->will($this->returnValue(true));
     // check that the descriptor has not been initialized
     $this->assertNull($this->descriptor->fromReflectionClass($reflectionClass));
 }