public function testGenerateLinkDisabledEditAndShow() { $component = new Component(); $component->setModel('Acme\\DemoBundle\\Model\\Demo'); $component->setIdentifier('2'); $action = new Action(); $this->admin->expects($this->at(0))->method('hasRoute')->with($this->equalTo('edit'))->will($this->returnValue(false)); $this->admin->expects($this->at(1))->method('hasRoute')->with($this->equalTo('show'))->will($this->returnValue(false)); $this->admin->expects($this->once())->method('toString')->with($this->anything())->will($this->returnValue('Text')); $this->assertEquals('Text', $this->twigExtension->generateLink($component, $action)); }
function testMoveWithAdmin() { $movedPath = '/cms/to-move'; $targetPath = '/cms/target/moved'; $urlSafeId = 'urlSafeId'; $admin = $this->getMockBuilder('Sonata\\DoctrinePHPCRAdminBundle\\Admin\\Admin')->disableOriginalConstructor()->getMock(); $admin->expects($this->once())->method('getNormalizedIdentifier')->will($this->returnValue($targetPath)); $admin->expects($this->once())->method('getUrlsafeIdentifier')->will($this->returnValue($urlSafeId)); $this->pool->expects($this->once())->method('getAdminByClass')->will($this->returnValue($admin)); $tree = new PhpcrOdmTree($this->dm, $this->defaultModelManager, $this->pool, $this->translator, $this->assetHelper, array(), array('depth' => 1, 'precise_children' => true)); $this->assertEquals(array('id' => $targetPath, 'url_safe_id' => $urlSafeId), $tree->move($movedPath, $targetPath)); }
/** * @param array $adminGroupsOnTopOption * * @dataProvider getAdminGroupsWithOnTopOption */ public function testGetMenuProviderOnTopOptions(array $adminGroupsOnTopOption) { $this->pool->expects($this->once())->method('getInstance')->with($this->equalTo('sonata_admin_foo_service'))->will($this->returnValue($this->getAdminMock(true, false))); $menu = $this->provider->get('providerFoo', array('name' => 'foo', 'group' => $adminGroupsOnTopOption)); $this->assertInstanceOf('Knp\\Menu\\ItemInterface', $menu); $this->assertCount(0, $menu->getChildren()); }