/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Http/Resources/JsonApi/JsonApiResourceTest.php
50 строк
1 KB
Lucas Michot
[13.x] Simplify most of the exceptions expectations (#61049)
05 авг 2026, 18:34
Не верифицирован
05 авг 2026, 18:34
910cd94
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Http\Resources\JsonApi; use BadMethodCallException; use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\JsonApi\JsonApiResource; use PHPUnit\Framework\TestCase; class JsonApiResourceTest extends TestCase { protected function tearDown(): void { JsonResource::flushState(); JsonApiResource::flushState(); } public function testResponseWrapperIsHardCodedToData() { JsonResource::wrap('laravel'); $this->assertSame('data', JsonApiResource::$wrap); } public function testUnableToSetWrapper() { $this->expectExceptionObject(new BadMethodCallException('Using Illuminate\Http\Resources\JsonApi\JsonApiResource::wrap() method is not allowed.')); JsonApiResource::wrap('laravel'); } public function testUnableToUnsetWrapper() { $this->expectExceptionObject(new BadMethodCallException('Using Illuminate\Http\Resources\JsonApi\JsonApiResource::withoutWrapping() method is not allowed.')); JsonApiResource::withoutWrapping(); } public function testFlushStateResetsMaxRelationshipDepthToDefault() { $this->assertSame(5, JsonApiResource::$maxRelationshipDepth); JsonApiResource::maxRelationshipDepth(10); $this->assertSame(10, JsonApiResource::$maxRelationshipDepth); JsonApiResource::flushState(); $this->assertSame(5, JsonApiResource::$maxRelationshipDepth); } }