• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 15394793169

02 Jun 2025 02:22PM UTC coverage: 21.851% (-0.03%) from 21.877%
15394793169

push

github

web-flow
chore: use type-info:^7.3 (#7185)

0 of 168 new or added lines in 12 files covered. (0.0%)

15 existing lines in 7 files now uncovered.

11381 of 52084 relevant lines covered (21.85%)

10.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Symfony/Tests/Validator/Metadata/Property/Restriction/PropertySchemaFormatTest.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Symfony\Tests\Validator\Metadata\Property\Restriction;
15

16
use ApiPlatform\Metadata\ApiProperty;
17
use ApiPlatform\Symfony\Validator\Metadata\Property\Restriction\PropertySchemaFormat;
18
use PHPUnit\Framework\TestCase;
19
use Prophecy\PhpUnit\ProphecyTrait;
20
use Symfony\Component\Validator\Constraint;
21
use Symfony\Component\Validator\Constraints\Email;
22
use Symfony\Component\Validator\Constraints\Hostname;
23
use Symfony\Component\Validator\Constraints\Ip;
24
use Symfony\Component\Validator\Constraints\Positive;
25
use Symfony\Component\Validator\Constraints\Ulid;
26
use Symfony\Component\Validator\Constraints\Url;
27
use Symfony\Component\Validator\Constraints\Uuid;
28

29
final class PropertySchemaFormatTest extends TestCase
30
{
31
    use ProphecyTrait;
32

33
    private PropertySchemaFormat $propertySchemaFormatRestriction;
34

35
    protected function setUp(): void
36
    {
37
        $this->propertySchemaFormatRestriction = new PropertySchemaFormat();
×
38
    }
39

40
    #[\PHPUnit\Framework\Attributes\DataProvider('supportsProvider')]
41
    public function testSupports(Constraint $constraint, ApiProperty $propertyMetadata, bool $expectedResult): void
42
    {
43
        self::assertSame($expectedResult, $this->propertySchemaFormatRestriction->supports($constraint, $propertyMetadata));
×
44
    }
45

46
    public static function supportsProvider(): \Generator
47
    {
48
        yield 'email' => [new Email(), new ApiProperty(), true];
×
49
        yield 'url' => [new Url(requireTld: true), new ApiProperty(), true];
×
50
        if (class_exists(Hostname::class)) {
×
51
            yield 'hostname' => [new Hostname(), new ApiProperty(), true];
×
52
        }
53
        yield 'uuid' => [new Uuid(), new ApiProperty(), true];
×
54
        if (class_exists(Ulid::class)) {
×
55
            yield 'ulid' => [new Ulid(), new ApiProperty(), true];
×
56
        }
57
        yield 'ip' => [new Ip(), new ApiProperty(), true];
×
58
        yield 'not supported' => [new Positive(), new ApiProperty(), false];
×
59
    }
60

61
    #[\PHPUnit\Framework\Attributes\DataProvider('createProvider')]
62
    public function testCreate(Constraint $constraint, ApiProperty $propertyMetadata, array $expectedResult): void
63
    {
64
        self::assertSame($expectedResult, $this->propertySchemaFormatRestriction->create($constraint, $propertyMetadata));
×
65
    }
66

67
    public static function createProvider(): \Generator
68
    {
69
        yield 'email' => [new Email(), new ApiProperty(), ['format' => 'email']];
×
70
        yield 'url' => [new Url(requireTld: true), new ApiProperty(), ['format' => 'uri']];
×
71
        if (class_exists(Hostname::class)) {
×
72
            yield 'hostname' => [new Hostname(), new ApiProperty(), ['format' => 'hostname']];
×
73
        }
74
        yield 'uuid' => [new Uuid(), new ApiProperty(), ['format' => 'uuid']];
×
75
        if (class_exists(Ulid::class)) {
×
76
            yield 'ulid' => [new Ulid(), new ApiProperty(), ['format' => 'ulid']];
×
77
        }
NEW
78
        yield 'ipv4' => [new Ip(version: '4'), new ApiProperty(), ['format' => 'ipv4']];
×
NEW
79
        yield 'ipv6' => [new Ip(version: '6'), new ApiProperty(), ['format' => 'ipv6']];
×
UNCOV
80
        yield 'not supported' => [new Positive(), new ApiProperty(), []];
×
81
    }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc