Exemplo n.º 1
0
 /**
  * @test
  */
 public function does_execute_rename_file_when_configured()
 {
     $manager = $this->getMock(ManagerInterface::class);
     $strategy = $this->getMock(Strategy::class);
     $strategy->expects($this->once())->method('getConfiguration')->will($this->returnValue(['after' => ['rename' => true]]));
     $import = $this->getMock(Import::class);
     $import->expects($this->once())->method('getStrategy')->will($this->returnValue($strategy));
     $file = vfsStream::newFile('import.csv')->at($this->root)->setContent("test;test");
     $oldFileName = $file->getName();
     $this->fileService->expects($this->any())->method('getFileAbsFileName')->will($this->returnCallback(function () use($file) {
         return $file->url();
     }));
     $this->fixture->execute($manager, $import);
     $children = $this->root->getChildren();
     $this->assertEquals(1, sizeof($children));
     $this->assertRegExp('/^[0-9]{14}_' . $oldFileName . '$/', $children[0]->getName());
 }