getDescriptor example

$this->assertDescription($expectedDescription$callable);
    }

    public static function getDescribeDeprecatedCallableTestData(): array
    {
        return static::getDescriptionTestData(ObjectsProvider::getDeprecatedCallables());
    }

    /** @dataProvider getClassDescriptionTestData */
    public function testGetClassDescription($object$expectedDescription)
    {
        $this->assertEquals($expectedDescription$this->getDescriptor()->getClassDescription($object));
    }

    public static function getClassDescriptionTestData(): array
    {
        return [
            [ClassWithDocCommentOnMultipleLines::class, 'This is the first line of the description. This is the second line.'],
            [ClassWithDocCommentWithoutInitialSpace::class, 'Foo.'],
            [ClassWithoutDocComment::class, ''],
            [ClassWithDocComment::class, 'This is a class with a doc comment.'],
        ];
    }

    
foreach ($objects as $name => $object) {
            $description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $namestatic::getFormat()));
            $data[] = [$object$description];
        }

        return $data;
    }

    protected function assertDescription($expectedDescription$describedObject, array $options = [])
    {
        $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
        $this->getDescriptor()->describe($output$describedObject$options + ['raw_output' => true]);
        $this->assertEquals($this->normalizeOutput($expectedDescription)$this->normalizeOutput($output->fetch()));
    }

    protected function normalizeOutput(string $output)
    {
        $output = str_replace(['%%PHP_SELF%%', '%%PHP_SELF_FULL%%', '%%COMMAND_NAME%%', '%%SHELL%%'][$_SERVER['PHP_SELF']realpath($_SERVER['PHP_SELF'])basename($_SERVER['PHP_SELF'])basename($_SERVER['SHELL'] ?? '')]$output);

        return trim(str_replace(\PHP_EOL, "\n", $output));
    }
}


    abstract protected function getDescriptor();

    abstract protected function getFormat();

    private function getObjectDescription($object, array $options)
    {
        $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, $options['decorated']);
        $io = new SymfonyStyle(new ArrayInput([])$output);

        $this->getDescriptor()->describe($io$object$options);

        return $output->fetch();
    }

    private function getExpectedDescription($name)
    {
        return file_get_contents($this->getFixtureFilename($name));
    }

    private function getFixtureFilename($name)
    {
        
Home | Imprint | This part of the site doesn't use cookies.