mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
add more unit tests and normalize the "__toString" methods
This commit is contained in:
@@ -116,6 +116,23 @@ class AuthorTest extends TestCase
|
||||
$fixture = new Author('Mike van Riel', '[email protected]');
|
||||
|
||||
$this->assertSame('Mike van Riel <[email protected]>', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Author('0', '[email protected]');
|
||||
|
||||
$this->assertSame('0 <[email protected]>', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutName() : void
|
||||
{
|
||||
$fixture = new Author('', '[email protected]');
|
||||
|
||||
$this->assertSame('<[email protected]>', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -151,6 +151,40 @@ class CoversTest extends TestCase
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Covers(new Fqsen('\\'));
|
||||
|
||||
$this->assertSame('\\', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Covers(new Fqsen('\DateTime'));
|
||||
|
||||
$this->assertSame('\DateTime', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Covers(new Fqsen('\DateTime'), new Description(''));
|
||||
|
||||
$this->assertSame('\DateTime', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithDescription() : void
|
||||
{
|
||||
$fixture = new Covers(new Fqsen('\DateTime'), new Description('My Description'));
|
||||
|
||||
$this->assertSame('\DateTime My Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
|
||||
@@ -117,6 +117,37 @@ class DeprecatedTest extends TestCase
|
||||
$fixture = new Deprecated('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('1.0 Description', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Deprecated(null, new Description('My Description'));
|
||||
|
||||
$this->assertSame('My Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Deprecated(null, new Description(''));
|
||||
|
||||
$this->assertSame('', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Deprecated('1.0', new Description(''));
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Deprecated('1.0');
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -37,7 +37,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -52,7 +52,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -67,7 +67,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -84,7 +84,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
@@ -101,7 +101,7 @@ class ExampleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
|
||||
@@ -107,6 +107,26 @@ class GenericTest extends TestCase
|
||||
$this->assertSame('Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Generic('generic');
|
||||
|
||||
$this->assertSame('', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Generic('generic', new Description(''));
|
||||
|
||||
$this->assertSame('', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -119,6 +119,25 @@ class LinkTest extends TestCase
|
||||
$this->assertSame('http://this.is.my/link Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Link('http://this.is.my/link');
|
||||
|
||||
$this->assertSame('http://this.is.my/link', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Link('http://this.is.my/link', new Description(''));
|
||||
|
||||
$this->assertSame('http://this.is.my/link', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -268,6 +268,36 @@ class MethodTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::isStatic
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Method('myMethod', [], null, false, new Description(''));
|
||||
|
||||
$this->assertSame(
|
||||
'void myMethod()',
|
||||
(string) $fixture
|
||||
);
|
||||
|
||||
// ---
|
||||
|
||||
$arguments = [
|
||||
['name' => 'argument1', 'type' => new String_()],
|
||||
['name' => 'argument2', 'type' => new Object_()],
|
||||
];
|
||||
$fixture = new Method('myMethod', $arguments, new Void_(), true);
|
||||
|
||||
$this->assertSame(
|
||||
'static void myMethod(string $argument1, object $argument2)',
|
||||
(string) $fixture
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -122,6 +122,25 @@ class ReturnTest extends TestCase
|
||||
$this->assertSame('string Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Return_(new String_());
|
||||
|
||||
$this->assertSame('string', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Return_(new String_(), new Description(''));
|
||||
|
||||
$this->assertSame('string', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -135,6 +135,27 @@ class SeeTest extends TestCase
|
||||
$this->assertSame('\DateTime::format() Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen
|
||||
* @uses \phpDocumentor\Reflection\Fqsen
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new See(new FqsenRef(new Fqsen('\DateTime::format()')));
|
||||
|
||||
$this->assertSame('\DateTime::format()', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new See(new FqsenRef(new Fqsen('\DateTime::format()')), new Description(''));
|
||||
|
||||
$this->assertSame('\DateTime::format()', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -119,6 +119,25 @@ class SinceTest extends TestCase
|
||||
$this->assertSame('1.0 Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Since('1.0');
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Since('1.0', new Description(''));
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -137,6 +137,32 @@ class SourceTest extends TestCase
|
||||
$this->assertSame('1 10 Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Source(1);
|
||||
|
||||
$this->assertSame('1', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Source(1, 0);
|
||||
|
||||
$this->assertSame('1 0', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Source(1, 10, new Description(''));
|
||||
|
||||
$this->assertSame('1 10', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -120,6 +120,31 @@ class ThrowsTest extends TestCase
|
||||
$fixture = new Throws(new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('string Description', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Throws(new String_(), new Description('My Description'));
|
||||
|
||||
$this->assertSame('string My Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Throws(new String_());
|
||||
|
||||
$this->assertSame('string', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Throws(new String_(), new Description(''));
|
||||
|
||||
$this->assertSame('string', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,6 +121,25 @@ class UsesTest extends TestCase
|
||||
$this->assertSame('\DateTime Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Uses(new Fqsen('\DateTime'));
|
||||
|
||||
$this->assertSame('\DateTime', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Uses(new Fqsen('\DateTime'), new Description(''));
|
||||
|
||||
$this->assertSame('\DateTime', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -154,6 +154,32 @@ class VarTest extends TestCase
|
||||
$this->assertSame('string $myVariable Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Var_('myVariable');
|
||||
|
||||
$this->assertSame('$myVariable', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Var_('myVariable', new String_());
|
||||
|
||||
$this->assertSame('string $myVariable', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Var_('myVariable', new String_(), new Description(''));
|
||||
|
||||
$this->assertSame('string $myVariable', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
@@ -119,6 +119,25 @@ class VersionTest extends TestCase
|
||||
$this->assertSame('1.0 Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||
{
|
||||
$fixture = new Version('1.0');
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
|
||||
// ---
|
||||
|
||||
$fixture = new Version('1.0', new Description(''));
|
||||
|
||||
$this->assertSame('1.0', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
|
||||
Reference in New Issue
Block a user