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

api-platform / core / 17487636389

05 Sep 2025 08:13AM UTC coverage: 22.339% (-0.2%) from 22.577%
17487636389

push

github

soyuka
docs: changelog 4.1.23

11057 of 49497 relevant lines covered (22.34%)

11.74 hits per line

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

0.0
/src/Metadata/Tests/Resource/OperationTest.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\Metadata\Tests\Resource;
15

16
use ApiPlatform\Metadata\CollectionOperationInterface;
17
use ApiPlatform\Metadata\Delete;
18
use ApiPlatform\Metadata\Get;
19
use ApiPlatform\Metadata\GetCollection;
20
use ApiPlatform\Metadata\GraphQl\Mutation;
21
use ApiPlatform\Metadata\GraphQl\Query;
22
use ApiPlatform\Metadata\GraphQl\QueryCollection;
23
use ApiPlatform\Metadata\GraphQl\Subscription;
24
use ApiPlatform\Metadata\HttpOperation;
25
use ApiPlatform\Metadata\Operation;
26
use ApiPlatform\Metadata\Patch;
27
use ApiPlatform\Metadata\Post;
28
use ApiPlatform\Metadata\Put;
29
use PHPUnit\Framework\TestCase;
30

31
final class OperationTest extends TestCase
32
{
33
    public function testWithResourceTrait(): void
34
    {
35
        $operation = (new GetCollection())->withOperation((new HttpOperation())->withShortName('test')->withRead(false));
×
36

37
        $this->assertSame($operation->getShortName(), 'test');
×
38
        $this->assertSame($operation->canRead(), false);
×
39
        $this->assertSame($operation instanceof CollectionOperationInterface, true);
×
40
    }
41

42
    #[\PHPUnit\Framework\Attributes\DataProvider('operationProvider')]
43
    public function testOperationConstructor(Operation $operation): void
44
    {
45
        $this->assertInstanceOf(Operation::class, $operation);
×
46
    }
47

48
    public static function operationProvider(): \Generator
49
    {
50
        $args = [];
×
51

52
        yield [new Get(...$args)];
×
53
        yield [new GetCollection(...$args)];
×
54
        yield [new Post(...$args)];
×
55
        yield [new Put(...$args)];
×
56
        yield [new Patch(...$args)];
×
57
        yield [new Delete(...$args)];
×
58
        yield [new Query(...$args)];
×
59
        yield [new QueryCollection(...$args)];
×
60
        yield [new Mutation(...$args)];
×
61
        yield [new Subscription(...$args)];
×
62
    }
63

64
    public function testPaginationViaCursor(): void
65
    {
66
        $operation = (new GetCollection())->withPaginationViaCursor(true);
×
67
        $this->assertTrue($operation->canPaginateViaCursor());
×
68

69
        $operation = (new GetCollection())->withPaginationViaCursor(false);
×
70
        $this->assertFalse($operation->canPaginateViaCursor());
×
71
    }
72
}
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

© 2026 Coveralls, Inc