optimized code from tests
This commit is contained in:
parent
fb9f31ccee
commit
c09b13c124
1 changed files with 17 additions and 11 deletions
|
@ -20,8 +20,8 @@ class SettingsValidatorTest extends FunctionalTestCase
|
||||||
*/
|
*/
|
||||||
public function ifNoNameIsGivenClassNameIsUsed(): void
|
public function ifNoNameIsGivenClassNameIsUsed(): void
|
||||||
{
|
{
|
||||||
$validator = $this->objectManager->get(SettingsValidator::class);
|
$result = $this->objectManager->get(SettingsValidator::class)->validate(new TestObject());
|
||||||
$result = $validator->validate(new TestObject());
|
|
||||||
$this->assertTrue($result->hasErrors());
|
$this->assertTrue($result->hasErrors());
|
||||||
$this->assertCount(1, $result->getFlattenedErrors());
|
$this->assertCount(1, $result->getFlattenedErrors());
|
||||||
$this->assertCount(1, $result->forProperty('shouldBeFalse')->getErrors());
|
$this->assertCount(1, $result->forProperty('shouldBeFalse')->getErrors());
|
||||||
|
@ -35,9 +35,11 @@ class SettingsValidatorTest extends FunctionalTestCase
|
||||||
*/
|
*/
|
||||||
public function conjunctionValidationWorksAsExpected(): void
|
public function conjunctionValidationWorksAsExpected(): void
|
||||||
{
|
{
|
||||||
$validatorResolver = $this->objectManager->get(ValidatorResolver::class);
|
$result = $this->objectManager
|
||||||
$validator = $validatorResolver->getBaseValidatorConjunction(TestObject::class);
|
->get(ValidatorResolver::class)
|
||||||
$result = $validator->validate(new TestObject());
|
->getBaseValidatorConjunction(TestObject::class)
|
||||||
|
->validate(new TestObject());
|
||||||
|
|
||||||
$this->assertTrue($result->hasErrors());
|
$this->assertTrue($result->hasErrors());
|
||||||
$this->assertCount(1, $result->getFlattenedErrors());
|
$this->assertCount(1, $result->getFlattenedErrors());
|
||||||
}
|
}
|
||||||
|
@ -48,9 +50,11 @@ class SettingsValidatorTest extends FunctionalTestCase
|
||||||
*/
|
*/
|
||||||
public function defaultValidationGroupWorks(): void
|
public function defaultValidationGroupWorks(): void
|
||||||
{
|
{
|
||||||
$validator = $this->objectManager->get(SettingsValidator::class, ['validationGroups' => ['Default']]);
|
$result = $this->objectManager
|
||||||
$result = $validator->validate(new TestValidationGroupsDefaultObject());
|
->get(SettingsValidator::class, ['validationGroups' => ['Default']])
|
||||||
$this->assertTrue($result->hasErrors(), 'No Errors for validation group "Default"');
|
->validate(new TestValidationGroupsDefaultObject());
|
||||||
|
|
||||||
|
$this->assertTrue($result->hasErrors(), 'No errors for validation group "Default"');
|
||||||
$this->assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Default"');
|
$this->assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Default"');
|
||||||
$this->assertCount(1, $result->forProperty('shouldBeTrue')->getErrors(), 'Got no error for property');
|
$this->assertCount(1, $result->forProperty('shouldBeTrue')->getErrors(), 'Got no error for property');
|
||||||
}
|
}
|
||||||
|
@ -61,9 +65,11 @@ class SettingsValidatorTest extends FunctionalTestCase
|
||||||
*/
|
*/
|
||||||
public function customValidationGroupWorks(): void
|
public function customValidationGroupWorks(): void
|
||||||
{
|
{
|
||||||
$validator = $this->objectManager->get(SettingsValidator::class, ['validationGroups' => ['Custom']]);
|
$result = $this->objectManager
|
||||||
$result = $validator->validate(new TestValidationGroupsCustomObject());
|
->get(SettingsValidator::class, ['validationGroups' => ['Custom']])
|
||||||
$this->assertTrue($result->hasErrors(), 'No Errors for validation group "Custom"');
|
->validate(new TestValidationGroupsCustomObject());
|
||||||
|
|
||||||
|
$this->assertTrue($result->hasErrors(), 'No errors for validation group "Custom"');
|
||||||
$this->assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Custom"');
|
$this->assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Custom"');
|
||||||
$this->assertCount(1, $result->forProperty('shouldBeFalse')->getErrors(), 'Got no error for property');
|
$this->assertCount(1, $result->forProperty('shouldBeFalse')->getErrors(), 'Got no error for property');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue