public function testRename() { $propertyMapping = Mocks::getPropertyMappingMock($this); $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('translitRename')->with($propertyMapping, 'sample file name', array('param' => 1))->will($this->returnValue('sample-file-name')); $this->assertSame($this->invoker->rename('test.service', 'translit', $propertyMapping, 'sample file name', array('param' => 1)), 'sample-file-name'); }
/** * create subdirectory name based on chain of directory namers * * @return array directory name and web path to file */ public function useDirectoryNamer($fileName, $clientOriginalName) { $path = ''; if ($this->hasDirectoryNamer()) { foreach ($this->config['directory_namer'] as $method => $namer) { $replaceMode = $method == 'replace' || isset($namer['params']['replace']) && $namer['params']['replace']; $subPath = $this->namerServiceInvoker->rename($namer['service'], $method, $this, $replaceMode ? $path : $fileName, isset($namer['params']) ? $namer['params'] : array()); /* $subPath = call_user_func( array($this->container->get($namer['service']), $method . 'Rename'), $this, $replaceMode ? $path : $fileName, isset($namer['params']) ? $namer['params'] : array());*/ if ($replaceMode) { $path = $subPath; } else { $path .= ($subPath ? '/' : '') . $subPath; } } } return $path; }