fix: fix 500 when submitting step1 form without entering values (#684)
This commit is contained in:
parent
24f27294f0
commit
bef999767e
2 changed files with 30 additions and 13 deletions
|
|
@ -45,7 +45,7 @@ class Address implements \Stringable
|
||||||
#[ORM\Column(type: Types::STRING, length: 255, nullable: false)]
|
#[ORM\Column(type: Types::STRING, length: 255, nullable: false)]
|
||||||
#[Assert\NotBlank]
|
#[Assert\NotBlank]
|
||||||
#[Assert\Length(max: 255)]
|
#[Assert\Length(max: 255)]
|
||||||
private string $address;
|
private ?string $address = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional information for the address, eg: APT 555.
|
* Additional information for the address, eg: APT 555.
|
||||||
|
|
@ -90,7 +90,7 @@ class Address implements \Stringable
|
||||||
#[ORM\Column(type: Types::STRING, length: 255, nullable: false)]
|
#[ORM\Column(type: Types::STRING, length: 255, nullable: false)]
|
||||||
#[Assert\NotBlank]
|
#[Assert\NotBlank]
|
||||||
#[Assert\Length(max: 255)]
|
#[Assert\Length(max: 255)]
|
||||||
private string $locality = '';
|
private ?string $locality = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postal code, eg: "59160".
|
* Postal code, eg: "59160".
|
||||||
|
|
@ -98,7 +98,7 @@ class Address implements \Stringable
|
||||||
#[ORM\Column(type: Types::STRING, length: 10, nullable: false)]
|
#[ORM\Column(type: Types::STRING, length: 10, nullable: false)]
|
||||||
#[Assert\NotBlank]
|
#[Assert\NotBlank]
|
||||||
#[Assert\Length(max: 20)]
|
#[Assert\Length(max: 20)]
|
||||||
private string $postalCode;
|
private ?string $postalCode = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ISO code of the country, eg: "FR".
|
* ISO code of the country, eg: "FR".
|
||||||
|
|
@ -108,7 +108,7 @@ class Address implements \Stringable
|
||||||
#[ORM\Column(type: Types::STRING, length: 2, nullable: false)]
|
#[ORM\Column(type: Types::STRING, length: 2, nullable: false)]
|
||||||
#[Assert\NotBlank]
|
#[Assert\NotBlank]
|
||||||
#[Assert\Country]
|
#[Assert\Country]
|
||||||
private string $country;
|
private ?string $country = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Latitude of the address (north/south), eg: "50.6322562".
|
* Latitude of the address (north/south), eg: "50.6322562".
|
||||||
|
|
@ -167,12 +167,12 @@ class Address implements \Stringable
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAddress(): string
|
public function getAddress(): ?string
|
||||||
{
|
{
|
||||||
return $this->address;
|
return $this->address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAddress(string $address): self
|
public function setAddress(?string $address): self
|
||||||
{
|
{
|
||||||
$this->address = $address;
|
$this->address = $address;
|
||||||
|
|
||||||
|
|
@ -227,7 +227,7 @@ class Address implements \Stringable
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocality(): string
|
public function getLocality(): ?string
|
||||||
{
|
{
|
||||||
return $this->locality;
|
return $this->locality;
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +237,7 @@ class Address implements \Stringable
|
||||||
return $this->locality !== '';
|
return $this->locality !== '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLocality(string $locality): self
|
public function setLocality(?string $locality): self
|
||||||
{
|
{
|
||||||
$this->locality = $locality;
|
$this->locality = $locality;
|
||||||
|
|
||||||
|
|
@ -256,24 +256,24 @@ class Address implements \Stringable
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostalCode(): string
|
public function getPostalCode(): ?string
|
||||||
{
|
{
|
||||||
return $this->postalCode;
|
return $this->postalCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPostalCode(string $postalCode): self
|
public function setPostalCode(?string $postalCode): self
|
||||||
{
|
{
|
||||||
$this->postalCode = $postalCode;
|
$this->postalCode = $postalCode;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCountry(): string
|
public function getCountry(): ?string
|
||||||
{
|
{
|
||||||
return $this->country;
|
return $this->country;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCountry(string $country): self
|
public function setCountry(?string $country): self
|
||||||
{
|
{
|
||||||
$this->country = $country;
|
$this->country = $country;
|
||||||
|
|
||||||
|
|
@ -378,7 +378,7 @@ class Address implements \Stringable
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubAndLocality(): string
|
public function getSubAndLocality(): ?string
|
||||||
{
|
{
|
||||||
if (u($this->subLocality)->isEmpty()) {
|
if (u($this->subLocality)->isEmpty()) {
|
||||||
return $this->locality;
|
return $this->locality;
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,23 @@ final class AddressControllerTest extends WebTestCase
|
||||||
self::assertSelectorTextContains('body', 'address.step1_action.no_address.warning');
|
self::assertSelectorTextContains('body', 'address.step1_action.no_address.warning');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Step1 form submitted without entering data.
|
||||||
|
*/
|
||||||
|
public function testStep1FormNothingFilledFailure(): void
|
||||||
|
{
|
||||||
|
$client = self::createClient();
|
||||||
|
$this->loginAsUser16($client);
|
||||||
|
|
||||||
|
$crawler = $client->request('GET', self::ROUTE_STEP1);
|
||||||
|
self::assertResponseIsSuccessful();
|
||||||
|
|
||||||
|
$form = $crawler->selectButton(self::STEP1_FORM_ID.'_submit')->form();
|
||||||
|
$client->submit($form);
|
||||||
|
self::assertResponseIsUnprocessable();
|
||||||
|
self::assertSelectorTextContains('body', 'This value should not be blank');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Step2 direct access is forbidden.
|
* Step2 direct access is forbidden.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue