Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[FWB][Serializer][Form][Validator] Uid integration #36317

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 33 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
UidTest
  • Loading branch information
Guillaume Pédelagrabe committed Apr 8, 2020
commit 7178f5b2dcc999fdd9fc22f3b6da2b42a5a5aa49
58 changes: 58 additions & 0 deletions 58 src/Symfony/Component/Validator/Tests/Constraints/UidTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Symfony\Component\Validator\Tests\Constraints;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraints\Uid;

class UidTest extends TestCase
{
public function testNotArrayTypesTriggersException()
{
$this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
$this->expectExceptionMessage('The "types" parameter should be an array.');
$uid = new Uid(['types' => 'foo']);
}

public function testInvalidTypeTriggerException()
{
$this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
$this->expectExceptionMessage('The "types" parameter is not valid.');
$uid = new Uid(['types' => ['foo']]);
}

public function testNotArrayVersionsTriggersException()
{
$this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
$this->expectExceptionMessage('The "versions" parameter should be an array.');
$uid = new Uid(['versions' => 'foo']);
}

public function testInvalidVersionTriggerException()
{
$this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
$this->expectExceptionMessage('The "versions" parameter is not valid.');
$uid = new Uid(['versions' => [7]]);
}

public function testNormalizerCanBeSet()
{
$email = new Uid(['normalizer' => 'trim']);

$this->assertEquals('trim', $email->normalizer);
}

public function testInvalidNormalizerThrowsException()
{
$this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
$this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).');
new Uid(['normalizer' => 'Unknown Callable']);
}

public function testInvalidNormalizerObjectThrowsException()
{
$this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
$this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).');
new Uid(['normalizer' => new \stdClass()]);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.