public function testResolveCollision() { $namer = $this->getMockBuilder('Iphp\\FileStoreBundle\\Naming\\DefaultNamer')->disableOriginalConstructor()->getMock(); $this->container->expects($this->once())->method('get')->with('test.service')->will($this->returnValue($namer)); $namer->expects($this->once())->method('resolveCollision')->with('sample-file-name', 1)->will($this->returnValue('sample-file-name_1')); $this->assertSame($this->invoker->resolveCollision('test.service', 'sample-file-name', 1), 'sample-file-name_1'); }
/** * @param $fileName * @param $clientOriginalName * @param int $attempt * @return string new file path * @throws \Exception */ public function resolveFileCollision($fileName, $clientOriginalName, $attempt = 1) { if ($this->hasNamer()) { $firstNamer = current($this->config['namer']); return $this->namerServiceInvoker->resolveCollision($firstNamer['service'], $fileName, $attempt); } throw new \Exception('Filename resolving collision not supported (namer is empty).Duplicate filename ' . $fileName); }