/** * Tests the servlets init() method. * * @return void */ public function testInit() { // create a servlet config mock instance $mockServletConfig = $this->getMockBuilder($servletConfigInterface = 'AppserverIo\\Psr\\Servlet\\ServletConfigInterface')->setMethods(get_class_methods($servletConfigInterface))->getMock(); // mock the necessary method $mockServletConfig->expects($this->once())->method('getWebappPath')->will($this->returnValue($webappPath = '/opt/appserver/webapps/test')); // create and initialize a servlet instance $servlet = new DhtmlServlet(); $servlet->init($mockServletConfig); // check that the servlet has been initilized successfully $this->assertSame($webappPath, $servlet->getWebappPath()); $this->assertSame(get_class($servlet), $servlet->getPoweredBy()); }