renderAddress() public method

Gets the HTML of an address.
public renderAddress ( Twig_Environment $environment, mixed $address, boolean $showName = true, boolean $showEdit = false, string $context = null ) : string
$environment Twig_Environment A Twig environment
$address mixed An instance of AddressInterface or array with keys: (id, firstname, lastname, address1, postcode, city, country_code and optionally name, address2, address3)
$showName boolean Display address name?
$showEdit boolean Display edit button?
$context string A context for edit link
return string
 /**
  * @expectedException Sonata\CoreBundle\Exception\InvalidParameterException
  * @expectedExceptionMessage sonata_address_render needs 'id' key to be set to render the edit button
  */
 public function testRenderAddressMissingId()
 {
     $environment = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
     $address = array("firstname" => "", "lastname" => "", "address1" => "", "postcode" => "", "city" => "", "country_code" => "");
     $extension = new AddressExtension();
     $extension->renderAddress($environment, $address, true, true);
 }
Example #2
0
 /**
  * @expectedException Sonata\CoreBundle\Exception\InvalidParameterException
  * @expectedExceptionMessage sonata_address_render needs 'id' key to be set to render the edit button
  */
 public function testRenderAddressMissingId()
 {
     $environment = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
     $deliverySelector = $this->getMock('Sonata\\Component\\Delivery\\ServiceDeliverySelectorInterface');
     $address = array('firstname' => '', 'lastname' => '', 'address1' => '', 'postcode' => '', 'city' => '', 'country_code' => '');
     $extension = new AddressExtension($deliverySelector);
     $extension->renderAddress($environment, $address, true, true);
 }