public function testMultipleFilesAdded() { $output = "A\tnewFile\nA\tanotherNewFile\nA\tyetAnotherNewFile"; $repository = m::mock('GitWrapper\\GitWorkingCopy'); $repository->shouldReceive('diff')->once(); $repository->shouldReceive('getDirectory')->once()->andReturn(''); $repository->shouldReceive('run')->once()->andReturn($repository); $repository->shouldReceive('getOutput')->once()->andReturn($output); $diff = new Diff($repository, 'someHash'); $expectedFilesToUpload = array('newFile', 'anotherNewFile', 'yetAnotherNewFile'); $expectedFilesToDelete = array(); $this->assertEquals($expectedFilesToUpload, $diff->getFilesToUpload()); $this->assertEquals($expectedFilesToDelete, $diff->getFilesToDelete()); }
private function deployCurrentCommit() { $application = $this->getApplication(); $history = $application->getHistory(); $diff = new Diff($application->getRepository(), $history->getLastHash()); $filesToUpload = $diff->getFilesToUpload(); $filesToDelete = $diff->getFilesToDelete(); foreach ($this->finder as $file) { if (in_array($file->getRelativePathname(), $filesToUpload)) { $this->uploadFile($file); } } foreach ($filesToDelete as $fileName) { $this->deleteFile($fileName); } }