|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * This file is part of phpDocumentor. |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + * |
| 11 | + * @link http://phpdoc.org |
| 12 | + */ |
| 13 | + |
| 14 | +namespace phpDocumentor\Reflection\PseudoTypes; |
| 15 | + |
| 16 | +use phpDocumentor\Reflection\Types\Compound; |
| 17 | +use phpDocumentor\Reflection\Types\Integer; |
| 18 | +use phpDocumentor\Reflection\Types\Mixed_; |
| 19 | +use phpDocumentor\Reflection\Types\String_; |
| 20 | +use PHPUnit\Framework\TestCase; |
| 21 | + |
| 22 | +/** |
| 23 | + * @coversDefaultClass \phpDocumentor\Reflection\PseudoTypes\NonEmptyList |
| 24 | + */ |
| 25 | +class NonEmptyListTest extends TestCase |
| 26 | +{ |
| 27 | + /** |
| 28 | + * @dataProvider provideArrays |
| 29 | + * @covers ::__toString |
| 30 | + */ |
| 31 | + public function testArrayStringifyCorrectly(NonEmptyList $array, string $expectedString): void |
| 32 | + { |
| 33 | + $this->assertSame($expectedString, (string) $array); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * @return mixed[] |
| 38 | + */ |
| 39 | + public function provideArrays(): array |
| 40 | + { |
| 41 | + return [ |
| 42 | + 'simple non-empty-list' => [new NonEmptyList(), 'non-empty-list'], |
| 43 | + 'non-empty-list of mixed' => [new NonEmptyList(new Mixed_()), 'non-empty-list'], |
| 44 | + 'non-empty-list of single type' => [new NonEmptyList(new String_()), 'non-empty-list<string>'], |
| 45 | + 'non-empty-list of compound type' => |
| 46 | + [new NonEmptyList(new Compound([new Integer(), new String_()])), 'non-empty-list<int|string>'], |
| 47 | + ]; |
| 48 | + } |
| 49 | +} |
0 commit comments