public function testItThrowsExceptionWhenDoesNotFindTheFullPath() { $path = 'uniquePartOfId_path_to_object_0_more_calls'; $object = $this->getMock('stdClass', array('getPathToObject')); $subObject = $this->getMock('stdClass', array('getMore')); $object->expects($this->atLeastOnce())->method('getPathToObject')->will($this->returnValue(array($subObject))); $subObject->expects($this->atLeastOnce())->method('getMore')->will($this->returnValue('Value')); $this->setExpectedException('Exception', 'Could not get element id from ' . $path . ' Failing part: calls'); $this->helper->getElementAccessPath($path, $object); }
public function testGetElementAccessPath() { $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $pool = new Pool($container, 'title', 'logo.png'); $helper = new AdminHelper($pool); $object = $this->getMock('stdClass', array('getPathToObject')); $subObject = $this->getMock('stdClass', array('getAnd')); $sub2Object = $this->getMock('stdClass', array('getMore')); $object->expects($this->atLeastOnce())->method('getPathToObject')->will($this->returnValue(array($subObject))); $subObject->expects($this->atLeastOnce())->method('getAnd')->will($this->returnValue($sub2Object)); $sub2Object->expects($this->atLeastOnce())->method('getMore')->will($this->returnValue('Value')); $path = $helper->getElementAccessPath('uniquePartOfId_path_to_object_0_and_more', $object); $this->assertSame('path_to_object[0].and.more', $path); }