Add test for Author Tag

This commit is contained in:
Mike van Riel
2015-06-14 00:33:59 +02:00
committed by Mike van Riel
parent 8798633221
commit 0d29e96332
2 changed files with 122 additions and 6 deletions
+111
View File
@@ -0,0 +1,111 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2015 Mike van Riel<[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tags\Other;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Author
* @covers ::<private>
*/
class AuthorTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::__construct
* @covers ::getAuthorName
*/
public function testHasTheAuthorName()
{
$expected = 'Mike van Riel';
$fixture = new Author($expected, '[email protected]');
$this->assertSame($expected, $fixture->getAuthorName());
}
/**
* @covers ::__construct
* @covers ::getAuthorName
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfAuthorNameIsNotAString()
{
new Author([], '[email protected]');
}
/**
* @covers ::__construct
* @covers ::getEmail
*/
public function testHasTheAuthorMailAddress()
{
$expected = '[email protected]';
$fixture = new Author('Mike van Riel', $expected);
$this->assertSame($expected, $fixture->getEmail());
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfEmailIsNotAString()
{
new Author('Mike van Riel', []);
}
/**
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInitializationFailsIfEmailIsNotValid()
{
new Author('Mike van Riel', 'mike');
}
/**
* @covers ::__construct
* @covers ::__toString
*/
public function testStringRepresentationIsReturned()
{
$fixture = new Author('Mike van Riel', '[email protected]');
$this->assertSame('Mike van Riel<[email protected]>', (string)$fixture);
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::<public>
*/
public function testFactoryMethod()
{
$fixture = Author::create('Mike van Riel <[email protected]>');
$this->assertSame('Mike van Riel<[email protected]>', (string)$fixture);
$this->assertSame('Mike van Riel', $fixture->getAuthorName());
$this->assertSame('[email protected]', $fixture->getEmail());
}
/**
* @covers ::create
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::<public>
*/
public function testFactoryMethodReturnsNullIfItCouldNotReadBody()
{
$this->assertNull(Author::create('dfgr<'));
}
}