@Test public void testRename1() throws Exception { Program program = createProgram(file); assertNotNull(program); int start = 102; ASTNode selectedNode = locateNode(program, start, 0); assertNotNull(selectedNode); RenameClassMemberProcessor processor = new RenameClassMemberProcessor(file, selectedNode); processor.setNewElementName("title1"); checkInitCondition(processor); performChange(processor); try { String content = FileUtils.getContents(file); assertEquals( "<?php class Item { public $title1;} class ItemEx extends Item{public $title1;} $a=new ItemEx(); $a->title1;?>", content); } catch (IOException e) { e.printStackTrace(); } }
@Test public void testRename() throws Exception { Program program = createProgram(file); assertNotNull(program); int start = 117; ASTNode selectedNode = locateNode(program, start, 0); assertNotNull(selectedNode); RenameClassProcessor processor = new RenameClassProcessor(file, selectedNode); processor.setNewElementName("MyClassNewName"); processor.setUpdateTextualMatches(true); checkInitCondition(processor); performChange(processor); try { String content = FileUtils.getContents(file); assertEquals( "<?php class MyClassNewName{const constant = 'constant value';function showCons1tant() {echo self::constant;}}$class = new MyClassNewName ();$class->showConstant ();echo $class::constant;?>", content); } catch (IOException e) { e.printStackTrace(); } }
@Test public void test(String fileName) { PdttFileExt testFile = filesMap.get(fileName); IFile file = project.findFile(testFile.getTestFiles().get(0).getName()); IStructuredModel model = null; try { model = createUnManagedStructuredModelFor(file); } catch (IOException e) { fail(e.getMessage()); } catch (CoreException e) { fail(e.getMessage()); } assertNotNull(model); IStructuredDocument structuredDocument = model.getStructuredDocument(); assertNotNull(structuredDocument); int start = Integer.valueOf(testFile.getConfig().get("start")); int length = Integer.valueOf(testFile.getConfig().get("length")); String visibility = testFile.getConfig().get("visibility"); ExtractFunctionRefactoring processor = new ExtractFunctionRefactoring( DLTKCore.createSourceModuleFrom(file), structuredDocument, start, length); if ("default".equals(visibility)) { processor.setVisibility(Modifiers.AccDefault); } if ("public".equals(visibility)) { processor.setVisibility(Modifiers.AccPublic); } if ("prvate".equals(visibility)) { processor.setVisibility(Modifiers.AccPrivate); } if ("protected".equals(visibility)) { processor.setVisibility(Modifiers.AccProtected); } processor.setNewFunctionName(testFile.getConfig().get("newName")); checkInitCondition(processor); performChange(processor); checkTestResult(testFile, structuredDocument); }