Merge pull request #262 from voku/more_tests

Only more tests
This commit is contained in:
Jaap van Otterdijk
2021-03-07 12:12:25 +01:00
committed by GitHub
6 changed files with 294 additions and 1 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ final class See extends BaseTag implements Factory\StaticMethod
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
// https://tools.ietf.org/html/rfc2396#section-3
if (preg_match('/\w:\/\/\w/i', $parts[0])) {
if (preg_match('#\w://\w#', $parts[0])) {
return new static(new Url($parts[0]), $description);
}
@@ -78,6 +78,30 @@ class StandardTagFactoryTest extends TestCase
$this->assertSame($expectedDescription, $tag->getDescription());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses \phpDocumentor\Reflection\DocBlock\Description
*
* @covers ::__construct
* @covers ::create
*/
public function testCreatingAGenericTagWithDescriptionText() : void
{
$expectedTagName = 'unknown-tag';
$expectedDescriptionText = ' foo Bar 123 ';
$context = new Context('');
$tagFactory = new StandardTagFactory(new FqsenResolver());
$tagFactory->addService(new DescriptionFactory($tagFactory), DescriptionFactory::class);
$tag = $tagFactory->create('@' . $expectedTagName . $expectedDescriptionText, $context);
$this->assertInstanceOf(Generic::class, $tag);
$this->assertSame('foo Bar 123', $tag . '');
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author
@@ -146,6 +170,90 @@ class StandardTagFactoryTest extends TestCase
$this->assertSame('author', $tag->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*
* @covers ::__construct
* @covers ::create
*/
public function testPassingYourOwnSetOfTagHandlersWithGermanChars() : void
{
$typeResolver = new TypeResolver();
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$tagFactory = new StandardTagFactory(
$fqsenResolver,
['my-täg' => Author::class]
);
$tag = $tagFactory->create('@my-täg foo bar ', $context);
$this->assertInstanceOf(Author::class, $tag);
$this->assertSame('author', $tag->getName());
$this->assertSame('foo bar', $tag . '');
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*
* @covers ::__construct
* @covers ::create
*/
public function testPassingYourOwnSetOfTagHandlersWithoutComment() : void
{
$typeResolver = new TypeResolver();
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$tagFactory = new StandardTagFactory(
$fqsenResolver,
['my-täg' => Author::class]
);
$tag = $tagFactory->create('@my-täg', $context);
$this->assertInstanceOf(Author::class, $tag);
$this->assertSame('author', $tag->getName());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*
* @covers ::__construct
* @covers ::create
*/
public function testPassingYourOwnSetOfTagHandlersWithEmptyComment() : void
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage(
'The tag "@my-täg " does not seem to be wellformed, please check it for errors'
);
$typeResolver = new TypeResolver();
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$tagFactory = new StandardTagFactory(
$fqsenResolver,
['my-täg' => Author::class]
);
$tag = $tagFactory->create('@my-täg ', $context);
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
+30
View File
@@ -16,6 +16,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context;
@@ -174,6 +175,35 @@ class CoversTest extends TestCase
$this->assertSame('\DateTime', (string) $fixture);
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\FqsenResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
* @uses \phpDocumentor\Reflection\Types\Context
*
* @covers ::create
*/
public function testFactoryMethodWithSpaceBeforeClass() : void
{
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$fixture = Covers::create(
'Foo My Description ',
$descriptionFactory,
$fqsenResolver,
$context
);
$this->assertSame('\Foo My Description ', (string) $fixture);
$this->assertSame('\Foo', (string) $fixture->getReference());
$this->assertSame('My Description ', $fixture->getDescription() . '');
}
/**
* @covers ::__construct
* @covers ::__toString
+56
View File
@@ -16,6 +16,8 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPUnit\Framework\TestCase;
@@ -163,6 +165,60 @@ class LinkTest extends TestCase
$this->assertSame($description, $fixture->getDescription());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\FqsenResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
* @uses \phpDocumentor\Reflection\Types\Context
*
* @covers ::create
*/
public function testFactoryMethodWithoutSpaceBeforeUrl() : void
{
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$fixture = Link::create(
'http://this.is.my/link My Description ',
$descriptionFactory,
$context
);
$this->assertSame('http://this.is.my/link My Description ', (string) $fixture);
$this->assertSame('My Description ', $fixture->getDescription() . '');
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\FqsenResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
* @uses \phpDocumentor\Reflection\Types\Context
*
* @covers ::create
*/
public function testFactoryMethodWithSpaceBeforeUrl() : void
{
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$fixture = Link::create(
' http://this.is.my/link My Description ',
$descriptionFactory,
$context
);
$this->assertSame('http://this.is.my/link My Description ', (string) $fixture);
$this->assertSame('http://this.is.my/link My Description ', $fixture->getDescription() . '');
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
+32
View File
@@ -16,7 +16,9 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as TagsFqsen;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url as UrlRef;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
@@ -251,6 +253,36 @@ class SeeTest extends TestCase
$this->assertSame($description, $fixture->getDescription());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\FqsenResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
* @uses \phpDocumentor\Reflection\Types\Context
*
* @covers ::create
*/
public function testFactoryMethodWithoutUrl() : void
{
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$fixture = See::create(
'Foo My Description ',
$fqsenResolver,
$descriptionFactory,
$context
);
$this->assertSame('\Foo My Description ', (string) $fixture);
$this->assertInstanceOf(TagsFqsen::class, $fixture->getReference());
$this->assertSame('\Foo', (string) $fixture->getReference());
$this->assertSame('My Description ', $fixture->getDescription() . '');
}
/**
* @covers ::create
*/
+67
View File
@@ -16,6 +16,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context;
@@ -129,6 +130,12 @@ class UsesTest extends TestCase
*/
public function testStringRepresentationIsReturnedWithoutDescription() : void
{
$fixture = new Uses(new Fqsen('\\'));
$this->assertSame('\\', (string) $fixture);
// ---
$fixture = new Uses(new Fqsen('\DateTime'));
$this->assertSame('\DateTime', (string) $fixture);
@@ -170,6 +177,66 @@ class UsesTest extends TestCase
$this->assertSame($description, $fixture->getDescription());
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\FqsenResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
* @uses \phpDocumentor\Reflection\Types\Context
*
* @covers ::create
*/
public function testFactoryMethodWithoutSpaceBeforeClass() : void
{
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$fixture = Uses::create(
'Foo My Description ',
$fqsenResolver,
$descriptionFactory,
$context
);
$this->assertSame('\Foo My Description ', (string) $fixture);
$this->assertInstanceOf(Fqsen::class, $fixture->getReference());
$this->assertSame('\\Foo', (string) $fixture->getReference());
$this->assertSame('My Description ', $fixture->getDescription() . '');
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\FqsenResolver
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
* @uses \phpDocumentor\Reflection\Types\Context
*
* @covers ::create
*/
public function testFactoryMethodWithSpaceBeforeClass() : void
{
$fqsenResolver = new FqsenResolver();
$tagFactory = new StandardTagFactory($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$context = new Context('');
$fixture = Uses::create(
' Foo My Description ',
$fqsenResolver,
$descriptionFactory,
$context
);
$this->assertSame('\ Foo My Description ', (string) $fixture);
$this->assertInstanceOf(Fqsen::class, $fixture->getReference());
$this->assertSame('\\', (string) $fixture->getReference());
$this->assertSame('Foo My Description ', $fixture->getDescription() . '');
}
/**
* @covers ::create
*/