public function testReplaceALine() { $mockTextFile = m::mock(TextFile::class); $mockTextFile->shouldReceive("extractAgainAllLinesIntoArray")->once(); $mockTextFile->shouldReceive("getLine")->with(0)->once()->andReturn("hasan gilak"); $mockTextFile->shouldReceive("getAllLines")->once()->andReturn(["hasan gilak"]); $mockTextFile->shouldReceive("write")->with("elyas gilak")->once(); $this->textChains->setFile($mockTextFile); $this->textChains->replaceALine(0, "elyas gilak"); }
/** * @param $fileAddress * @return TextChains */ public function text($fileAddress) { $text = $this->text->setFile(new TextFile($fileAddress)); $text->getFile()->isSafeForOperations(); return $text; }