yiisoft /
yii-widgets
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace Yiisoft\Yii\Widgets\Tests\Breadcrumbs; |
||||
| 6 | |||||
| 7 | use InvalidArgumentException; |
||||
| 8 | use PHPUnit\Framework\TestCase; |
||||
| 9 | use Yiisoft\Definitions\Exception\CircularReferenceException; |
||||
| 10 | use Yiisoft\Definitions\Exception\InvalidConfigException; |
||||
| 11 | use Yiisoft\Definitions\Exception\NotInstantiableException; |
||||
| 12 | use Yiisoft\Factory\NotFoundException; |
||||
| 13 | use Yiisoft\Yii\Widgets\Breadcrumbs; |
||||
| 14 | use Yiisoft\Yii\Widgets\Tests\Support\TestTrait; |
||||
| 15 | |||||
| 16 | /** |
||||
| 17 | * @psalm-suppress PropertyNotSetInConstructor |
||||
| 18 | */ |
||||
| 19 | final class ExceptionTest extends TestCase |
||||
| 20 | { |
||||
| 21 | use TestTrait; |
||||
| 22 | |||||
| 23 | /** |
||||
| 24 | * @throws CircularReferenceException |
||||
| 25 | * @throws InvalidArgumentException |
||||
| 26 | * @throws InvalidConfigException |
||||
| 27 | * @throws NotFoundException |
||||
| 28 | * @throws NotInstantiableException |
||||
| 29 | */ |
||||
| 30 | public function testHomeItemThrowExceptionForEmptyArray(): void |
||||
| 31 | { |
||||
| 32 | $this->expectException(InvalidArgumentException::class); |
||||
| 33 | $this->expectExceptionMessage( |
||||
| 34 | 'The home item cannot be an empty array. To disable rendering of the home item, specify null.', |
||||
| 35 | ); |
||||
| 36 | Breadcrumbs::widget()->homeItem([]); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 37 | } |
||||
| 38 | |||||
| 39 | /** |
||||
| 40 | * @throws CircularReferenceException |
||||
| 41 | * @throws InvalidArgumentException |
||||
| 42 | * @throws InvalidConfigException |
||||
| 43 | * @throws NotFoundException |
||||
| 44 | * @throws NotInstantiableException |
||||
| 45 | */ |
||||
| 46 | public function testLabelNotString(): void |
||||
| 47 | { |
||||
| 48 | $this->expectException(InvalidArgumentException::class); |
||||
| 49 | $this->expectExceptionMessage('The "label" element must be a string.'); |
||||
| 50 | Breadcrumbs::widget()->items([['label' => 1]])->render(); |
||||
|
0 ignored issues
–
show
The method
items() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Yii\Widgets\Menu or Yiisoft\Yii\Widgets\Breadcrumbs or Yiisoft\Yii\Widgets\Dropdown.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 51 | } |
||||
| 52 | |||||
| 53 | /** |
||||
| 54 | * @throws CircularReferenceException |
||||
| 55 | * @throws InvalidArgumentException |
||||
| 56 | * @throws InvalidConfigException |
||||
| 57 | * @throws NotFoundException |
||||
| 58 | * @throws NotInstantiableException |
||||
| 59 | */ |
||||
| 60 | public function testRenderItem(): void |
||||
| 61 | { |
||||
| 62 | $this->expectException(InvalidArgumentException::class); |
||||
| 63 | $this->expectExceptionMessage('The "label" element is required for each item.'); |
||||
| 64 | Breadcrumbs::widget()->homeItem(null)->items([['url' => 'http://my.example.com/yii2/link/page']])->render(); |
||||
| 65 | } |
||||
| 66 | } |
||||
| 67 |