Rename the tests to pass phpcs checks
This commit is contained in:
parent
3946e9aac4
commit
d5bbed1eac
52 changed files with 1329 additions and 1062 deletions
|
@ -1,55 +1,57 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\Place;
|
||||
use App\Services\PlaceService;
|
||||
use MStaack\LaravelPostgis\Geometries\Point;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use InvalidArgumentException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PlacesTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_notes_method()
|
||||
/** @test */
|
||||
public function canRetrieveAssociatedNotes(): void
|
||||
{
|
||||
$place = Place::find(1);
|
||||
$this->assertInstanceOf(Collection::class, $place->notes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the near method returns a collection.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_near_method()
|
||||
/** @test */
|
||||
public function nearMethodReturnsCollection(): void
|
||||
{
|
||||
$nearby = Place::near((object) ['latitude' => 53.5, 'longitude' => -2.38], 1000)->get();
|
||||
$this->assertEquals('the-bridgewater-pub', $nearby[0]->slug);
|
||||
}
|
||||
|
||||
public function test_longurl_method()
|
||||
/** @test */
|
||||
public function getLongurl(): void
|
||||
{
|
||||
$place = Place::find(1);
|
||||
$this->assertEquals(config('app.url') . '/places/the-bridgewater-pub', $place->longurl);
|
||||
}
|
||||
|
||||
public function test_uri_method()
|
||||
{
|
||||
$place = Place::find(1);
|
||||
$this->assertEquals(config('app.url') . '/places/the-bridgewater-pub', $place->uri);
|
||||
|
||||
}
|
||||
|
||||
public function test_shorturl_method()
|
||||
/** @test */
|
||||
public function getShorturl()
|
||||
{
|
||||
$place = Place::find(1);
|
||||
$this->assertEquals(config('app.shorturl') . '/places/the-bridgewater-pub', $place->shorturl);
|
||||
}
|
||||
|
||||
public function test_service_returns_existing_place()
|
||||
/** @test */
|
||||
public function getUri(): void
|
||||
{
|
||||
$place = Place::find(1);
|
||||
$this->assertEquals(config('app.url') . '/places/the-bridgewater-pub', $place->uri);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function placeServiceReturnsExistingPlaceBasedOnExternalUrlsSearch(): void
|
||||
{
|
||||
$place = new Place();
|
||||
$place->name = 'Temp Place';
|
||||
|
@ -64,28 +66,31 @@ class PlacesTest extends TestCase
|
|||
]
|
||||
]);
|
||||
$this->assertInstanceOf('App\Models\Place', $ret); // a place was returned
|
||||
$this->assertEquals(12, count(Place::all())); // still 2 places
|
||||
$this->assertCount(12, Place::all()); // still 12 places
|
||||
}
|
||||
|
||||
public function test_service_requires_name()
|
||||
/** @test */
|
||||
public function placeServiceRequiresNameWhenCreatingNewPlace(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Missing required name');
|
||||
|
||||
$service = new PlaceService();
|
||||
$service->createPlaceFromCheckin(['foo' => 'bar']);
|
||||
}
|
||||
|
||||
public function test_service_requires_latitude()
|
||||
/** @test */
|
||||
public function placeServiceRequiresLatitudeWhenCreatingNewPlace(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Missing required longitude/latitude');
|
||||
|
||||
$service = new PlaceService();
|
||||
$service->createPlaceFromCheckin(['properties' => ['name' => 'bar']]);
|
||||
}
|
||||
|
||||
public function test_updating_external_urls()
|
||||
/** @test */
|
||||
public function placeServcieCanupdateExternalUrls(): void
|
||||
{
|
||||
$place = Place::find(1);
|
||||
$place->external_urls = 'https://bridgewater.pub';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue