public function testRenameLocalVariable() { $buffer = \Phake::mock('QafooLabs\\Refactoring\\Domain\\Model\\EditorBuffer'); \Phake::when($this->scanner)->scanForVariables(\Phake::anyParameters())->thenReturn(new DefinedVariables(array('helloWorld' => array(6)))); \Phake::when($this->editor)->openBuffer(\Phake::anyParameters())->thenReturn($buffer); \Phake::when($this->codeAnalysis)->findMethodRange(\Phake::anyParameters())->thenReturn(LineRange::fromSingleLine(1)); $patch = $this->refactoring->refactor(new File("foo.php", <<<'PHP' <?php class Foo { public function main() { $helloWorld = 'bar'; } } PHP ), 6, new Variable('$helloWorld'), new Variable('$var')); \Phake::verify($buffer)->replaceString(6, '$helloWorld', '$var'); }
protected function getDefinedVariables() { $selectedMethodLineRange = $this->codeAnalysis->findMethodRange($this->file, LineRange::fromSingleLine($this->line)); $definedVariables = $this->variableScanner->scanForVariables($this->file, $selectedMethodLineRange); return $definedVariables; }