annotate vendor/psy/psysh/test/Formatter/DocblockFormatterTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 5fb285c0d0e3
children
rev   line source
Chris@13 1 <?php
Chris@13 2
Chris@13 3 /*
Chris@13 4 * This file is part of Psy Shell.
Chris@13 5 *
Chris@13 6 * (c) 2012-2018 Justin Hileman
Chris@13 7 *
Chris@13 8 * For the full copyright and license information, please view the LICENSE
Chris@13 9 * file that was distributed with this source code.
Chris@13 10 */
Chris@13 11
Chris@13 12 namespace Psy\Test\Formatter;
Chris@13 13
Chris@13 14 use Psy\Formatter\DocblockFormatter;
Chris@13 15
Chris@13 16 class DocblockFormatterTest extends \PHPUnit\Framework\TestCase
Chris@13 17 {
Chris@13 18 /**
Chris@13 19 * This is a docblock!
Chris@13 20 *
Chris@13 21 * @author Justin Hileman <justin@justinhileman.info>
Chris@13 22 *
Chris@13 23 * @throws InvalidArgumentException if $foo is empty
Chris@13 24 *
Chris@13 25 * @param mixed $foo It's a foo thing
Chris@13 26 * @param int $bar This is definitely bar
Chris@13 27 *
Chris@13 28 * @return string A string of no consequence
Chris@13 29 */
Chris@13 30 private function methodWithDocblock($foo, $bar = 1)
Chris@13 31 {
Chris@13 32 if (empty($foo)) {
Chris@13 33 throw new \InvalidArgumentException();
Chris@13 34 }
Chris@13 35
Chris@13 36 return 'method called';
Chris@13 37 }
Chris@13 38
Chris@13 39 public function testFormat()
Chris@13 40 {
Chris@13 41 $expected = <<<EOS
Chris@13 42 <comment>Description:</comment>
Chris@13 43 This is a docblock!
Chris@13 44
Chris@13 45 <comment>Throws:</comment>
Chris@13 46 <info>InvalidArgumentException </info> if \$foo is empty
Chris@13 47
Chris@13 48 <comment>Param:</comment>
Chris@13 49 <info>mixed </info> <strong>\$foo </strong> It's a foo thing
Chris@13 50 <info>int </info> <strong>\$bar </strong> This is definitely bar
Chris@13 51
Chris@13 52 <comment>Return:</comment>
Chris@13 53 <info>string </info> A string of no consequence
Chris@13 54
Chris@13 55 <comment>Author:</comment> Justin Hileman \<justin@justinhileman.info>
Chris@13 56 EOS;
Chris@13 57
Chris@13 58 $this->assertSame(
Chris@13 59 $expected,
Chris@13 60 DocblockFormatter::format(new \ReflectionMethod($this, 'methodWithDocblock'))
Chris@13 61 );
Chris@13 62 }
Chris@13 63 }