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

api-platform / core / 10315659289

09 Aug 2024 07:49AM UTC coverage: 7.841% (-0.006%) from 7.847%
10315659289

push

github

soyuka
style: cs fixes

70 of 529 new or added lines in 176 files covered. (13.23%)

160 existing lines in 58 files now uncovered.

12688 of 161818 relevant lines covered (7.84%)

26.86 hits per line

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

0.0
/tests/Symfony/Maker/MakeStateProcessorTest.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\Tests\Symfony\Maker;
15

16
use Symfony\Bundle\FrameworkBundle\Console\Application;
17
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
18
use Symfony\Component\Console\Tester\CommandTester;
19
use Symfony\Component\Filesystem\Filesystem;
20

21
class MakeStateProcessorTest extends KernelTestCase
22
{
23
    protected function setup(): void
24
    {
25
        (new Filesystem())->remove(self::tempDir());
×
26
    }
27

28
    #[\PHPUnit\Framework\Attributes\DataProvider('stateProcessorProvider')]
29
    public function testMakeStateProcessor(bool $isInteractive): void
30
    {
31
        $inputs = ['name' => 'CustomStateProcessor'];
×
32
        $newProcessorFile = self::tempFile('src/State/CustomStateProcessor.php');
×
33

34
        $tester = new CommandTester((new Application(self::bootKernel()))->find('make:state-processor'));
×
35
        $tester->setInputs($isInteractive ? $inputs : []);
×
36
        $tester->execute($isInteractive ? [] : $inputs);
×
37

38
        $this->assertFileExists($newProcessorFile);
×
39

40
        // Unify line endings
41
        $expected = preg_replace('~\R~u', "\r\n", file_get_contents(__DIR__.'/../../Fixtures/Symfony/Maker/CustomStateProcessor.fixture'));
×
42
        $result = preg_replace('~\R~u', "\r\n", file_get_contents($newProcessorFile));
×
43
        $this->assertStringContainsString($expected, $result);
×
44

45
        $display = $tester->getDisplay();
×
46
        $this->assertStringContainsString('Success!', $display);
×
47

48
        $notInteractiveOutput = 'Choose a class name for your state processor (e.g. AwesomeStateProcessor):';
×
49

50
        if ($isInteractive) {
×
51
            $this->assertStringContainsString($notInteractiveOutput, $display);
×
52
        } else {
53
            $this->assertStringNotContainsString($notInteractiveOutput, $display);
×
54
        }
55

56
        $this->assertStringContainsString('Next: Open your new state processor class and start customizing it.', $display);
×
57
    }
58

59
    public static function stateProcessorProvider(): \Generator
60
    {
61
        yield 'Generate state processor' => [
×
62
            'isInteractive' => true,
×
63
        ];
×
64

65
        yield 'Generate state processor not interactively' => [
×
66
            'isInteractive' => false,
×
67
        ];
×
68
    }
69

70
    private static function tempDir(): string
71
    {
72
        return __DIR__.'/../../Fixtures/app/var/tmp';
×
73
    }
74

75
    private static function tempFile(string $path): string
76
    {
NEW
77
        return \sprintf('%s/%s', self::tempDir(), $path);
×
78
    }
79
}
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