File "MetadataContainerTestHelper.php"

Full Path: /var/www/html/back/vendor/phpdocumentor/reflection/tests/unit/phpDocumentor/Reflection/Php/MetadataContainerTestHelper.php
File size: 828 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

declare(strict_types=1);

namespace phpDocumentor\Reflection\Php;

use phpDocumentor\Reflection\Exception;
use phpDocumentor\Reflection\Metadata\MetaDataContainer as MetaDataContainerInterface;

trait MetadataContainerTestHelper
{
    public function testSetMetaDataForNonExistingKey(): void
    {
        $stub = new MetadataStub('stub');

        $this->getFixture()->addMetadata($stub);

        self::assertSame(['stub' => $stub], $this->getFixture()->getMetadata());
    }

    public function testSetMetaDataWithExistingKeyThrows(): void
    {
        self::expectException(Exception::class);

        $stub = new MetadataStub('stub');

        $this->getFixture()->addMetadata($stub);
        $this->getFixture()->addMetadata($stub);
    }

    abstract public function getFixture(): MetaDataContainerInterface;
}