<?php

namespace Tests\Services\CityService;

use App\City;
use App\Services\CityService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class FindByNameTest extends TestCase
{
    /** @var CityService $cityService */
    public $cityService;

    public function setUp(): void
    {
        parent::setUp(); // TODO: Change the autogenerated stub
        $this->cityService = app(CityService::class);
        if(!City::query()->where('name','南京')->exists())
            factory(City::class)->create(['name'=>'南京']);
    }

    /**
     * @test
     */
    public function findByName()
    {
        /** @var City $city */
        $city = $this->cityService->findByName('南京市');
        $_city =City::query()->where('name','南京')->first();
        $this->assertEquals($city,$_city);
    }
}
