id = $id; $this->testData = $testData; $this->setup = $setup; } public function setUp() { $this->oldLibxmlErrorSetting = libxml_use_internal_errors( true ); $this->setup->performSetup( $this, $this->id ); $this->tmpDir = $this->createTempDir( get_class( $this ) ); // Store current timezone and switch to UTC for test $this->oldTimezoneSetting = date_default_timezone_get(); date_default_timezone_set( 'UTC' ); $this->backend->options->lockFile = $this->tmpDir . '/backend.lock'; } protected function tearDown() { libxml_use_internal_errors( $this->oldLibxmlErrorSetting ); $this->removeTempDir(); // Reset old timezone date_default_timezone_set( $this->oldTimezoneSetting ); } public function runTest() { $this->setup->adjustRequest( $this->testData['request'] ); $response = $this->performTestSetRun( $this->testData['request'] ); $this->setup->adjustResponse( $response, $this->testData['response'] ); $this->assertRunCorrect( $this->testData['response'], $response ); } protected function assertRunCorrect( array $expectedResponse, array $actualResponse ) { $this->assertEquals( $expectedResponse, $actualResponse, 'Response sent by WebDAV server incorrect.' ); $this->setup->assertCustomAssertions( $this ); } /** * storeBackend * * @TODO Revise! * @return void */ protected function storeBackend() { /* // Store backend after test execution, if desired if ( self::STORE_BACKEND ) { $backendDir = self::$backendDir . '/' . get_class( $this ); if ( !is_dir( $backendDir ) ) { mkdir( $backendDir ); } file_put_contents( $backendDir . '/' . basename( $testSetName ) . '.ser', serialize( $this->backend ) ); } */ } protected function performTestSetRun( array $request ) { ezcWebdavTestTransportInjector::reset(); ezcWebdavTestTransportInjector::$requestBody = $request['body']; $_SERVER = $request['server']; // ini_set( 'xdebug.collect_return', 1 ); // xdebug_start_trace( './traces/' . basename( $testSetName ) ); $this->server->handle( $this->backend ); // xdebug_stop_trace(); $response['status'] = ezcWebdavTestTransportInjector::$responseStatus; $response['headers'] = ezcWebdavTestTransportInjector::$responseHeaders; $response['body'] = ezcWebdavTestTransportInjector::$responseBody; return $response; } } ?>