65 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			65 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| namespace Zoomyboy\LaravelNami\Tests\Unit;
 | |
| 
 | |
| use Illuminate\Support\Facades\Http;
 | |
| use Zoomyboy\LaravelNami\Data\SearchLayerOption;
 | |
| use Zoomyboy\LaravelNami\Enum\SearchLayer;
 | |
| use Zoomyboy\LaravelNami\Fakes\SearchLayerFake;
 | |
| use Zoomyboy\LaravelNami\Tests\TestCase;
 | |
| 
 | |
| class SearchLayerTest extends TestCase
 | |
| {
 | |
|     public function testItGetsSearchLayerOptionsForFirstLayer(): void
 | |
|     {
 | |
|         app(SearchLayerFake::class)->fetches('1', [
 | |
|             ['descriptor' => 'aa', 'id' => 5],
 | |
|             ['descriptor' => 'bb', 'id' => 6],
 | |
|         ]);
 | |
| 
 | |
|         $options = $this->login()->searchLayerOptions(SearchLayer::ROOT);
 | |
| 
 | |
|         $this->assertCount(2, $options);
 | |
|         $this->assertInstanceOf(SearchLayerOption::class, $options->first());
 | |
|         $this->assertEquals('aa', $options->first()->name);
 | |
|         $this->assertEquals(5, $options->first()->id);
 | |
| 
 | |
|         Http::assertSentCount(1);
 | |
|         app(SearchLayerFake::class)->assertFetched('1');
 | |
|     }
 | |
| 
 | |
|     public function testItGetsSecondLayer(): void
 | |
|     {
 | |
|         app(SearchLayerFake::class)->fetches('2/gruppierung1/50', [
 | |
|             ['descriptor' => 'kind', 'id' => 15],
 | |
|         ]);
 | |
| 
 | |
|         $options = $this->login()->searchLayerOptions(SearchLayer::FEDERAL, 50);
 | |
| 
 | |
|         $this->assertCount(1, $options);
 | |
|         $this->assertInstanceOf(SearchLayerOption::class, $options->first());
 | |
|         $this->assertEquals('kind', $options->first()->name);
 | |
|         $this->assertEquals(15, $options->first()->id);
 | |
| 
 | |
|         Http::assertSentCount(1);
 | |
|         app(SearchLayerFake::class)->assertFetched('2/gruppierung1/50');
 | |
|     }
 | |
| 
 | |
|     public function testItGetsThirdLayer(): void
 | |
|     {
 | |
|         app(SearchLayerFake::class)->fetches('3/gruppierung2/100', [
 | |
|             ['descriptor' => 'kinda', 'id' => 16],
 | |
|         ]);
 | |
| 
 | |
|         $options = $this->login()->searchLayerOptions(SearchLayer::REGION, 100);
 | |
| 
 | |
|         $this->assertCount(1, $options);
 | |
|         $this->assertInstanceOf(SearchLayerOption::class, $options->first());
 | |
|         $this->assertEquals('kinda', $options->first()->name);
 | |
|         $this->assertEquals(16, $options->first()->id);
 | |
| 
 | |
|         Http::assertSentCount(1);
 | |
|         app(SearchLayerFake::class)->assertFetched('3/gruppierung2/100');
 | |
|     }
 | |
| }
 |