Browse Source

Update codebase and tests

pull/11/head
Nafies Luthfi 5 years ago
parent
commit
49b7e91054
  1. 10
      app/Exceptions/Handler.php
  2. 15
      tests/Feature/Api/OutletListingTest.php
  3. 8
      tests/Unit/Models/OutletTest.php

10
app/Exceptions/Handler.php

@ -2,8 +2,8 @@
namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
@ -29,10 +29,10 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
*
* @param \Exception $exception
* @param \Throwable $exception
* @return void
*/
public function report(Exception $exception)
public function report(Throwable $exception)
{
parent::report($exception);
}
@ -41,10 +41,10 @@ class Handler extends ExceptionHandler
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @param \Throwable $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
}

15
tests/Feature/Api/OutletListingTest.php

@ -3,8 +3,8 @@
namespace Tests\Feature\Api;
use App\Outlet;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\BrowserKitTest as TestCase;
class OutletListingTest extends TestCase
{
@ -17,7 +17,7 @@ class OutletListingTest extends TestCase
$this->getJson(route('api.outlets.index'));
$this->seeJsonSubset([
$this->seeJsonContains([
'type' => 'FeatureCollection',
'features' => [
[
@ -26,12 +26,19 @@ class OutletListingTest extends TestCase
'name' => $outlet->name,
'address' => $outlet->address,
'coordinate' => $outlet->coordinate,
'latitude' => (string) $outlet->latitude,
'longitude' => (string) $outlet->longitude,
'map_popup_content' => $outlet->map_popup_content,
'creator_id' => (string) $outlet->creator_id,
'id' => $outlet->id,
'created_at' => $outlet->created_at,
'updated_at' => $outlet->updated_at,
],
'geometry' => [
'type' => 'Point',
'coordinates' => [
$outlet->longitude,
$outlet->latitude,
(string) $outlet->longitude,
(string) $outlet->latitude,
],
],
],

8
tests/Unit/Models/OutletTest.php

@ -2,14 +2,14 @@
namespace Tests\Unit\Models;
use App\User;
use App\Outlet;
use App\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class OutletTest extends TestCase
{
use DatabaseMigrations;
use RefreshDatabase;
/** @test */
public function an_outlet_has_name_link_attribute()
@ -52,7 +52,7 @@ class OutletTest extends TestCase
/** @test */
public function an_outlet_has_map_popup_content_attribute()
{
$outlet = factory(Outlet::class)->make(['lat' => '-3.333333', 'long' => '114.583333']);
$outlet = factory(Outlet::class)->create(['latitude' => '-3.333333', 'longitude' => '114.583333']);
$mapPopupContent = '';
$mapPopupContent .= '<div class="my-2"><strong>'.__('outlet.name').':</strong><br>'.$outlet->name_link.'</div>';

Loading…
Cancel
Save