<?php

namespace Tests\Unit;

use App\PivotNameAnalyser;
use Tests\TestCase;

class PivotNameAnalyserTest extends TestCase
{
    private PivotNameAnalyser $pivotNameAnalyser;

    protected function setUp(): void
    {
        parent::setUp(); // TODO: Change the autogenerated stub

        $this->pivotNameAnalyser = new PivotNameAnalyser(
            (app_path('../tests/__fixtures__/Muhoroni/pivot.geojson')),
            (app_path('../tests/__fixtures__/Muhoroni/harvest.xlsx'))
        );
    }

    /** @test */
    public function it_can_get_pivot_names_from_harvest_data()
    {
        $this->assertCount(49, $this->pivotNameAnalyser->getHarvestDataPivotNames());
        $this->assertContains('Nyando A2a', $this->pivotNameAnalyser->getHarvestDataPivotNames());
    }

    /** @test */
    public function it_can_get_pivot_names_from_pivot_geojson()
    {
        $this->assertCount(48, $this->pivotNameAnalyser->getGeoJsonPivotNames());
        $this->assertContains('Nyando A2a', $this->pivotNameAnalyser->getGeoJsonPivotNames());
    }

    /** @test */
    public function it_can_the_pivot_names_that_are_in_both_files()
    {
        $this->assertCount(40, $this->pivotNameAnalyser->getCommonPivotNames());
        $this->assertContains('Nyando A2a', $this->pivotNameAnalyser->getCommonPivotNames());
        $this->assertNotContains('N.c4', $this->pivotNameAnalyser->getCommonPivotNames());
        $this->assertNotContains('Nandi C4b', $this->pivotNameAnalyser->getCommonPivotNames());
    }

    /** @test */
    public function it_can_get_the_pivot_names_that_are_geo_json_file_but_not_in_harvest_file()
    {
        $this->assertCount(8, $this->pivotNameAnalyser->getGeoJsonPivotNamesNotInHarvest());
        $this->assertNotContains('Nandi A1a', $this->pivotNameAnalyser->getGeoJsonPivotNamesNotInHarvest());
        $this->assertContains('N.c4', $this->pivotNameAnalyser->getGeoJsonPivotNamesNotInHarvest());
    }

    /** @test */
    public function it_can_get_the_pivot_names_that_are_harvest_file_but_not_in_geo_json_file()
    {
        $this->assertCount(9, $this->pivotNameAnalyser->getHarvestPivotNamesNotInGeoJson());
        $this->assertNotContains('Nandi A1a', $this->pivotNameAnalyser->getHarvestPivotNamesNotInGeoJson());
        $this->assertContains('Nandi C4b', $this->pivotNameAnalyser->getHarvestPivotNamesNotInGeoJson());
    }
}
