8000 [Validator] Define which collection keys should be checked for uniqueness by wkania · Pull Request #42403 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Define which collection keys should be checked for uniqueness #42403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
Remove redundant test
  • Loading branch information
wkania committed Apr 3, 2022
commit 8e6682f6edb0d4b3b606a49db5b8ea413d3e5568
Original file line number Diff line number Diff line change
Expand Up @@ -221,35 +221,6 @@ public function testExpectsValidCaseInsensitiveComparison()
$this->assertNoViolation();
}

/**
* @dataProvider getValidCollectionValues
*/
public function testValidCollectionValues($value, $fields)
{
$this->validator->validate($value, new Unique($fields));

$this->assertNoViolation();
}

public function getValidCollectionValues()
{
return [
yield 'single string' => [[['letter' => 'a']], 'letter'],
yield 'unique strings' => [[['language' => 'eng'], ['language' => 'fra'], ['language' => 'pol']], 'language'],
yield 'unique floats' => [[
['latitude' => 51.509865, 'longitude' => -0.118092],
['latitude' => 48.864716, 'longitude' => 2.349014],
['latitude' => 52.520008, 'longitude' => 13.404954],
], ['latitude', 'longitude']],
yield 'unique int and string' => [[
['id' => 1, 'email' => 'bar@email.com'], ['id' => 2, 'email' => 'foo@email.com'],
], ['id', 'name']],
yield 'unique arrays' => [[['vector' => [1, 2]], ['vector' => [2, 4]], ['vector' => [4, 6]]
], ['vector']],
yield 'unique objects' => [[['object' => new \stdClass()], ['object' => new \stdClass()]], ['object']],
];
}

/**
* @dataProvider getInvalidCollectionValues
*/
Expand Down
0