public function testSetDefaultOptions() { /** @var OptionsResolverInterface|\PHPUnit_Framework_MockObject_MockObject $resolver */ $resolver = $this->getMock('Symfony\\Component\\OptionsResolver\\OptionsResolverInterface'); $resolver->expects($this->once())->method('setDefaults')->with($this->isType('array')); $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]])); $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0)); $this->type->setDefaultOptions($resolver); }
/** * {@inheritdoc} */ protected function setUp() { $this->routerMock = $this->getMock('Symfony\\Component\\Routing\\RouterInterface'); $this->assetsHelperMock = $this->getMockBuilder('Symfony\\Component\\Templating\\Helper\\CoreAssetsHelper')->disableOriginalConstructor()->getMock(); $this->assetsHelperMock->expects($this->any())->method('getUrl')->will($this->returnArgument(0)); $this->containerMock = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $this->containerMock->expects($this->any())->method('get')->will($this->returnValueMap(array(array('templating.helper.assets', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->assetsHelperMock), array('router', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->routerMock)))); $this->helper = new CKEditorHelper($this->containerMock); }
public function testFinishView() { $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]])); $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0)); $testIntegration1 = new Integration(); $testIntegration1->setType('testType1'); $testIntegration1Label = uniqid('label'); $testIntegration1Id = uniqid('id'); $testIntegration2 = new Integration(); $testIntegration2->setType('testType2'); $testIntegration2Label = uniqid('label'); $testIntegration2Id = uniqid('id'); $view = new FormView(); $view->vars['choices'] = [new ChoiceView($testIntegration1, $testIntegration1Id, $testIntegration1Label), new ChoiceView($testIntegration2, $testIntegration2Id, $testIntegration2Label)]; $this->type->finishView($view, $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'), []); $this->assertInstanceOf('Oro\\Bundle\\FormBundle\\Form\\Type\\ChoiceListItem', $view->vars['choices'][0]->label); $this->assertInstanceOf('Oro\\Bundle\\FormBundle\\Form\\Type\\ChoiceListItem', $view->vars['choices'][1]->label); $this->assertSame(['data-status' => true, 'data-icon' => 'bundles/acmedemo/img/logo.png'], $view->vars['choices'][0]->label->getAttr()); }
/** * @param array $files * @param array $options * @param array $expected * * @dataProvider optionsProvider */ public function testFinishView(array $files, array $options, array $expected) { $testDir = $this->getTestDir(); $this->removeTestDir($testDir); mkdir($testDir); $form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'); $view = new FormView(); $valueMap = []; foreach ($files as $fileName) { file_put_contents($testDir . DIRECTORY_SEPARATOR . $fileName, ''); if (isset($expected['files'][$fileName])) { array_push($valueMap, [$options['source']['url'] . '/' . $fileName, null, $expected['files'][$fileName]]); } } $this->assetHelper->expects($this->exactly(count($files)))->method('getUrl')->willReturnMap($valueMap); $this->type->finishView($view, $form, $options); $this->assertEquals($expected, $view->vars); $this->removeTestDir($testDir); }
public function testGetJsPath() { $this->assetsHelperMock->expects($this->once())->method('getUrl')->with($this->equalTo('foo'))->will($this->returnValue('bar')); $this->assertSame('bar', $this->helper->getJsPath('foo')); }
public function testRenderTemplate() { $this->assetsHelperMock->expects($this->once())->method('getUrl')->with($this->equalTo('foo'), $this->equalTo(null))->will($this->returnValue('bar')); $this->assetsVersionTrimerHelperMock->expects($this->once())->method('trim')->with($this->equalTo('bar'))->will($this->returnValue('baz')); $this->assertSame('CKEDITOR.addTemplates("foo", {"imagesPath":"baz","filename":"bat"});', $this->helper->renderTemplate('foo', array('imagesPath' => 'foo', 'filename' => 'bat'))); }
/** * @dataProvider pathProvider */ public function testRenderTemplate($path, $asset, $url) { $this->assetsHelperMock->expects($this->once())->method('getUrl')->with($this->equalTo($path))->will($this->returnValue($asset)); $this->assertSame('CKEDITOR.addTemplates("foo", {"imagesPath":' . json_encode($url) . ',"filename":"bat"});', $this->helper->renderTemplate('foo', array('imagesPath' => $path, 'filename' => 'bat'))); }