• 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/PropertySchemaCountRestrictionTest.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\PropertySchemaCountRestriction;
18
use PHPUnit\Framework\TestCase;
19
use Prophecy\PhpUnit\ProphecyTrait;
20
use Symfony\Component\Validator\Constraint;
21
use Symfony\Component\Validator\Constraints\Count;
22
use Symfony\Component\Validator\Constraints\Positive;
23

24
/**
25
 * @author Tomas Norkūnas <norkunas.tom@gmail.com>
26
 */
27
final class PropertySchemaCountRestrictionTest extends TestCase
28
{
29
    use ProphecyTrait;
30

31
    private PropertySchemaCountRestriction $propertySchemaCountRestriction;
32

33
    protected function setUp(): void
34
    {
35
        $this->propertySchemaCountRestriction = new PropertySchemaCountRestriction();
×
36
    }
37

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

44
    public static function supportsProvider(): \Generator
45
    {
NEW
46
        yield 'supported' => [new Count(min: 1), new ApiProperty(), true];
×
47
        yield 'not supported' => [new Positive(), new ApiProperty(), false];
×
48
    }
49

50
    #[\PHPUnit\Framework\Attributes\DataProvider('createProvider')]
51
    public function testCreate(Count $constraint, ApiProperty $propertyMetadata, array $expectedResult): void
52
    {
53
        self::assertSame($expectedResult, $this->propertySchemaCountRestriction->create($constraint, $propertyMetadata));
×
54
    }
55

56
    public static function createProvider(): \Generator
57
    {
NEW
58
        yield 'min items' => [new Count(min: 1), new ApiProperty(), ['minItems' => 1]];
×
NEW
59
        yield 'max items' => [new Count(max: 10), new ApiProperty(), ['maxItems' => 10]];
×
NEW
60
        yield 'min/max items' => [new Count(min: 1, max: 10), new ApiProperty(), ['minItems' => 1, 'maxItems' => 10]];
×
61
    }
62
}
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