|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * phpDocumentor Example Tag Test |
| 4 | + * |
| 5 | + * PHP version 5.3 |
| 6 | + * |
| 7 | + * @author Vasil Rangelov <[email protected]> |
| 8 | + * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com) |
| 9 | + * @license http://www.opensource.org/licenses/mit-license.php MIT |
| 10 | + * @link http://phpdoc.org |
| 11 | + */ |
| 12 | + |
| 13 | +namespace phpDocumentor\Reflection\DocBlock\Tag; |
| 14 | + |
| 15 | +/** |
| 16 | + * Test class for \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag |
| 17 | + * |
| 18 | + * @author Vasil Rangelov <[email protected]> |
| 19 | + * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com) |
| 20 | + * @license http://www.opensource.org/licenses/mit-license.php MIT |
| 21 | + * @link http://phpdoc.org |
| 22 | + */ |
| 23 | +class ExampleTagTest extends \PHPUnit_Framework_TestCase |
| 24 | +{ |
| 25 | + /** |
| 26 | + * Test that the \phpDocumentor\Reflection\DocBlock\Tag\SourceTag can |
| 27 | + * understand the @source DocBlock. |
| 28 | + * |
| 29 | + * @param string $type |
| 30 | + * @param string $content |
| 31 | + * @param string $exContent |
| 32 | + * @param string $exStartingLine |
| 33 | + * @param string $exLineCount |
| 34 | + * @param string $exFilepath |
| 35 | + * |
| 36 | + * @covers \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag::__construct |
| 37 | + * @covers \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag::getFilePath |
| 38 | + * @dataProvider provideDataForConstuctor |
| 39 | + * |
| 40 | + * @return void |
| 41 | + */ |
| 42 | + public function testConstructorParesInputsIntoCorrectFields( |
| 43 | + $type, |
| 44 | + $content, |
| 45 | + $exContent, |
| 46 | + $exDescription, |
| 47 | + $exStartingLine, |
| 48 | + $exLineCount, |
| 49 | + $exFilePath |
| 50 | + ) { |
| 51 | + $tag = new ExampleTag($type, $content); |
| 52 | + |
| 53 | + $this->assertEquals($type, $tag->getName()); |
| 54 | + $this->assertEquals($exContent, $tag->getContent()); |
| 55 | + $this->assertEquals($exDescription, $tag->getDescription()); |
| 56 | + $this->assertEquals($exStartingLine, $tag->getStartingLine()); |
| 57 | + $this->assertEquals($exLineCount, $tag->getLineCount()); |
| 58 | + $this->assertEquals($exFilePath, $tag->getFilePath()); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Data provider for testConstructorParesInputsIntoCorrectFields |
| 63 | + * |
| 64 | + * @return array |
| 65 | + */ |
| 66 | + public function provideDataForConstuctor() |
| 67 | + { |
| 68 | + // $type, $content, $exContent, $exDescription, $exStartingLine, $exLineCount, $exFilePath |
| 69 | + return array( |
| 70 | + array( |
| 71 | + 'example', |
| 72 | + 'file.php', |
| 73 | + 'file.php', |
| 74 | + '', |
| 75 | + 1, |
| 76 | + null, |
| 77 | + 'file.php' |
| 78 | + ), |
| 79 | + array( |
| 80 | + 'example', |
| 81 | + 'Testing comments', |
| 82 | + 'Testing comments', |
| 83 | + 'comments', |
| 84 | + 1, |
| 85 | + null, |
| 86 | + 'Testing' |
| 87 | + ), |
| 88 | + array( |
| 89 | + 'example', |
| 90 | + 'file.php 2 Testing', |
| 91 | + 'file.php 2 Testing', |
| 92 | + 'Testing', |
| 93 | + 2, |
| 94 | + null, |
| 95 | + 'file.php' |
| 96 | + ), |
| 97 | + array( |
| 98 | + 'example', |
| 99 | + 'file.php 2 3 Testing comments', |
| 100 | + 'file.php 2 3 Testing comments', |
| 101 | + 'Testing comments', |
| 102 | + 2, |
| 103 | + 3, |
| 104 | + 'file.php' |
| 105 | + ), |
| 106 | + array( |
| 107 | + 'example', |
| 108 | + 'file.php 2 -1 Testing comments', |
| 109 | + 'file.php 2 -1 Testing comments', |
| 110 | + '-1 Testing comments', |
| 111 | + 2, |
| 112 | + null, |
| 113 | + 'file.php' |
| 114 | + ), |
| 115 | + array( |
| 116 | + 'example', |
| 117 | + 'file.php -1 1 Testing comments', |
| 118 | + 'file.php -1 1 Testing comments', |
| 119 | + '-1 1 Testing comments', |
| 120 | + 1, |
| 121 | + null, |
| 122 | + 'file.php' |
| 123 | + ), |
| 124 | + array( |
| 125 | + 'example', |
| 126 | + '"file with spaces.php" Testing comments', |
| 127 | + '"file with spaces.php" Testing comments', |
| 128 | + 'Testing comments', |
| 129 | + 1, |
| 130 | + null, |
| 131 | + 'file with spaces.php' |
| 132 | + ), |
| 133 | + array( |
| 134 | + 'example', |
| 135 | + '"file with spaces.php" 2 Testing comments', |
| 136 | + '"file with spaces.php" 2 Testing comments', |
| 137 | + 'Testing comments', |
| 138 | + 2, |
| 139 | + null, |
| 140 | + 'file with spaces.php' |
| 141 | + ), |
| 142 | + array( |
| 143 | + 'example', |
| 144 | + '"file with spaces.php" 2 3 Testing comments', |
| 145 | + '"file with spaces.php" 2 3 Testing comments', |
| 146 | + 'Testing comments', |
| 147 | + 2, |
| 148 | + 3, |
| 149 | + 'file with spaces.php' |
| 150 | + ), |
| 151 | + array( |
| 152 | + 'example', |
| 153 | + '"file with spaces.php" 2 -3 Testing comments', |
| 154 | + '"file with spaces.php" 2 -3 Testing comments', |
| 155 | + '-3 Testing comments', |
| 156 | + 2, |
| 157 | + null, |
| 158 | + 'file with spaces.php' |
| 159 | + ), |
| 160 | + array( |
| 161 | + 'example', |
| 162 | + '"file with spaces.php" -2 3 Testing comments', |
| 163 | + '"file with spaces.php" -2 3 Testing comments', |
| 164 | + '-2 3 Testing comments', |
| 165 | + 1, |
| 166 | + null, |
| 167 | + 'file with spaces.php' |
| 168 | + ), |
| 169 | + array( |
| 170 | + 'example', |
| 171 | + 'file%20with%20spaces.php Testing comments', |
| 172 | + 'file%20with%20spaces.php Testing comments', |
| 173 | + 'Testing comments', |
| 174 | + 1, |
| 175 | + null, |
| 176 | + 'file with spaces.php' |
| 177 | + ), |
| 178 | + array( |
| 179 | + 'example', |
| 180 | + 'folder/file%20with%20spaces.php Testing comments', |
| 181 | + 'folder/file%20with%20spaces.php Testing comments', |
| 182 | + 'Testing comments', |
| 183 | + 1, |
| 184 | + null, |
| 185 | + 'folder/file with spaces.php' |
| 186 | + ), |
| 187 | + array( |
| 188 | + 'example', |
| 189 | + 'http://example.com/file%20with%20spaces.php Testing comments', |
| 190 | + 'http://example.com/file%20with%20spaces.php Testing comments', |
| 191 | + 'Testing comments', |
| 192 | + 1, |
| 193 | + null, |
| 194 | + 'http://example.com/file%20with%20spaces.php' |
| 195 | + ) |
| 196 | + ); |
| 197 | + } |
| 198 | +} |
0 commit comments