Exemplo n.º 1
0
 /**
  * Tests creating a address format via a form and programmatically.
  */
 function testAddressFormatCreation()
 {
     $countryCode = 'CM';
     $values = ['countryCode' => $countryCode, 'format' => '%locality', 'localityType' => 'city'];
     $addressFormat = AddressFormat::create($values);
     $addressFormat->save();
     $this->drupalGet('admin/config/regional/address-formats/manage/' . $addressFormat->id());
     $this->assertResponse(200, 'The new address format can be accessed at admin/config/regional/address-formats.');
     $addressFormat = AddressFormat::load($countryCode);
     $this->assertEqual($addressFormat->getCountryCode(), $values['countryCode'], 'The new address format has the correct countryCode.');
     $this->assertEqual($addressFormat->getFormat(), $values['format'], 'The new address format has the correct format string.');
     $this->assertEqual($addressFormat->getLocalityType(), $values['localityType'], 'The new address format has the correct localityType.');
     $countryCode = 'YE';
     $edit = ['countryCode' => $countryCode, 'format' => '%locality', 'localityType' => 'city'];
     $this->drupalGet('admin/config/regional/address-formats/add');
     $this->assertResponse(200, 'The address format add form can be accessed at admin/config/regional/address-formats/add.');
     $this->drupalPostForm('admin/config/regional/address-formats/add', $edit, t('Save'));
     $addressFormat = AddressFormat::load($countryCode);
     $this->assertEqual($addressFormat->getCountryCode(), $edit['countryCode'], 'The new address format has the correct countryCode.');
     $this->assertEqual($addressFormat->getFormat(), $edit['format'], 'The new address format has the correct format string.');
     $this->assertEqual($addressFormat->getLocalityType(), $edit['localityType'], 'The new address format has the correct localityType.');
 }
Exemplo n.º 2
0
 /**
  * Tests creating a address format via a form and programmatically.
  */
 function testAddressFormatCreation()
 {
     $country_code = 'CM';
     $values = ['countryCode' => $country_code, 'format' => '%locality', 'localityType' => 'city'];
     $address_format = AddressFormat::create($values);
     $address_format->save();
     $this->drupalGet('admin/config/regional/address-formats/manage/' . $address_format->id());
     $this->assertSession()->statusCodeEquals(200);
     $address_format = AddressFormat::load($country_code);
     $this->assertEquals($address_format->getCountryCode(), $values['countryCode'], 'The new address format has the correct countryCode.');
     $this->assertEquals($address_format->getFormat(), $values['format'], 'The new address format has the correct format string.');
     $this->assertEquals($address_format->getLocalityType(), $values['localityType'], 'The new address format has the correct localityType.');
     $country_code = 'YE';
     $edit = ['countryCode' => $country_code, 'format' => '%locality', 'localityType' => 'city'];
     $this->drupalGet('admin/config/regional/address-formats/add');
     $this->assertSession()->statusCodeEquals(200);
     $this->submitForm($edit, t('Save'));
     $address_format = AddressFormat::load($country_code);
     $this->assertEquals($address_format->getCountryCode(), $edit['countryCode'], 'The new address format has the correct countryCode.');
     $this->assertEquals($address_format->getFormat(), $edit['format'], 'The new address format has the correct format string.');
     $this->assertEquals($address_format->getLocalityType(), $edit['localityType'], 'The new address format has the correct localityType.');
 }