public function test_moveFile_usingAppendNumberOptionAppendsNumberToFilenameIfItAlreadyExistsRelativePath() { $currDir = __DIR__; chdir(realpath(__DIR__ . '/../../temp/uploadable')); $file = new FileAppendNumber(); $file2 = new FileAppendNumberRelative(); $file->setTitle('test'); $file2->setTitle('test2'); $fileInfo = $this->generateUploadedFile('image', realpath(__DIR__ . '/../../../tests/data/test'), 'test'); $this->listener->addEntityFileInfo($file, $fileInfo); $this->em->persist($file); $this->em->flush(); $this->listener->addEntityFileInfo($file2, $fileInfo); $this->em->persist($file2); $this->em->flush(); $this->em->refresh($file2); $this->assertEquals('./test-2', $file2->getFilePath()); chdir($currDir); }
public function test_moveFile_usingAppendNumberOptionAppendsNumberToFilenameIfItAlreadyExists() { $file = new FileAppendNumber(); $file2 = new FileAppendNumber(); $file->setTitle('test'); $file2->setTitle('test2'); $fileInfo = $this->generateUploadedFile(); $this->listener->addEntityFileInfo($file, $fileInfo); $this->em->persist($file); $this->em->flush(); $this->listener->addEntityFileInfo($file2, $fileInfo); $this->em->persist($file2); $this->em->flush(); $this->em->refresh($file2); $filename = substr($file2->getFilePath(), strrpos($this->fixWindowsPath($file2->getFilePath()), '/') + 1); $this->assertEquals('test-2.txt', $filename); }