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

AlexanderAllen / panettone / 8878745975

29 Apr 2024 12:42PM UTC coverage: 75.316% (-6.8%) from 82.143%
8878745975

push

github

web-flow
Add configuration file support. (#30)

* Rename main command to Main.

* Rename main command to Main.

* Rename entrypoint to app.

* Update Main command.

* Promote Setup trait for use in command.

* Turn api-platform links into permalinks.

* Initial test configuration file.

* Initial test boilerplate for configuration file.

* Cleanup local test output path on each test run.

* Test that configured namespace exists.

* Move config test to pan de agua.

* Add configuration file capability and update test.

* Add support for config param in command.

* Cleanup namespaces.

* Cleanup comment.

* Add use class for setup in media noche.

13 of 48 new or added lines in 4 files covered. (27.08%)

119 of 158 relevant lines covered (75.32%)

2.9 hits per line

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

0.0
/src/Setup.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace AlexanderAllen\Panettone;
6

7
use Psr\Log\{LoggerAwareTrait, NullLogger};
8
use Symfony\Component\Console\Output\ConsoleOutput;
9
use Symfony\Component\Console\Logger\ConsoleLogger;
10
use cebe\openapi\{Reader, ReferenceContext};
11
use cebe\openapi\spec\{OpenApi};
12
use cebe\openapi\exceptions\{TypeErrorException, UnresolvableReferenceException, IOException};
13
use Nette\PhpGenerator\PsrPrinter as Printer;
14

15
/**
16
 * Sources schema from cebe openapi and provides Nette Printer.
17
 *
18
 * @package AlexanderAllen\Panettone\Test
19
 * @see https://github.com/AlexanderAllen/panettone/issues/18
20
 * @see https://github.com/api-platform/schema-generator/blob/997f6f811faa75006aeff72cec26fe291bb8eaab/src/Schema/Generator.php
21
 * @see https://github.com/api-platform/schema-generator/blob/997f6f811faa75006aeff72cec26fe291bb8eaab/src/FilesGenerator.php
22
 */
23
trait Setup
24
{
25
    use LoggerAwareTrait;
26

27
    /**
28
     * The real fixture method - setup the spec and logging for every test.
29
     *
30
     * Most tests in this suite read from a OAS source. This method just cuts
31
     * down some of that boilerplate, along with some of the logging ceremonies.
32
     *
33
     * @param string $spec
34
     *   The path to the Open API specification.
35
     * @param bool $log
36
     *   A Nette Printer instance used for logging and debugging.
37
     *
38
     * @return array{OpenApi, Printer}
39
     *   A tuple with the cebe OAS graph a Nette Printer instance.
40
     * @throws TypeErrorException
41
     * @throws UnresolvableReferenceException
42
     * @throws IOException
43
     */
44
    public function realSetup(string $spec, bool $log = false): array
45
    {
NEW
46
        $this->setLogger($log ?
×
NEW
47
            new ConsoleLogger(new ConsoleOutput(ConsoleOutput::VERBOSITY_DEBUG)) :
×
NEW
48
            new NullLogger());
×
49

NEW
50
        return [
×
NEW
51
            Reader::readFromYamlFile(
×
NEW
52
                realpath($spec),
×
NEW
53
                OpenAPI::class,
×
NEW
54
                ReferenceContext::RESOLVE_MODE_ALL,
×
NEW
55
            ),
×
NEW
56
            new Printer()
×
NEW
57
        ];
×
58
    }
59
}
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